Skip to main content

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.

MethodPathSummary
GET/v1/mcp/admin_serverCheck whether the admin MCP server is available
POST/admin/mcpManage the gateway from an AI assistant through the hosted admin MCP server
GET/admin/healthzCheck that the hosted admin MCP server is mounted
GET/.well-known/oauth-protected-resource/admin/mcpTell 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:

StatusDescriptionBody
200Whether the admin MCP server is mounted, licensed, offers OAuth sign-in and is read onlyapplication/json AdminMcpStatus
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key is not a proxy admin or admin viewer keyapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
enabledbooleanYesTrue when the admin MCP server is mounted on this gateway
licensedbooleanYesTrue when the license includes the admin_mcp feature
oauth_sign_inbooleanYesTrue when MCP clients can sign in with OAuth instead of a key
read_onlybooleanYesTrue when SPANWAY_ADMIN_READ_ONLY hides every tool that changes data
pathstringYesThe path MCP clients connect to
min_roleenum: "internal_user", "team_admin", "org_admin", "proxy_admin"NoThe 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):

FieldTypeRequiredDescription
jsonrpc"2.0"Yes
idstring or integerNo
methodstringYesFor example initialize, tools/list or tools/call
paramsobjectNo

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:

StatusDescriptionBody
200The JSON-RPC answer, as one JSON body or as server-sent events when the client accepts themapplication/json object
401No 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 inapplication/json object
403The 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
503The gateway cannot check the caller right now, for example OAuth sign-in needs the Admin UI login or the session tokens cannot be verifiedapplication/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:

StatusDescriptionBody
200The admin MCP server is mountedapplication/json object
403The 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):

FieldTypeRequiredDescription
statusstringNo
versionstringNo

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:

StatusDescriptionBody
200Where the client signs in for the admin MCP serverapplication/json object

Response fields (200):

FieldTypeRequiredDescription
resourcestringYes
resource_namestringNo
authorization_serversarray of stringYes
bearer_methods_supportedarray of stringNo
scopes_supportedarray of stringNo