Mcp API
This page documents the 4 gateway endpoints tagged mcp in the gateway's OpenAPI document. Every example targets a gateway on http://localhost:4000 and authenticates with the SPANWAY_API_KEY environment variable, which holds the master key or a virtual key that has access to the route. Request and response fields are taken from the schema the running gateway publishes at /openapi.json, and the same document is bundled with this site as openapi.json.
| Method | Path | Summary |
|---|---|---|
| GET | /v1/mcp/admin_server | Check whether the admin MCP server is available |
| POST | /admin/mcp | Manage the gateway from an AI assistant through the hosted admin MCP server |
| GET | /admin/healthz | Check that the hosted admin MCP server is mounted |
| GET | /.well-known/oauth-protected-resource/admin/mcp | Tell an MCP client how to sign in to the hosted admin MCP server |
Endpoints
GET /v1/mcp/admin_server
Check whether the admin MCP server is available
Tells an admin whether an AI assistant can manage this gateway through the hosted admin MCP server at /admin/mcp: whether the server is mounted, whether the license includes the admin_mcp feature, whether MCP clients can sign in with OAuth, whether only read tools are exposed and the lowest role that may connect. Proxy admins and admin viewers may call it, and it changes nothing.
Example request:
curl -X GET "http://localhost:4000/v1/mcp/admin_server" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Whether the admin MCP server is mounted, licensed, offers OAuth sign-in and is read only | application/json AdminMcpStatus |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key is not a proxy admin or admin viewer key | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
enabled | boolean | Yes | True when the admin MCP server is mounted on this gateway |
licensed | boolean | Yes | True when the license includes the admin_mcp feature |
oauth_sign_in | boolean | Yes | True when MCP clients can sign in with OAuth instead of a key |
read_only | boolean | Yes | True when SPANWAY_ADMIN_READ_ONLY hides every tool that changes data |
path | string | Yes | The path MCP clients connect to |
min_role | enum: "internal_user", "team_admin", "org_admin", "proxy_admin" | No | The lowest role that may connect, set by SPANWAY_ADMIN_MCP_MIN_ROLE |
POST /admin/mcp
Manage the gateway from an AI assistant through the hosted admin MCP server
The hosted admin MCP server. An MCP client such as an IDE or desktop assistant posts one JSON-RPC message of the MCP streamable HTTP transport, such as initialize, tools/list or tools/call, with the person's own virtual key or OAuth session token as a bearer credential. Every tool runs with that person's own permissions, the tools they may not use are hidden, and every tool call writes an audit row. The server is mounted only when SPANWAY_ENABLE_ADMIN_MCP is true and the license includes the admin_mcp feature. A refused tool call answers 200 with isError true and the reason in the result text. Docs (https://docs.spanway.ai/docs/mcp/admin_server)
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
jsonrpc | "2.0" | Yes | |
id | string or integer | No | |
method | string | Yes | For example initialize, tools/list or tools/call |
params | object | No |
Example request:
curl -X POST "http://localhost:4000/admin/mcp" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 7,
"method": "tools/call",
"params": {
"name": "approve_access_request",
"arguments": {
"body": {
"request_id": "req-1"
}
}
}
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The JSON-RPC answer, as one JSON body or as server-sent events when the client accepts them | application/json object |
| 401 | No bearer credential was sent, or the session token is invalid or expired. The WWW-Authenticate header points the client at the protected resource metadata so it can sign in | application/json object |
| 403 | The license lacks the admin_mcp feature, the caller's role is below SPANWAY_ADMIN_MCP_MIN_ROLE, or the client IP is outside the allowed_ips of the caller's teams and organizations. A license refusal answers detail.error, a connector refusal answers error, for example This Spanway identity may not use the admin connector. | application/json object |
| 503 | The gateway cannot check the caller right now, for example OAuth sign-in needs the Admin UI login or the session tokens cannot be verified | application/json object |
GET /admin/healthz
Check that the hosted admin MCP server is mounted
Answers ok with the admin MCP version when the server is mounted on this gateway. It needs no bearer credential, but it still needs a license with the admin_mcp feature, and it changes nothing. Docs (https://docs.spanway.ai/docs/mcp/admin_server)
Example request:
curl -X GET "http://localhost:4000/admin/healthz"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The admin MCP server is mounted | application/json object |
| 403 | The license lacks the admin_mcp feature, the caller's role is below SPANWAY_ADMIN_MCP_MIN_ROLE, or the client IP is outside the allowed_ips of the caller's teams and organizations. A license refusal answers detail.error, a connector refusal answers error, for example This Spanway identity may not use the admin connector. | application/json object |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
status | string | No | |
version | string | No |
GET /.well-known/oauth-protected-resource/admin/mcp
Tell an MCP client how to sign in to the hosted admin MCP server
RFC 9728 metadata for /admin/mcp. MCP clients fetch it by themselves after a 401 and then sign the person in through the gateway's OAuth endpoints. Anyone may call it without a key, and nothing is changed. Docs (https://docs.spanway.ai/docs/mcp/admin_server)
Example request:
curl -X GET "http://localhost:4000/.well-known/oauth-protected-resource/admin/mcp"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Where the client signs in for the admin MCP server | application/json object |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
resource | string | Yes | |
resource_name | string | No | |
authorization_servers | array of string | Yes | |
bearer_methods_supported | array of string | No | |
scopes_supported | array of string | No |