Mcp byok oauth API
This page documents the 9 gateway endpoints tagged mcp_byok_oauth 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/oauth-authorization-server | Read the gateway's OAuth sign-in addresses |
| GET | /.well-known/oauth-authorization-server/mcp | Read the sign-in addresses of the shared MCP endpoint |
| GET | /.well-known/oauth-authorization-server/mcp/{mcp_server_name} | Read the sign-in addresses of one MCP server |
| GET | /.well-known/oauth-authorization-server/{mcp_server_name} | Read the sign-in addresses of one MCP server, short address |
| GET | /.well-known/oauth-authorization-server/{mcp_server_name}/mcp | Read the sign-in addresses of one MCP server, older address |
| GET | /.well-known/oauth-protected-resource | Find where to sign in for the gateway |
| GET | /.well-known/oauth-protected-resource/mcp | Find where to sign in for the shared MCP endpoint |
| GET | /.well-known/oauth-protected-resource/mcp/{mcp_server_name} | Find where to sign in for one MCP server |
| GET | /.well-known/oauth-protected-resource/{mcp_server_name}/mcp | Find where to sign in for one MCP server, older address |
Endpoints
GET /.well-known/oauth-authorization-server
Read the gateway's OAuth sign-in addresses
List the sign-in, token and registration addresses of the gateway. When exactly one MCP server signs in through OAuth, its addresses are shown. 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.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
mcp_server_name | query | string or null | No |
Example request:
curl -X GET "http://localhost:4000/.well-known/oauth-authorization-server"
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 |
| 422 | Validation Error | application/json HTTPValidationError |
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/oauth-authorization-server/mcp
Read the sign-in addresses of the shared MCP endpoint
List the sign-in, token, registration and token check addresses the gateway offers to MCP clients of the shared /mcp endpoint. Clients register themselves without a secret and must use PKCE. 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/oauth-authorization-server/mcp"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The gateway's own sign-in addresses for the shared /mcp endpoint | application/json AuthorizationServerMetadata |
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/oauth-authorization-server/mcp/{mcp_server_name}
Read the sign-in addresses of one MCP server
List the sign-in, token and registration addresses an MCP client uses for /mcp/{mcp_server_name}, with the scopes the server's provider offers. A name that is unknown, hidden or not an OAuth server answers 404. 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.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
mcp_server_name | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/.well-known/oauth-authorization-server/mcp/mcp_server_name-123"
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 |
| 422 | Validation Error | application/json HTTPValidationError |
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/oauth-authorization-server/{mcp_server_name}
Read the sign-in addresses of one MCP server, short address
The same document as /.well-known/oauth-authorization-server/mcp/{mcp_server_name}, for clients that insert the well-known segment before the server name. 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.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
mcp_server_name | path | string or null | Yes |
Example request:
curl -X GET "http://localhost:4000/.well-known/oauth-authorization-server/mcp_server_name-123"
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 |
| 422 | Validation Error | application/json HTTPValidationError |
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/oauth-authorization-server/{mcp_server_name}/mcp
Read the sign-in addresses of one MCP server, older address
The same document as /.well-known/oauth-authorization-server/mcp/{mcp_server_name}, for clients set up with the older /{mcp_server_name}/mcp address. 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.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
mcp_server_name | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/.well-known/oauth-authorization-server/mcp_server_name-123/mcp"
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 |
| 422 | Validation Error | application/json HTTPValidationError |
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/oauth-protected-resource
Find where to sign in for the gateway
Tell an OAuth client which authorization server signs it in for the gateway itself. 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/oauth-protected-resource"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Where the client signs in | application/json ProtectedResourceMetadata |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
authorization_servers | array of string | Yes | Where the client signs in for that resource |
resource | string | Yes | The URL the client presents its token to |
scopes_supported | array of string | Yes | The scopes the client may ask for, often empty |
GET /.well-known/oauth-protected-resource/mcp
Find where to sign in for the shared MCP endpoint
Tell an MCP client connecting to the shared /mcp endpoint that the gateway itself signs it in. Which servers the person may use is decided after sign-in, so no server names appear here. 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/oauth-protected-resource/mcp"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Where the client signs in for /mcp | application/json ProtectedResourceMetadata |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
authorization_servers | array of string | Yes | Where the client signs in for that resource |
resource | string | Yes | The URL the client presents its token to |
scopes_supported | array of string | Yes | The scopes the client may ask for, often empty |
GET /.well-known/oauth-protected-resource/mcp/{mcp_server_name}
Find where to sign in for one MCP server
Tell an MCP client connecting to /mcp/{mcp_server_name} where to sign in. A server whose own provider checks the token gets that provider's details, any other OAuth server gets the gateway's sign-in. A name that is unknown, hidden from the caller or not an OAuth server answers 404. 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.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
mcp_server_name | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/.well-known/oauth-protected-resource/mcp/mcp_server_name-123"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Where the client signs in for this MCP address | application/json ProtectedResourceMetadata |
| 404 | No OAuth MCP server has that name | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
authorization_servers | array of string | Yes | Where the client signs in for that resource |
resource | string | Yes | The URL the client presents its token to |
scopes_supported | array of string | Yes | The scopes the client may ask for, often empty |
GET /.well-known/oauth-protected-resource/{mcp_server_name}/mcp
Find where to sign in for one MCP server, older address
The same answer as /.well-known/oauth-protected-resource/mcp/{mcp_server_name}, for clients set up with the older /{mcp_server_name}/mcp address. New setups should use /mcp/{mcp_server_name}. 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.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
mcp_server_name | path | string or null | Yes |
Example request:
curl -X GET "http://localhost:4000/.well-known/oauth-protected-resource/mcp_server_name-123/mcp"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Where the client signs in for this MCP address | application/json ProtectedResourceMetadata |
| 404 | No OAuth MCP server has that name | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
authorization_servers | array of string | Yes | Where the client signs in for that resource |
resource | string | Yes | The URL the client presents its token to |
scopes_supported | array of string | Yes | The scopes the client may ask for, often empty |