Skip to main content

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.

MethodPathSummary
GET/.well-known/jwks.jsonRead the keys that verify gateway-signed MCP tokens
GET/.well-known/openid-configurationRead the gateway's OpenID discovery document
GET/.well-known/spanway-cli-authRead how a command line client signs in
GET/authorizeStart an OAuth sign-in
POST/authorize/completeApprove or deny a client on the connect page
GET/authorize/flowDescribe a sign-in waiting on the connect page
GET/authorize/mcp-sessionStart signing in to the shared MCP endpoint
GET/callbackReceive the answer of an MCP server's sign-in provider
POST/introspectCheck whether a gateway session token is valid
POST/registerRegister an MCP client
POST/revokeSign a command line client out
POST/tokenExchange a code or refresh token
GET/{mcp_server_name}/authorizeStart signing in to one MCP server
POST/{mcp_server_name}/registerRegister an MCP client for one server
POST/{mcp_server_name}/tokenExchange 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:

StatusDescriptionBody
200The public signing keysapplication/json JsonWebKeySet

Response fields (200):

FieldTypeRequiredDescription
keysarray of JsonWebKeyYesThe 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:

StatusDescriptionBody
200The sign-in addresses for this MCP serverapplication/json AuthorizationServerMetadata
404No OAuth MCP server has that nameapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
authorization_endpointstringYesWhere the browser goes to sign in
code_challenge_methods_supportedarray of stringYesAlways S256, PKCE is required
grant_types_supportedarray of stringYesThe grants the token endpoint accepts
id_token_signing_alg_values_supportedarray of string or nullNoSignature algorithms, present when MCP token signing is on
introspection_endpointstring or nullNoToken check address, aggregate only
issuerstringYesThe authorization server's identifier, checked by strict clients
jwks_uristring or nullNoSigning keys, present when MCP token signing is on
registration_endpointstringYesWhere the client registers itself before signing in
response_types_supportedarray of stringYesAlways code
scopes_supportedarray of stringYesThe scopes the client may ask for
token_endpointstringYesWhere the client trades the code for tokens
token_endpoint_auth_methods_supportedarray of stringYesHow 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:

StatusDescriptionBody
200The sign-in contractapplication/json NativeClientAuthDiscovery

Response fields (200):

FieldTypeRequiredDescription
authorization_endpointstringYesWhere the browser signs in
code_challenge_methods_supportedarray of stringYesAlways S256
contract_versionintegerYesRaised only when a field changes meaning or goes away
grant_types_supportedarray of stringYesThe grants the token endpoint accepts
issuerstringYesThe gateway's base URL
registration_endpointstringYesWhere the client registers itself
resourcestringYesThe exact resource value to send so the grant is for the gateway API
response_types_supportedarray of stringYesAlways code
revocation_endpointstringYesWhere the client signs out
revocation_endpoint_auth_methods_supportedarray of stringYesAlways none
token_endpointstringYesWhere the client trades the code for a key
token_endpoint_auth_methods_supportedarray of stringYesAlways 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:

NameInTypeRequiredDescription
redirect_uriquerystringYes
client_idquerystring or nullNo
statequerystringNo
mcp_server_namequerystring or nullNo
code_challengequerystring or nullNo
code_challenge_methodquerystring or nullNo
response_typequerystring or nullNo
scopequerystring or nullNo
resourcequerystring or nullNo

Example request:

curl -X GET "http://localhost:4000/authorize?redirect_uri=string"

Responses:

StatusDescriptionBody
303Sent to Spanway sign-in or to the connect page
307Sent to the MCP server's own sign-in providerapplication/json any
400The client id, redirect address, PKCE challenge or scope is invalid, so nothing is redirectedapplication/json OAuthErrorBody
404No MCP server has that nameapplication/json ErrorDetail
422Validation Errorapplication/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):

FieldTypeRequiredDescription
decisionstring or nullNoDecision
deliverystring or nullNoDelivery
flowstringYesFlow
team_idstring or nullNoTeam Id

Example request:

curl -X POST "http://localhost:4000/authorize/complete"

Responses:

StatusDescriptionBody
200The page with the return address to copy, for delivery=manualtext/html string
303Sent back to the client with the code, or with error=access_denied
400The sign-in is unknown, expired, already finished, or its MCP server still needs approvalapplication/json OAuthErrorBody
401Nobody is signed in to Spanwayapplication/json OAuthErrorBody
403Another user started this sign-inapplication/json OAuthErrorBody
422Validation Errorapplication/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:

