Mcp discoverable API
This page documents the 15 gateway endpoints tagged mcp_discoverable 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 | /.well-known/jwks.json | Read the keys that verify gateway-signed MCP tokens |
| GET | /.well-known/openid-configuration | Read the gateway's OpenID discovery document |
| GET | /.well-known/spanway-cli-auth | Read how a command line client signs in |
| GET | /authorize | Start an OAuth sign-in |
| POST | /authorize/complete | Approve or deny a client on the connect page |
| GET | /authorize/flow | Describe a sign-in waiting on the connect page |
| GET | /authorize/mcp-session | Start signing in to the shared MCP endpoint |
| GET | /callback | Receive the answer of an MCP server's sign-in provider |
| POST | /introspect | Check whether a gateway session token is valid |
| POST | /register | Register an MCP client |
| POST | /revoke | Sign a command line client out |
| POST | /token | Exchange a code or refresh token |
| GET | /{mcp_server_name}/authorize | Start signing in to one MCP server |
| POST | /{mcp_server_name}/register | Register an MCP client for one server |
| POST | /{mcp_server_name}/token | Exchange a code or refresh token for one server |
Endpoints
GET /.well-known/jwks.json
Read the keys that verify gateway-signed MCP tokens
Give MCP servers and other gateways the public keys that check the tokens the gateway signs when it calls them, so they can trust a call without a shared secret. The set is empty while the MCP token signing guardrail is off. Anyone may call it without a key. Only public keys are shown, and nothing is changed.
Example request:
curl -X GET "http://localhost:4000/.well-known/jwks.json"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The public signing keys | application/json JsonWebKeySet |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
keys | array of JsonWebKey | Yes | The public keys, empty when MCP token signing is off |
GET /.well-known/openid-configuration
Read the gateway's OpenID discovery document
The same sign-in addresses as /.well-known/oauth-authorization-server, under the name OpenID clients look for. When the MCP token signing guardrail is on, it also names the key set that verifies the tokens the gateway signs for MCP servers. MCP clients fetch this document by themselves when they connect, so people rarely call it by hand. Anyone may call it without a key, and nothing is changed.
Example request:
curl -X GET "http://localhost:4000/.well-known/openid-configuration"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The sign-in addresses for this MCP server | application/json AuthorizationServerMetadata |
| 404 | No OAuth MCP server has that name | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
authorization_endpoint | string | Yes | Where the browser goes to sign in |
code_challenge_methods_supported | array of string | Yes | Always S256, PKCE is required |
grant_types_supported | array of string | Yes | The grants the token endpoint accepts |
id_token_signing_alg_values_supported | array of string or null | No | Signature algorithms, present when MCP token signing is on |
introspection_endpoint | string or null | No | Token check address, aggregate only |
issuer | string | Yes | The authorization server's identifier, checked by strict clients |
jwks_uri | string or null | No | Signing keys, present when MCP token signing is on |
registration_endpoint | string | Yes | Where the client registers itself before signing in |
response_types_supported | array of string | Yes | Always code |
scopes_supported | array of string | Yes | The scopes the client may ask for |
token_endpoint | string | Yes | Where the client trades the code for tokens |
token_endpoint_auth_methods_supported | array of string | Yes | How a client proves itself |
GET /.well-known/spanway-cli-auth
Read how a command line client signs in
Give a command line client such as spanwayctl login --pkce, or a tool you write in any language, everything it needs to sign a person in through the browser and receive a gateway key: the sign-in, token, registration and sign-out addresses, the resource value to send, and the grants on offer. Check contract_version before trusting the rest. Anyone may call it without a key, and nothing is changed. Docs
Example request:
curl -X GET "http://localhost:4000/.well-known/spanway-cli-auth"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The sign-in contract | application/json NativeClientAuthDiscovery |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
authorization_endpoint | string | Yes | Where the browser signs in |
code_challenge_methods_supported | array of string | Yes | Always S256 |
contract_version | integer | Yes | Raised only when a field changes meaning or goes away |
grant_types_supported | array of string | Yes | The grants the token endpoint accepts |
issuer | string | Yes | The gateway's base URL |
registration_endpoint | string | Yes | Where the client registers itself |
resource | string | Yes | The exact resource value to send so the grant is for the gateway API |
response_types_supported | array of string | Yes | Always code |
revocation_endpoint | string | Yes | Where the client signs out |
revocation_endpoint_auth_methods_supported | array of string | Yes | Always none |
token_endpoint | string | Yes | Where the client trades the code for a key |
token_endpoint_auth_methods_supported | array of string | Yes | Always none, a public client |
GET /authorize
Start an OAuth sign-in
Start an OAuth sign-in in the browser. For one MCP server that signs in with its own provider, the browser is sent on to that provider with the gateway's client details, and the provider later returns to /callback. For a client the gateway registered itself, the person signs in to Spanway and approves the client on the connect page. MCP clients open this address by themselves. Anyone may open it and nothing is stored until the sign-in finishes. Docs (https://docs.spanway.ai/docs/mcp/oauth)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
redirect_uri | query | string | Yes | |
client_id | query | string or null | No | |
state | query | string | No | |
mcp_server_name | query | string or null | No | |
code_challenge | query | string or null | No | |
code_challenge_method | query | string or null | No | |
response_type | query | string or null | No | |
scope | query | string or null | No | |
resource | query | string or null | No |
Example request:
curl -X GET "http://localhost:4000/authorize?redirect_uri=string"
Responses:
| Status | Description | Body |
|---|---|---|
| 303 | Sent to Spanway sign-in or to the connect page | |
| 307 | Sent to the MCP server's own sign-in provider | application/json any |
| 400 | The client id, redirect address, PKCE challenge or scope is invalid, so nothing is redirected | application/json OAuthErrorBody |
| 404 | No MCP server has that name | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
POST /authorize/complete
Approve or deny a client on the connect page
Finish a sign-in from the connect page. On approve the gateway creates a one-time code for the signed-in user and sends the browser back to the client with it, or, with delivery=manual for a client running on another machine, shows the return address to copy there. On deny the client gets access_denied. A command line client's approval can name the team_id its key is billed to. Only the signed-in Spanway user who started the sign-in may finish it, and each sign-in finishes once. Docs (https://docs.spanway.ai/docs/mcp/oauth)
Request body (application/x-www-form-urlencoded, schema Body_authorize_complete_authorize_complete_post):
| Field | Type | Required | Description |
|---|---|---|---|
decision | string or null | No | Decision |
delivery | string or null | No | Delivery |
flow | string | Yes | Flow |
team_id | string or null | No | Team Id |
Example request:
curl -X POST "http://localhost:4000/authorize/complete"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The page with the return address to copy, for delivery=manual | text/html string |
| 303 | Sent back to the client with the code, or with error=access_denied | |
| 400 | The sign-in is unknown, expired, already finished, or its MCP server still needs approval | application/json OAuthErrorBody |
| 401 | Nobody is signed in to Spanway | application/json OAuthErrorBody |
| 403 | Another user started this sign-in | application/json OAuthErrorBody |
| 422 | Validation Error | application/json HTTPValidationError |
GET /authorize/flow
Describe a sign-in waiting on the connect page
Tell the Admin UI connect page what a sign-in in progress is for: which client is asking, which MCP server it wants if only one, and whether that server's own sign-in is already done. Only the signed-in Spanway user who started the sign-in, in the same browser, gets an answer. Nothing is changed.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
flow | query | string | Yes |
Example request:
curl -X GET "http://localhost:4000/authorize/flow?flow=string"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The sign-in the connect page shows | application/json ConnectFlowView |
| 400 | The sign-in is unknown or expired | application/json OAuthErrorBody |
| 401 | Nobody is signed in to Spanway | application/json OAuthErrorBody |
| 403 | Another user started this sign-in | application/json OAuthErrorBody |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
client_origin | string | Yes | The scheme and host of the client being connected |
connected | boolean or null | Yes | Whether that server's own sign-in is already done |
requested_scopes | array of string or null | No | Extra scopes asked for |
server_id | string or null | Yes | The one MCP server this sign-in is for, if any |
server_name | string or null | Yes | That server's display name |
state | enum: "unscoped", "interactive", "m2m", "stale" | Yes | interactive when the user must still approve one server, stale when it is gone |
GET /authorize/mcp-session
Start signing in to the shared MCP endpoint
The first step an MCP client takes in the browser to connect to the shared /mcp endpoint. A person who is not signed in to Spanway is sent to sign in first, then to the connect page where they approve the client. The address comes from the gateway's discovery document. Anyone may open it, it needs a registered client id, a redirect address and a PKCE S256 challenge, and it only starts a sign-in that expires on its own. Docs (https://docs.spanway.ai/docs/mcp/oauth)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
redirect_uri | query | string | Yes | |
client_id | query | string | Yes | |
state | query | string | No | |
code_challenge | query | string or null | No | |
code_challenge_method | query | string or null | No | |
response_type | query | string or null | No | |
resource | query | string or null | No | |
scope | query | string or null | No |
Example request:
curl -X GET "http://localhost:4000/authorize/mcp-session?redirect_uri=string&client_id=client_id-123"
Responses:
| Status | Description | Body |
|---|---|---|
| 303 | Sent to Spanway sign-in, or to the connect page once signed in | application/json any |
| 400 | The client id, redirect address, PKCE challenge or scope is invalid, so nothing is redirected | application/json OAuthErrorBody |
| 422 | Validation Error | application/json HTTPValidationError |
GET /callback
Receive the answer of an MCP server's sign-in provider
Where an MCP server's own sign-in provider sends the browser back after the person signed in or refused. The gateway checks that the answer belongs to a sign-in it started, then sends the browser on to the MCP client's own return address with the code or the provider's error. When the answer cannot be matched to a trusted return address, a short error page is shown instead. Providers call it, not people, and it needs no key. Docs (https://docs.spanway.ai/docs/mcp/oauth)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
code | query | string or null | No | |
state | query | string or null | No | |
iss | query | string or null | No | |
error | query | string or null | No | |
error_description | query | string or null | No | |
error_uri | query | string or null | No |
Example request:
curl -X GET "http://localhost:4000/callback"
Responses:
| Status | Description | Body |
|---|---|---|
| 302 | Sent back to the MCP client with the code or the provider's error | application/json any |
| 400 | An error page, because the answer could not be matched to a trusted client | text/html string |
| 422 | Validation Error | application/json HTTPValidationError |
POST /introspect
Check whether a gateway session token is valid
Tell another gateway or service whether an MCP session token or refresh token the gateway issued is still valid, and for whom, without sharing the signing secret. Any valid key may call it. A token the gateway cannot vouch for answers only active: false. Nothing is changed.
Request body (application/x-www-form-urlencoded, schema Body_introspect_endpoint_introspect_post):
| Field | Type | Required | Description |
|---|---|---|---|
token | string | Yes | Token |
Example request:
curl -X POST "http://localhost:4000/introspect" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Whether the token is live and who it belongs to | application/json TokenIntrospection |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway has no master key to check tokens with | application/json OAuthErrorBody |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
active | boolean | Yes | True only for a live token the gateway issued |
audience | string or null | No | Who the token is meant for |
client_id | string or null | No | The client the token was issued to |
exp | integer or null | No | Expires at, Unix seconds |
iat | integer or null | No | Issued at, Unix seconds |
iss | string or null | No | Who issued the token |
jti | string or null | No | The token's unique id |
kind | string or null | No | session or session_refresh |
resource_server_id | string or null | No | The one MCP server the token is scoped to |
sub | string or null | No | The user the token belongs to |
team_id | string or null | No | The team the credential is billed to |
token_type | string or null | No | Bearer for a session token |
POST /register
Register an MCP client
Part of the OAuth 2.1 front door that MCP clients walk when they connect to /mcp or to one server at /{mcp_server_name}/mcp. Clients discover these routes from the /.well-known metadata and never call them by hand.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
mcp_server_name | query | string or null | No |
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
application_type | string or null | No | Application Type |
client_name | string or null | No | Client Name |
grant_types | array of string | No | Grant Types |
redirect_uris | array of string | Yes | Where the client receives the authorization code |
response_types | array of string | No | Response Types |
token_endpoint_auth_method | string | No | Token Endpoint Auth Method |
Example request:
curl -X POST "http://localhost:4000/register" \
-H "Content-Type: application/json" \
-d '{
"client_name": "Claude Desktop",
"grant_types": [
"authorization_code",
"refresh_token"
],
"redirect_uris": [
"http://127.0.0.1:52341/callback"
],
"response_types": [
"code"
],
"token_endpoint_auth_method": "none"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The registered client. The gateway stores nothing, the client id seals the redirect URIs | application/json MCPClientRegistrationResponse |
| 201 | The registered client. The gateway stores nothing, the sealed client id carries the redirect URIs | application/json MCPClientRegistrationResponse |
| 400 | A redirect URI is not allowed, or the registration metadata is too large | application/json OAuthErrorBody |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
client_id | string | Yes | Client Id |
client_id_issued_at | integer or null | No | Client Id Issued At |
client_name | string or null | No | Client Name |
client_secret | string or null | No | Client Secret |
grant_types | array of string | No | Grant Types |
redirect_uris | array of string | No | Redirect Uris |
response_types | array of string | No | Response Types |
token_endpoint_auth_method | string or null | No | Token Endpoint Auth Method |
POST /revoke
Sign a command line client out
Revoke a refresh token the gateway issued, which is what spanwayctl logout calls, so the token can never be used again. Access tokens are not revoked, they simply expire. Anyone holding the token may call it with the client id it was issued to. A known client always gets 200, whatever state the token was in, so the answer reveals nothing about the token.
Request body (application/x-www-form-urlencoded, schema Body_revoke_endpoint_revoke_post):
| Field | Type | Required | Description |
|---|---|---|---|
client_id | string | Yes | Client Id |
token | string | Yes | Token |
Example request:
curl -X POST "http://localhost:4000/revoke"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The token can no longer be used | application/json object |
| 401 | The client id is unknown or malformed | application/json OAuthErrorBody |
| 422 | Validation Error | application/json HTTPValidationError |
| 503 | The shared record that blocks reuse could not be written, try again | application/json OAuthErrorBody |
POST /token
Exchange a code or refresh token
The last step of an MCP client's sign-in: trade the one-time code from the sign-in for an access token and a refresh token, or trade a refresh token for a new access token. The client sends its PKCE code_verifier and the same redirect_uri it signed in with. For one MCP server that signs in with its own provider, the gateway relays the exchange to that provider and keeps the user's token so later tool calls can use it. Anyone may call it, the code or refresh token is the proof. A code works once and expires within minutes. An agent bound to an identity provider application can also send grant_type token-exchange with its own token as subject_token and the name of one of its stored SaaS credentials as audience, and gets that credential back as access_token. Docs (https://docs.spanway.ai/docs/mcp/oauth) and agent credentials (https://docs.spanway.ai/docs/proxy/agent_credentials)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
mcp_server_name | query | string or null | No |
Request body (application/x-www-form-urlencoded, schema Body_token_endpoint_token_post):
| Field | Type | Required | Description |
|---|---|---|---|
audience | string or null | No | Audience |
client_id | string | Yes | Client Id |
client_secret | string or null | No | Client Secret |
code | string | No | Code |
code_verifier | string | No | Code Verifier |
grant_type | string | Yes | Grant Type |
redirect_uri | string | No | Redirect Uri |
refresh_token | string or null | No | Refresh Token |
requested_token_type | string or null | No | Requested Token Type |
resource | string or null | No | Resource |
scope | string or null | No | Scope |
subject_token | string or null | No | Subject Token |
subject_token_type | string or null | No | Subject Token Type |
Example request:
curl -X POST "http://localhost:4000/token"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The session tokens for the signed-in user, or for an agent token exchange the agent's stored SaaS credential with token_type N_A and no refresh token | application/json MCPOAuthTokenResponse or AgentCredentialTokenResponse |
| 400 | The code expired, was used already, or the PKCE verifier does not match, or an agent token exchange was refused | application/json OAuthErrorBody |
| 404 | No registered server has that name | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 503 | The gateway could not read the agent's stored credentials, or has no database for them. Retry | application/json OAuthErrorBody |
GET /{mcp_server_name}/authorize
Start signing in to one MCP server
Start an OAuth sign-in in the browser. For one MCP server that signs in with its own provider, the browser is sent on to that provider with the gateway's client details, and the provider later returns to /callback. For a client the gateway registered itself, the person signs in to Spanway and approves the client on the connect page. MCP clients open this address by themselves. Anyone may open it and nothing is stored until the sign-in finishes. Docs (https://docs.spanway.ai/docs/mcp/oauth)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
mcp_server_name | path | string or null | Yes | |
redirect_uri | query | string | Yes | |
client_id | query | string or null | No | |
state | query | string | No | |
code_challenge | query | string or null | No | |
code_challenge_method | query | string or null | No | |
response_type | query | string or null | No | |
scope | query | string or null | No | |
resource | query | string or null | No |
Example request:
curl -X GET "http://localhost:4000/mcp_server_name-123/authorize?redirect_uri=string"
Responses:
| Status | Description | Body |
|---|---|---|
| 303 | Sent to Spanway sign-in or to the connect page | |
| 307 | Sent to the MCP server's own sign-in provider | application/json any |
| 400 | The client id, redirect address, PKCE challenge or scope is invalid, so nothing is redirected | application/json OAuthErrorBody |
| 404 | No MCP server has that name | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
POST /{mcp_server_name}/register
Register an MCP client for one server
Part of the OAuth 2.1 front door that MCP clients walk when they connect to /mcp or to one server at /{mcp_server_name}/mcp. Clients discover these routes from the /.well-known metadata and never call them by hand.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
mcp_server_name | path | string or null | Yes |
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
application_type | string or null | No | Application Type |
client_name | string or null | No | Client Name |
grant_types | array of string | No | Grant Types |
redirect_uris | array of string | Yes | Where the client receives the authorization code |
response_types | array of string | No | Response Types |
token_endpoint_auth_method | string | No | Token Endpoint Auth Method |
Example request:
curl -X POST "http://localhost:4000/mcp_server_name-123/register" \
-H "Content-Type: application/json" \
-d '{
"client_name": "Claude Desktop",
"grant_types": [
"authorization_code",
"refresh_token"
],
"redirect_uris": [
"http://127.0.0.1:52341/callback"
],
"response_types": [
"code"
],
"token_endpoint_auth_method": "none"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The registered client. The gateway stores nothing, the client id seals the redirect URIs | application/json MCPClientRegistrationResponse |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
client_id | string | Yes | Client Id |
client_id_issued_at | integer or null | No | Client Id Issued At |
client_name | string or null | No | Client Name |
client_secret | string or null | No | Client Secret |
grant_types | array of string | No | Grant Types |
redirect_uris | array of string | No | Redirect Uris |
response_types | array of string | No | Response Types |
token_endpoint_auth_method | string or null | No | Token Endpoint Auth Method |
POST /{mcp_server_name}/token
Exchange a code or refresh token for one server
The last step of an MCP client's sign-in: trade the one-time code from the sign-in for an access token and a refresh token, or trade a refresh token for a new access token. The client sends its PKCE code_verifier and the same redirect_uri it signed in with. For one MCP server that signs in with its own provider, the gateway relays the exchange to that provider and keeps the user's token so later tool calls can use it. Anyone may call it, the code or refresh token is the proof. A code works once and expires within minutes. An agent bound to an identity provider application can also send grant_type token-exchange with its own token as subject_token and the name of one of its stored SaaS credentials as audience, and gets that credential back as access_token. Docs (https://docs.spanway.ai/docs/mcp/oauth) and agent credentials (https://docs.spanway.ai/docs/proxy/agent_credentials)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
mcp_server_name | path | string or null | Yes |
Request body (application/x-www-form-urlencoded, schema Body_token_endpoint__mcp_server_name__token_post):
| Field | Type | Required | Description |
|---|---|---|---|
audience | string or null | No | Audience |
client_id | string | Yes | Client Id |
client_secret | string or null | No | Client Secret |
code | string | No | Code |
code_verifier | string | No | Code Verifier |
grant_type | string | Yes | Grant Type |
redirect_uri | string | No | Redirect Uri |
refresh_token | string or null | No | Refresh Token |
requested_token_type | string or null | No | Requested Token Type |
resource | string or null | No | Resource |
scope | string or null | No | Scope |
subject_token | string or null | No | Subject Token |
subject_token_type | string or null | No | Subject Token Type |
Example request:
curl -X POST "http://localhost:4000/mcp_server_name-123/token"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The session tokens for the signed-in user, or for an agent token exchange the agent's stored SaaS credential with token_type N_A and no refresh token | application/json MCPOAuthTokenResponse or AgentCredentialTokenResponse |
| 400 | The code expired, was used already, or the PKCE verifier does not match, or an agent token exchange was refused | application/json OAuthErrorBody |
| 404 | No registered server has that name | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 503 | The gateway could not read the agent's stored credentials, or has no database for them. Retry | application/json OAuthErrorBody |