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.
| Method | Path | Summary |
|---|---|---|
| POST | /mcp-rest/test/connection | Test an MCP server definition before saving it |
| POST | /mcp-rest/test/tools/list | Preview the tools of an unsaved MCP server |
| POST | /mcp-rest/tools/call | Call an MCP tool over REST |
| GET | /mcp-rest/tools/list | List 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):
| Field | Type | Required | Description |
|---|---|---|---|
alias | string or null | No | Alias |
allow_all_keys | boolean | No | Allow All Keys |
allowed_tools | array of string or null | No | Allowed Tools |
approval_status | string or null | No | Server-managed: set by the endpoint; caller values are overridden. |
args | array of string | No | Args |
audience | string or null | No | Audience |
auth_type | enum: "none", "api_key", "bearer_token", "basic", "authorization", "oauth2", "aws_sigv4", "token", ... or null | No | Auth Type |
authorization_url | string or null | No | Authorization Url |
available_on_public_internet | boolean | No | Available On Public Internet |
byok_api_key_help_url | string or null | No | Byok Api Key Help Url |
byok_description | array of string | No | Byok Description |
catalog_entry | string or null | No | Catalog Entry |
command | string or null | No | Command |
credentials | MCPCredentials or null | No | |
dcr_bridge | boolean or null | No | Dcr Bridge |
delegate_auth_to_upstream | boolean | No | Delegate Auth To Upstream |
description | string or null | No | Description |
env | object | No | Env |
env_vars | array of MCPEnvVar or null | No | Env Vars |
extra_headers | array of string or null | No | Extra Headers |
instructions | string or null | No | Instructions |
is_byok | boolean | No | Is Byok |
issuer | string or null | No | Issuer |
max_concurrent_requests | integer or null | No | Max Concurrent Requests |
mcp_access_groups | array of string | No | Mcp Access Groups |
mcp_info | object or null | No | Mcp Info |
oauth2_flow | enum: "client_credentials", "authorization_code" or null | No | Oauth2 Flow |
oauth_passthrough | boolean | No | Oauth Passthrough |
per_server_oauth_discovery | boolean | No | Per Server Oauth Discovery |
registration_url | string or null | No | Registration Url |
rpm | integer or null | No | Rpm |
server_id | string or null | No | Server Id |
server_name | string or null | No | Server Name |
source_url | string or null | No | Source Url |
spec_path | string or null | No | Spec Path |
static_headers | object or null | No | Static Headers |
subject_token_type | string or null | No | Subject Token Type |
submitted_at | string or null | No | Server-managed: set by the endpoint; caller values are overridden. |
submitted_by | string or null | No | Server-managed: set by the endpoint; caller values are overridden. |
timeout | number or null | No | Timeout |
token_exchange_endpoint | string or null | No | Token Exchange Endpoint |
token_exchange_profile | string or null | No | Token Exchange Profile |
token_url | string or null | No | Token Url |
tool_name_to_description | object or null | No | Tool Name To Description |
tool_name_to_display_name | object or null | No | Tool Name To Display Name |
transport | enum: "sse", "http", "stdio" | No | Transport |
url | string or null | No | Url |
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:
| Status | Description | Body |
|---|---|---|
| 200 | The gateway opened an MCP session with the server | application/json MCPConnectionTestResponse |
| 403 | Only proxy admins may test server definitions | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
status | "ok" | Yes | Status |
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):
| Field | Type | Required | Description |
|---|---|---|---|
alias | string or null | No | Alias |
allow_all_keys | boolean | No | Allow All Keys |
allowed_tools | array of string or null | No | Allowed Tools |
approval_status | string or null | No | Server-managed: set by the endpoint; caller values are overridden. |
args | array of string | No | Args |
audience | string or null | No | Audience |
auth_type | enum: "none", "api_key", "bearer_token", "basic", "authorization", "oauth2", "aws_sigv4", "token", ... or null | No | Auth Type |
authorization_url | string or null | No | Authorization Url |
available_on_public_internet | boolean | No | Available On Public Internet |
byok_api_key_help_url | string or null | No | Byok Api Key Help Url |
byok_description | array of string | No | Byok Description |
catalog_entry | string or null | No | Catalog Entry |
command | string or null | No | Command |
credentials | MCPCredentials or null | No | |
dcr_bridge | boolean or null | No | Dcr Bridge |
delegate_auth_to_upstream | boolean | No | Delegate Auth To Upstream |
description | string or null | No | Description |
env | object | No | Env |
env_vars | array of MCPEnvVar or null | No | Env Vars |
extra_headers | array of string or null | No | Extra Headers |
instructions | string or null | No | Instructions |
is_byok | boolean | No | Is Byok |
issuer | string or null | No | Issuer |
max_concurrent_requests | integer or null | No | Max Concurrent Requests |
mcp_access_groups | array of string | No | Mcp Access Groups |
mcp_info | object or null | No | Mcp Info |
oauth2_flow | enum: "client_credentials", "authorization_code" or null | No | Oauth2 Flow |
oauth_passthrough | boolean | No | Oauth Passthrough |
per_server_oauth_discovery | boolean | No | Per Server Oauth Discovery |
registration_url | string or null | No | Registration Url |
rpm | integer or null | No | Rpm |
server_id | string or null | No | Server Id |
server_name | string or null | No | Server Name |
source_url | string or null | No | Source Url |
spec_path | string or null | No | Spec Path |
static_headers | object or null | No | Static Headers |
subject_token_type | string or null | No | Subject Token Type |
submitted_at | string or null | No | Server-managed: set by the endpoint; caller values are overridden. |
submitted_by | string or null | No | Server-managed: set by the endpoint; caller values are overridden. |
timeout | number or null | No | Timeout |
token_exchange_endpoint | string or null | No | Token Exchange Endpoint |
token_exchange_profile | string or null | No | Token Exchange Profile |
token_url | string or null | No | Token Url |
tool_name_to_description | object or null | No | Tool Name To Description |
tool_name_to_display_name | object or null | No | Tool Name To Display Name |
transport | enum: "sse", "http", "stdio" | No | Transport |
url | string or null | No | Url |
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:
| Status | Description | Body |
|---|---|---|
| 200 | The tools the server advertises, before any allow list is applied | application/json MCPToolPreviewResponse |
| 403 | Only proxy admins may test server definitions | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
error | boolean or null | No | Error |
message | string | Yes | Message |
status | string or null | No | Status |
tools | array of object | No | Tools |
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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
x-spanway-approval-id | header | string | No | The 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):
| Field | Type | Required | Description |
|---|---|---|---|
arguments | object | No | Arguments matching the tool's input schema |
name | string | Yes | Tool name as GET /mcp-rest/tools/list returns it |
server_id | string | Yes | Server 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:
| Status | Description | Body |
|---|---|---|
| 200 | The tool result as the MCP server returned it, after the post-call guardrails | application/json MCPRestToolCallResponse |
| 400 | A required field is missing, or a guardrail refused the arguments | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The 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 call | application/json ErrorDetail |
| 404 | No registered server matches server_id | application/json ErrorDetail |
| 412 | The server declares per-user environment variables the user has not filled in | application/json ErrorDetail |
| 500 | The gateway failed while calling the tool. The cause is in the gateway log, never in the answer | application/json ErrorDetail |
| 503 | The 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 answer | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
content | array of MCPRestContentBlock | No | Content |
isError | boolean | No | Iserror |
structuredContent | object or null | No | Structuredcontent |
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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
server_id | query | string or null | No | The server id to list tools for |
mcp_server_name | query | string or null | No | Filter tools to a single MCP server by name or alias |
toolset_name | query | string or null | No | Filter tools to a single toolset by name |
include_disabled_tools | query | boolean | No | Admin 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:
| Status | Description | Body |
|---|---|---|
| 200 | The 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 which | application/json MCPRestToolListResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The client application is not allowed, the key may not use the server, or the upstream refused the listing | application/json ErrorDetail |
| 404 | No registered server matches server_id | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 429 | The upstream server rate limited the listing | application/json ErrorDetail |
| 500 | The gateway failed while listing the tools | application/json ErrorDetail |
| 502 | The upstream server could not be reached or answered with an error | application/json ErrorDetail |
| 504 | The upstream server did not answer in time | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
error | string or null | No | Error |
message | string | Yes | Message |
tools | array of MCPRestTool | No | Tools |