Skip to main content

MCP tools over REST

Most MCP tools are called by an MCP client or by a model inside a chat request. Sometimes you want to call one from something simpler, such as a cron job, a workflow step, a test script or a service that already speaks HTTP. The REST tool bridge serves the same tools at /mcp-rest/tools/list and /mcp-rest/tools/call. Every call uses a virtual key, follows the key's and team's server and tool grants, runs the guardrails attached to them, is costed and lands in the spend logs, exactly like a tool call made through /mcp.

The same prefix also carries two admin-only routes the Admin UI uses when you add a server, POST /mcp-rest/test/connection and POST /mcp-rest/test/tools/list, which try a server definition before it is saved.

A real-world scenario​

An operations team runs a nightly script that collects the Jira issues assigned to the on-call engineer and posts a summary to a channel. The script has no MCP client library, only curl. The team registers the Jira MCP server on the gateway once, gives the script's key access to the search_issues tool only, and the script calls /mcp-rest/tools/call each night. The Jira credential never leaves the gateway, and every call shows up in the logs against the script's key.

Call a tool from a script​

  1. In the Admin UI, open MCP Servers, click the server card and open the MCP Tools tab. The Available Tools list shows the exact tool names. Pick one and use the Tool Testing Playground on the right to try it with sample arguments, so you know the input schema before scripting it.

  2. Make sure the key you will use may reach the server. Open Virtual Keys, edit the key and check the MCP server picker lists the server, or grant it through the API as shown in access control.

  3. List the tools the key can see. Tool names come back namespaced as {server_name}-{tool_name}:

    curl "http://localhost:4000/mcp-rest/tools/list?mcp_server_name=jira" \
    -H "Authorization: Bearer $SPANWAY_API_KEY"

    Expected result:

    {
    "tools": [
    {
    "name": "jira-search_issues",
    "description": "Search Jira issues with JQL",
    "inputSchema": {"type": "object", "properties": {"jql": {"type": "string"}}, "required": ["jql"]},
    "mcp_info": {"server_name": "jira", "server_id": "8f1c2d3e-4b5a-4c6d-9e7f-0a1b2c3d4e5f", "alias": "jira"}
    }
    ],
    "error": null,
    "message": "Successfully retrieved tools"
    }
  4. Call the tool. server_id accepts the server id, name or alias, name is the tool name from the list and arguments follows the tool's input schema:

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

    Expected result, in the MCP tool result shape:

    {"content": [{"type": "text", "text": "PROJ-1 Login page returns 500"}], "isError": false}
  5. Open Logs in the Admin UI. The call appears with the model column reading MCP: jira-search_issues, the key alias and the cost from the server's cost settings.

Query parameters on the list route:

ParameterMeaning
mcp_server_nameOnly the tools of one server, by name or alias. server_id does the same by id.
toolset_nameOnly the tools of one toolset.
include_disabled_toolsAdmins only. Returns the whole upstream catalogue without the allow list and per-key tool grants, which the server form uses to configure the allow list. Ignored for other roles.

A key with tool search turned on gets the four virtual tools from the list route instead of the catalogue, and can call mcp_tool_search and mcp_tool_call through the call route like any other tool.

Servers that need something from the user still need it here. A bring your own key server fails until the user behind the key has stored a key, a per-user OAuth server needs the user's token, and per-user environment variables must be filled in first. Headers an MCP client would send, such as x-mcp-auth for a true passthrough server, are read from the REST request the same way.

Test a server before saving it​

Both test routes take the same body as POST /v1/mcp/server and store nothing. Only proxy admins may call them. The Admin UI runs them from the Connection Status card of the Add New MCP Server form.

  1. Open MCP Servers, click + Add New MCP Server, pick a connector or + Custom Server and fill in the URL, transport and authentication.

  2. The Connection Status card calls the test routes on its own and lists the tools it found. To do the same from a terminal:

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

    Expected result:

    {"status": "ok"}
  3. POST /mcp-rest/test/tools/list with the same body returns tools, error and message like the list route, before any allow list is applied. For a server with a spec_path the tools are generated from the OpenAPI document instead of asking a server.

Routes​

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

Errors​

StatusRouteMeaningFix
400 server_id is required in request body or name is required in request bodytools/callThe body is missing one of the two required fields.Send server_id, name and arguments.
400 guardrail_violation or blocked_pii_entitytools/callA guardrail attached to the key, team or gateway refused the arguments. The message names the guardrail.Change the arguments, or review the guardrail on the Guardrails page.
401 or 403 relayed from the servertools/callThe upstream server refused the credential. For a bring your own key or per-user OAuth server this means the user's stored credential is missing or expired.The user connects again from the server card, see per-user credentials.
403tools/list, tools/callThe key may not reach the server or tool, the client application is not in mcp_allowed_clients, or the server is internal only and the caller is outside mcp_internal_ip_ranges.Grant the server or tool, see access control.
403 Only PROXY_ADMIN users can perform this action.test/connection, test/tools/listThe key is not a proxy admin key.Use a proxy admin key.
403 approval_required or approval_grant_rejectedtools/callA human approval policy gates the tool. The first answer carries an approval_id.Wait for the approval, then retry the same call with the x-spanway-approval-id header.
404 server_not_foundtools/call, tools/list with server_idNo registered server matches server_id.Check the id, name or alias on the MCP Servers page.
401, 403, 429, 502, 504 or 500 with error set to auth_required, forbidden, rate_limited, unreachable, upstream_error, timeout or internaltools/list with server_idListing one server failed. The status says why: the upstream wants a credential (401) or refused it (403), rate limited you (429), could not be reached or answered with an error (502), took too long (504), or the gateway itself failed (500).Check the server's health badge and credential, then retry.
412 missing_user_env_varstools/callThe server declares per-user environment variables the user has not filled in.Set them from the server card, or with POST /v1/mcp/server/{server_id}/user-env-vars.
500 internal_server_errortools/callThe gateway failed while calling the tool. The answer says "An unexpected error occurred while calling the tool. Check the gateway logs for details." and the cause is only in the gateway log.Look for Unexpected error in MCP tool call in the log.
503 approval_unavailabletools/callAn approval policy matched but the gateway could not read it, so the call was refused.Check the database and retry.
200 with "error": "server_not_found"tools/list with mcp_server_nameThe server is not registered.Check the name.
200 with "error": "server_error"tools/listListing one server failed for an unexpected reason. The message names the server and says "The gateway log has the cause.", the reason itself stays in the log.Check the server's health badge and read the Error getting tools from log line.
200 with "error": "partial_failure"tools/list across several serversAt least one server could not be listed. The tools of the others are in the answer and server_outcomes says which server failed.Check that server's health badge.
200 with "error": "unexpected_error"tools/list across several serversThe gateway hit an unexpected error before it could list the servers. The message is "An unexpected error occurred. The gateway log has the cause."Read the Unexpected error in list_tool_rest_api log line.

Logs​

LevelLineWhat it meansAction
ERRORUnexpected error in MCP tool call: <error>A REST tool call failed inside the gateway and the caller got 500. The line carries the cause.Fix what it names, or report it with the call id.
ERRORHTTPException in MCP tool call: <error>A tool call was refused, for example by a permission or approval check.None if the refusal was expected.
INFOListing tools from <server> failed with a <fault> faultA single-server listing failed, and the status of the answer says why.Check the server.
ERRORError getting tools from <server>: <error>Listing one server failed for an unexpected reason and the caller got server_error.Fix what the error names.
ERRORUnexpected error in list_tool_rest_api: <error>A listing across several servers failed and the caller got unexpected_error.Fix what the error names.