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
-
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.
-
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.
-
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"} -
Call the tool.
server_idaccepts the server id, name or alias,nameis the tool name from the list andargumentsfollows 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} -
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:
| Parameter | Meaning |
|---|---|
mcp_server_name | Only the tools of one server, by name or alias. server_id does the same by id. |
toolset_name | Only the tools of one toolset. |
include_disabled_tools | Admins 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.
-
Open MCP Servers, click + Add New MCP Server, pick a connector or + Custom Server and fill in the URL, transport and authentication.
-
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"} -
POST /mcp-rest/test/tools/listwith the same body returnstools,errorandmessagelike the list route, before any allow list is applied. For a server with aspec_paththe tools are generated from the OpenAPI document instead of asking a server.
Routes
| 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 |
Errors
| Status | Route | Meaning | Fix |
|---|---|---|---|
400 server_id is required in request body or name is required in request body | tools/call | The body is missing one of the two required fields. | Send server_id, name and arguments. |
400 guardrail_violation or blocked_pii_entity | tools/call | A 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 server | tools/call | The 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. |
| 403 | tools/list, tools/call | The 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/list | The key is not a proxy admin key. | Use a proxy admin key. |
403 approval_required or approval_grant_rejected | tools/call | A 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_found | tools/call, tools/list with server_id | No 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 internal | tools/list with server_id | Listing 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_vars | tools/call | The 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_error | tools/call | The 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_unavailable | tools/call | An 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_name | The server is not registered. | Check the name. |
200 with "error": "server_error" | tools/list | Listing 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 servers | At 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 servers | The 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
| Level | Line | What it means | Action |
|---|---|---|---|
| ERROR | Unexpected 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. |
| ERROR | HTTPException in MCP tool call: <error> | A tool call was refused, for example by a permission or approval check. | None if the refusal was expected. |
| INFO | Listing tools from <server> failed with a <fault> fault | A single-server listing failed, and the status of the answer says why. | Check the server. |
| ERROR | Error getting tools from <server>: <error> | Listing one server failed for an unexpected reason and the caller got server_error. | Fix what the error names. |
| ERROR | Unexpected error in list_tool_rest_api: <error> | A listing across several servers failed and the caller got unexpected_error. | Fix what the error names. |
Related
- MCP gateway for registering servers and connecting MCP clients.
- MCP access control for server and tool grants.
- MCP per-user credentials for servers that act as the calling user.
- MCP toolsets for calling a curated bundle of tools.
- Tool filtering and tool search for keys that search tools instead of listing them.