NameInTypeRequiredDescription
flowquerystringYes

Example request:

curl -X GET "http://localhost:4000/authorize/flow?flow=string"

Responses:

StatusDescriptionBody
200The sign-in the connect page showsapplication/json ConnectFlowView
400The sign-in is unknown or expiredapplication/json OAuthErrorBody
401Nobody is signed in to Spanwayapplication/json OAuthErrorBody
403Another user started this sign-inapplication/json OAuthErrorBody
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
client_originstringYesThe scheme and host of the client being connected
connectedboolean or nullYesWhether that server's own sign-in is already done
requested_scopesarray of string or nullNoExtra scopes asked for
server_idstring or nullYesThe one MCP server this sign-in is for, if any
server_namestring or nullYesThat server's display name
stateenum: "unscoped", "interactive", "m2m", "stale"Yesinteractive 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:

NameInTypeRequiredDescription
redirect_uriquerystringYes
client_idquerystringYes
statequerystringNo
code_challengequerystring or nullNo
code_challenge_methodquerystring or nullNo
response_typequerystring or nullNo
resourcequerystring or nullNo
scopequerystring or nullNo

Example request:

curl -X GET "http://localhost:4000/authorize/mcp-session?redirect_uri=string&client_id=client_id-123"

Responses:

StatusDescriptionBody
303Sent to Spanway sign-in, or to the connect page once signed inapplication/json any
400The client id, redirect address, PKCE challenge or scope is invalid, so nothing is redirectedapplication/json OAuthErrorBody
422Validation Errorapplication/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:

NameInTypeRequiredDescription
codequerystring or nullNo
statequerystring or nullNo
issquerystring or nullNo
errorquerystring or nullNo
error_descriptionquerystring or nullNo
error_uriquerystring or nullNo

Example request:

curl -X GET "http://localhost:4000/callback"

Responses:

StatusDescriptionBody
302Sent back to the MCP client with the code or the provider's errorapplication/json any
400An error page, because the answer could not be matched to a trusted clienttext/html string
422Validation Errorapplication/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):

FieldTypeRequiredDescription
tokenstringYesToken

Example request:

curl -X POST "http://localhost:4000/introspect" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Whether the token is live and who it belongs toapplication/json TokenIntrospection
401No valid key or Admin UI session was presentedapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500The gateway has no master key to check tokens withapplication/json OAuthErrorBody

Response fields (200):

FieldTypeRequiredDescription
activebooleanYesTrue only for a live token the gateway issued
audiencestring or nullNoWho the token is meant for
client_idstring or nullNoThe client the token was issued to
expinteger or nullNoExpires at, Unix seconds
iatinteger or nullNoIssued at, Unix seconds
issstring or nullNoWho issued the token
jtistring or nullNoThe token's unique id
kindstring or nullNosession or session_refresh
resource_server_idstring or nullNoThe one MCP server the token is scoped to
substring or nullNoThe user the token belongs to
team_idstring or nullNoThe team the credential is billed to
token_typestring or nullNoBearer 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:

NameInTypeRequiredDescription
mcp_server_namequerystring or nullNo

Request body (application/json, object):

FieldTypeRequiredDescription
application_typestring or nullNoApplication Type
client_namestring or nullNoClient Name
grant_typesarray of stringNoGrant Types
redirect_urisarray of stringYesWhere the client receives the authorization code
response_typesarray of stringNoResponse Types
token_endpoint_auth_methodstringNoToken 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:

StatusDescriptionBody
200The registered client. The gateway stores nothing, the client id seals the redirect URIsapplication/json MCPClientRegistrationResponse
201The registered client. The gateway stores nothing, the sealed client id carries the redirect URIsapplication/json MCPClientRegistrationResponse
400A redirect URI is not allowed, or the registration metadata is too largeapplication/json OAuthErrorBody
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
client_idstringYesClient Id
client_id_issued_atinteger or nullNoClient Id Issued At
client_namestring or nullNoClient Name
client_secretstring or nullNoClient Secret
grant_typesarray of stringNoGrant Types
redirect_urisarray of stringNoRedirect Uris
response_typesarray of stringNoResponse Types
token_endpoint_auth_methodstring or nullNoToken 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):

FieldTypeRequiredDescription
client_idstringYesClient Id
tokenstringYesToken

Example request:

curl -X POST "http://localhost:4000/revoke"

Responses:

StatusDescriptionBody
200The token can no longer be usedapplication/json object
401The client id is unknown or malformedapplication/json OAuthErrorBody
422Validation Errorapplication/json HTTPValidationError
503The shared record that blocks reuse could not be written, try againapplication/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:

NameInTypeRequiredDescription
mcp_server_namequerystring or nullNo

Request body (application/x-www-form-urlencoded, schema Body_token_endpoint_token_post):

FieldTypeRequiredDescription
audiencestring or nullNoAudience
client_idstringYesClient Id
client_secretstring or nullNoClient Secret
codestringNoCode
code_verifierstringNoCode Verifier
grant_typestringYesGrant Type
redirect_uristringNoRedirect Uri
refresh_tokenstring or nullNoRefresh Token
requested_token_typestring or nullNoRequested Token Type
resourcestring or nullNoResource
scopestring or nullNoScope
subject_tokenstring or nullNoSubject Token
subject_token_typestring or nullNoSubject Token Type

Example request:

curl -X POST "http://localhost:4000/token"

Responses:

StatusDescriptionBody
200The 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 tokenapplication/json MCPOAuthTokenResponse or AgentCredentialTokenResponse
400The code expired, was used already, or the PKCE verifier does not match, or an agent token exchange was refusedapplication/json OAuthErrorBody
404No registered server has that nameapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
503The gateway could not read the agent's stored credentials, or has no database for them. Retryapplication/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:

NameInTypeRequiredDescription
mcp_server_namepathstring or nullYes
redirect_uriquerystringYes
client_idquerystring or nullNo
statequerystringNo
code_challengequerystring or nullNo
code_challenge_methodquerystring or nullNo
response_typequerystring or nullNo
scopequerystring or nullNo
resourcequerystring or nullNo

Example request:

curl -X GET "http://localhost:4000/mcp_server_name-123/authorize?redirect_uri=string"

Responses:

StatusDescriptionBody
303Sent to Spanway sign-in or to the connect page
307Sent to the MCP server's own sign-in providerapplication/json any
400The client id, redirect address, PKCE challenge or scope is invalid, so nothing is redirectedapplication/json OAuthErrorBody
404No MCP server has that nameapplication/json ErrorDetail
422Validation Errorapplication/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:

NameInTypeRequiredDescription
mcp_server_namepathstring or nullYes

Request body (application/json, object):

FieldTypeRequiredDescription
application_typestring or nullNoApplication Type
client_namestring or nullNoClient Name
grant_typesarray of stringNoGrant Types
redirect_urisarray of stringYesWhere the client receives the authorization code
response_typesarray of stringNoResponse Types
token_endpoint_auth_methodstringNoToken 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:

StatusDescriptionBody
200The registered client. The gateway stores nothing, the client id seals the redirect URIsapplication/json MCPClientRegistrationResponse
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
client_idstringYesClient Id
client_id_issued_atinteger or nullNoClient Id Issued At
client_namestring or nullNoClient Name
client_secretstring or nullNoClient Secret
grant_typesarray of stringNoGrant Types
redirect_urisarray of stringNoRedirect Uris
response_typesarray of stringNoResponse Types
token_endpoint_auth_methodstring or nullNoToken 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:

NameInTypeRequiredDescription
mcp_server_namepathstring or nullYes

Request body (application/x-www-form-urlencoded, schema Body_token_endpoint__mcp_server_name__token_post):

FieldTypeRequiredDescription
audiencestring or nullNoAudience
client_idstringYesClient Id
client_secretstring or nullNoClient Secret
codestringNoCode
code_verifierstringNoCode Verifier
grant_typestringYesGrant Type
redirect_uristringNoRedirect Uri
refresh_tokenstring or nullNoRefresh Token
requested_token_typestring or nullNoRequested Token Type
resourcestring or nullNoResource
scopestring or nullNoScope
subject_tokenstring or nullNoSubject Token
subject_token_typestring or nullNoSubject Token Type

Example request:

curl -X POST "http://localhost:4000/mcp_server_name-123/token"

Responses:

StatusDescriptionBody
200The 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 tokenapplication/json MCPOAuthTokenResponse or AgentCredentialTokenResponse
400The code expired, was used already, or the PKCE verifier does not match, or an agent token exchange was refusedapplication/json OAuthErrorBody
404No registered server has that nameapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
503The gateway could not read the agent's stored credentials, or has no database for them. Retryapplication/json OAuthErrorBody