Skip to main content

Mcp rest API

This page documents the 4 gateway endpoints tagged mcp_rest 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
POST/mcp-rest/test/connectionTest an MCP server definition before saving it
POST/mcp-rest/test/tools/listPreview the tools of an unsaved MCP server
POST/mcp-rest/tools/callCall an MCP tool over REST
GET/mcp-rest/tools/listList the MCP tools a key may call over REST

Endpoints​

POST /mcp-rest/test/connection​

Test an MCP server definition before saving it

Opens an MCP session with the server described in the body and closes it again, without storing anything. The Admin UI calls this from the Test Connection button of the server form. Proxy admins only.

Request body (application/json, schema NewMCPServerRequest):

FieldTypeRequiredDescription
aliasstring or nullNoAlias
allow_all_keysbooleanNoAllow All Keys
allowed_toolsarray of string or nullNoAllowed Tools
approval_statusstring or nullNoServer-managed: set by the endpoint; caller values are overridden.
argsarray of stringNoArgs
audiencestring or nullNoAudience
auth_typeenum: "none", "api_key", "bearer_token", "basic", "authorization", "oauth2", "aws_sigv4", "token", ... or nullNoAuth Type
authorization_urlstring or nullNoAuthorization Url
available_on_public_internetbooleanNoAvailable On Public Internet
byok_api_key_help_urlstring or nullNoByok Api Key Help Url
byok_descriptionarray of stringNoByok Description
catalog_entrystring or nullNoCatalog Entry
commandstring or nullNoCommand
credentialsMCPCredentials or nullNo
dcr_bridgeboolean or nullNoDcr Bridge
delegate_auth_to_upstreambooleanNoDelegate Auth To Upstream
descriptionstring or nullNoDescription
envobjectNoEnv
env_varsarray of MCPEnvVar or nullNoEnv Vars
extra_headersarray of string or nullNoExtra Headers
instructionsstring or nullNoInstructions
is_byokbooleanNoIs Byok
issuerstring or nullNoIssuer
max_concurrent_requestsinteger or nullNoMax Concurrent Requests
mcp_access_groupsarray of stringNoMcp Access Groups
mcp_infoobject or nullNoMcp Info
oauth2_flowenum: "client_credentials", "authorization_code" or nullNoOauth2 Flow
oauth_passthroughbooleanNoOauth Passthrough
per_server_oauth_discoverybooleanNoPer Server Oauth Discovery
registration_urlstring or nullNoRegistration Url
rpminteger or nullNoRpm
server_idstring or nullNoServer Id
server_namestring or nullNoServer Name
source_urlstring or nullNoSource Url
spec_pathstring or nullNoSpec Path
static_headersobject or nullNoStatic Headers
subject_token_typestring or nullNoSubject Token Type
submitted_atstring or nullNoServer-managed: set by the endpoint; caller values are overridden.
submitted_bystring or nullNoServer-managed: set by the endpoint; caller values are overridden.
timeoutnumber or nullNoTimeout
token_exchange_endpointstring or nullNoToken Exchange Endpoint
token_exchange_profilestring or nullNoToken Exchange Profile
token_urlstring or nullNoToken Url
tool_name_to_descriptionobject or nullNoTool Name To Description
tool_name_to_display_nameobject or nullNoTool Name To Display Name
transportenum: "sse", "http", "stdio"NoTransport
urlstring or nullNoUrl

Example request:

curl -X POST "http://localhost:4000/mcp-rest/test/connection" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"auth_type": "bearer_token",
"credentials": {
"auth_value": "os.environ/JIRA_MCP_TOKEN"
},
"server_name": "jira",
"transport": "http",
"url": "https://mcp.atlassian.com/v1/mcp"
}'

Responses:

StatusDescriptionBody
200The gateway opened an MCP session with the serverapplication/json MCPConnectionTestResponse
403Only proxy admins may test server definitionsapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
status"ok"YesStatus

POST /mcp-rest/test/tools/list​

Preview the tools of an unsaved MCP server

Lists the tools the server described in the body advertises, so an admin can pick allowed_tools before saving it. OpenAPI backed servers are read from their spec_path. Proxy admins only.

Request body (application/json, schema NewMCPServerRequest):

FieldTypeRequiredDescription
aliasstring or nullNoAlias
allow_all_keysbooleanNoAllow All Keys
allowed_toolsarray of string or nullNoAllowed Tools
approval_statusstring or nullNoServer-managed: set by the endpoint; caller values are overridden.
argsarray of stringNoArgs
audiencestring or nullNoAudience
auth_typeenum: "none", "api_key", "bearer_token", "basic", "authorization", "oauth2", "aws_sigv4", "token", ... or nullNoAuth Type
authorization_urlstring or nullNoAuthorization Url
available_on_public_internetbooleanNoAvailable On Public Internet
byok_api_key_help_urlstring or nullNoByok Api Key Help Url
byok_descriptionarray of stringNoByok Description
catalog_entrystring or nullNoCatalog Entry
commandstring or nullNoCommand
credentialsMCPCredentials or nullNo
dcr_bridgeboolean or nullNoDcr Bridge
delegate_auth_to_upstreambooleanNoDelegate Auth To Upstream
descriptionstring or nullNoDescription
envobjectNoEnv
env_varsarray of MCPEnvVar or nullNoEnv Vars
extra_headersarray of string or nullNoExtra Headers
instructionsstring or nullNoInstructions
is_byokbooleanNoIs Byok
issuerstring or nullNoIssuer
max_concurrent_requestsinteger or nullNoMax Concurrent Requests
mcp_access_groupsarray of stringNoMcp Access Groups
mcp_infoobject or nullNoMcp Info
oauth2_flowenum: "client_credentials", "authorization_code" or nullNoOauth2 Flow
oauth_passthroughbooleanNoOauth Passthrough
per_server_oauth_discoverybooleanNoPer Server Oauth Discovery
registration_urlstring or nullNoRegistration Url
rpminteger or nullNoRpm
server_idstring or nullNoServer Id
server_namestring or nullNoServer Name
source_urlstring or nullNoSource Url
spec_pathstring or nullNoSpec Path
static_headersobject or nullNoStatic Headers
subject_token_typestring or nullNoSubject Token Type
submitted_atstring or nullNoServer-managed: set by the endpoint; caller values are overridden.
submitted_bystring or nullNoServer-managed: set by the endpoint; caller values are overridden.
timeoutnumber or nullNoTimeout
token_exchange_endpointstring or nullNoToken Exchange Endpoint
token_exchange_profilestring or nullNoToken Exchange Profile
token_urlstring or nullNoToken Url
tool_name_to_descriptionobject or nullNoTool Name To Description
tool_name_to_display_nameobject or nullNoTool Name To Display Name
transportenum: "sse", "http", "stdio"NoTransport
urlstring or nullNoUrl

Example request:

curl -X POST "http://localhost:4000/mcp-rest/test/tools/list" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"auth_type": "bearer_token",
"credentials": {
"auth_value": "os.environ/JIRA_MCP_TOKEN"
},
"server_name": "jira",
"transport": "http",
"url": "https://mcp.atlassian.com/v1/mcp"
}'

Responses:

StatusDescriptionBody
200The tools the server advertises, before any allow list is appliedapplication/json MCPToolPreviewResponse
403Only proxy admins may test server definitionsapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
errorboolean or nullNoError
messagestringYesMessage
statusstring or nullNoStatus
toolsarray of objectNoTools

POST /mcp-rest/tools/call​

Call an MCP tool over REST

Runs one tool on a registered MCP server for a caller that is not an MCP client. The call is authorised against the key and team, screened by the guardrails attached to them, costed and written to the spend logs like a model call. server_id accepts the server id, name or alias.

Parameters:

NameInTypeRequiredDescription
x-spanway-approval-idheaderstringNoThe approval_id of an approved request, sent when retrying a call that answered 403 approval_required. It covers only the same key, tool and arguments, once.

Request body (application/json, object):

FieldTypeRequiredDescription
argumentsobjectNoArguments matching the tool's input schema
namestringYesTool name as GET /mcp-rest/tools/list returns it
server_idstringYesServer id, name or alias that serves the tool

Example request:

curl -X POST "http://localhost:4000/mcp-rest/tools/call" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"arguments": {
"jql": "assignee = currentUser()"
},
"name": "jira-search_issues",
"server_id": "jira"
}'

Responses:

StatusDescriptionBody
200The tool result as the MCP server returned it, after the post-call guardrailsapplication/json MCPRestToolCallResponse
400A required field is missing, or a guardrail refused the argumentsapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key may not call this tool, the client application is not allowed, a human approval is needed, or the write action alignment guardrail stopped the callapplication/json ErrorDetail
404No registered server matches server_idapplication/json ErrorDetail
412The server declares per-user environment variables the user has not filled inapplication/json ErrorDetail
500The gateway failed while calling the tool. The cause is in the gateway log, never in the answerapplication/json ErrorDetail
503The approval store could not be read, a guardrail flagged the call while no approvals database is set up, or the write action alignment judge gave no clear answerapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
contentarray of MCPRestContentBlockNoContent
isErrorbooleanNoIserror
structuredContentobject or nullNoStructuredcontent

GET /mcp-rest/tools/list​

List the MCP tools a key may call over REST

Lists every tool the calling key may use across its MCP servers, or on one server or toolset when mcp_server_name or toolset_name is given. The same permission layers apply as on /mcp, so a key sees only the tools its grants, the server allow lists and the connector read-only defaults leave.

Parameters:

NameInTypeRequiredDescription
server_idquerystring or nullNoThe server id to list tools for
mcp_server_namequerystring or nullNoFilter tools to a single MCP server by name or alias
toolset_namequerystring or nullNoFilter tools to a single toolset by name
include_disabled_toolsquerybooleanNoAdmin only. Return the full server tool catalog without the allowed_tools filter or per-key tool permissions, so the MCP settings UI can configure the allowlist. Ignored for non-admins.

Example request:

curl -X GET "http://localhost:4000/mcp-rest/tools/list" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The tools the calling key may use, namespaced as {server}-{tool}. With several servers, error is partial_failure when one of them could not be listed and server_outcomes says whichapplication/json MCPRestToolListResponse
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The client application is not allowed, the key may not use the server, or the upstream refused the listingapplication/json ErrorDetail
404No registered server matches server_idapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
429The upstream server rate limited the listingapplication/json ErrorDetail
500The gateway failed while listing the toolsapplication/json ErrorDetail
502The upstream server could not be reached or answered with an errorapplication/json ErrorDetail
504The upstream server did not answer in timeapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
errorstring or nullNoError
messagestringYesMessage
toolsarray of MCPRestToolNoTools