Skip to main content

MCP access control

Which servers and tools a caller sees is decided at session start from the virtual key, the key's team and the user behind it, and re-checked on every tool call. The controls on this page stack, and a tool is available only when every applicable layer allows it. Grants decide who may reach a server, tool grants narrow it to named tools, the client allow list decides which applications may connect at all, the network rules keep internal servers off the public internet, and the review queue lets people propose servers without being admins.

A real-world scenario​

The support team's assistant should search Jira and read the knowledge base, but not create or edit anything. The admin gives the team's key the jira server with only search_issues and get_issue, plus the knowledge access group that expands to the Confluence and wiki servers. The assistant sees exactly those tools. The company only allows its approved desktop client to open MCP sessions, so an unknown client that gets hold of a key is turned away with a 403. When a contractor leaves, the admin closes their live sessions from the Live Connections tab and their next request has to authenticate again, which fails because their key was revoked.

Grant servers and tools to a key or team​

object_permission on a key, team, organization or user carries the MCP grants.

  1. In the Admin UI, open Virtual Keys and click + Create New Key, or edit an existing key. In the MCP server picker, choose the servers, access groups and toolsets the key may use, and in the tool permission panel untick the tools it must not call. Save.

  2. Or grant with the API:

    curl -X POST http://localhost:4000/key/generate \
    -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \
    -d '{
    "key_alias": "support-bot",
    "object_permission": {
    "mcp_servers": ["jira"],
    "mcp_access_groups": ["knowledge"],
    "mcp_tool_permissions": {"jira": ["search_issues", "get_issue"]},
    "mcp_toolsets": ["support-agent"],
    "mcp_tool_search_enabled": false
    }
    }'

    Expected result is the new key with its object_permission echoed back.

  3. Check what the key ends up with after every layer is applied:

    curl http://localhost:4000/v1/mcp/tools -H "Authorization: Bearer sk-support-bot"
    {"tools": [{"name": "jira-search_issues"}, {"name": "jira-get_issue"}, {"name": "confluence-search_pages"}, {"name": "wiki-search"}]}
FieldMeaning
mcp_serversServer ids or names the caller may reach.
mcp_access_groupsAccess group names, each expanding to every server that lists the group in mcp_access_groups. GET /v1/mcp/access_groups lists the groups known from config and the database.
mcp_tool_permissionsPer server allow list of tool names. Unlisted tools on that server are hidden.
mcp_toolsetsToolsets the caller may use.
mcp_tool_search_enabledServe the tool search virtual tools instead of the catalogue.
mcp_tool_search_top_kFrom 1 to 100, the most tools one tool search returns for this key or team. Empty keeps the global top_k.
mcp_tool_search_similarity_thresholdFrom 0.0 to 1.0, the lowest similarity a tool needs in semantic tool search results for this key or team. Empty keeps the global threshold.
mcp_rpm_limitSet on a team with /team/new or /team/update, a map of server name to requests per minute that applies to every member reaching that server through the team.

A key's own grants and its team's grants are both consulted, and a user with no key reaches servers through the teams they belong to. A server with allow_all_keys: true is reachable without a grant, and an admin key that carries no MCP scope of its own reaches every server. Tool level restrictions still apply on a server reached through an open channel.

Limit client applications​

general_settings.mcp_allowed_clients restricts which client applications may open MCP sessions, independent of who the user is.

  1. In the Admin UI, open MCP Servers and the Network Settings tab. Under Allowed Clients click Add client, enter an Alias and the exact Value, and click Save. Set Client Identity Header when some clients carry no JWT claim.

  2. Or in config.yaml:

    general_settings:
    mcp_allowed_clients:
    - alias: Approved desktop client
    value: desktop-client-prod
    mcp_client_id_header: x-mcp-client
  3. A client that sends x-mcp-client: desktop-client-prod connects. One that sends nothing, or another value, gets 403.

With mcp_client_id_header set, every MCP tool call that carries the header is also tagged MCP-Client: <label>, using the alias when the value is listed. JWT callers are labelled by their mcp_client_id_jwt_field claim, never by the header, so the label always matches the identity the gateway admitted. This lets MCP usage analytics split active users and agents by client app. The header or the JWT claim setting alone turns the labels on, the allowlist is not needed for them.

When the list is set every MCP request must carry an identity matching one of the values. A JWT caller is identified by the claim named in spanway_jwtauth.mcp_client_id_jwt_field, any other caller by the mcp_client_id_header header. The header is chosen by the client, so it is a policy control rather than a security boundary, and the JWT claim should be preferred where callers have JWTs.

Keep internal servers internal​

available_on_public_internet: false on a server, the Internal network only switch of the server form, limits it to callers on internal networks. general_settings.mcp_internal_ip_ranges defines those networks and defaults to the RFC 1918 ranges plus loopback, and the Private IP Ranges field on the Network Settings tab edits it. The client address is taken from X-Forwarded-For only when use_x_forwarded_for is on and the direct peer is inside general_settings.trusted_proxy_ranges, the same ranges the IP allow-lists use. The header is read from the right and the first address that is not a trusted proxy is the client, so an internal address a caller forged on the left is never used. mcp_trusted_proxy_ranges is still read, and when both are set only proxies inside both lists are trusted. mcp_xff_num_trusted_hops picks the entry that many places from the right instead, and a chain shorter than that counts the caller as external.

curl http://localhost:4000/v1/mcp/network/client-ip -H "Authorization: Bearer $SPANWAY_API_KEY"
{"client_ip": "10.20.1.44"}

That route returns the address the gateway resolved for the caller, which is the quickest way to check the proxy settings.

Review submitted servers​

Team members can propose servers without being admins. In the Admin UI they see + Submit MCP Server instead of the add button, and the form's title reads Submit MCP Server for Review.

  1. A team member submits a server with a team scoped key. The server is created with approval_status: pending_review and is not live:

    curl -X POST http://localhost:4000/v1/mcp/server/register \
    -H "Authorization: Bearer sk-team-member" -H "Content-Type: application/json" \
    -d '{"server_name": "docs_search", "url": "https://docs-mcp.internal.example.com/mcp", "transport": "http", "auth_type": "none", "description": "Search the internal docs", "source_url": "https://git.example.com/platform/docs-mcp"}'

    Expected result, with status 201, is the server with "approval_status": "pending_review".

  2. An admin opens MCP Servers and the Submitted MCPs tab. The card shows the submitter, the fields and a compliance panel against the Submission Rules. Click Approve or Reject with an optional reason. Or with the API:

    curl -X PUT http://localhost:4000/v1/mcp/server/8f1c2d3e-4b5a-4c6d-9e7f-0a1b2c3d4e5f/approve \
    -H "Authorization: Bearer $SPANWAY_MASTER_KEY"

    Expected result is the server with "approval_status": "active", and the submitter now sees it in their list. Approving and rejecting are audited with the approval status before and after.

GET /v1/mcp/server/submissions returns the queue with counts. general_settings.mcp_required_fields lists the fields a submission must fill in, for example description, source_url and alias, which the Submission Rules panel edits. general_settings.user_mcp_management_mode controls what non admins see on the MCP Servers page, restricted shows only the servers they can use and view_all lists every server read only.

Inspect and close sessions​

Stateful MCP sessions live on the worker that accepted them. The Live Connections tab of MCP Servers lists them with client name and version, user, key alias, team, client address, idle time and in-flight requests, refreshing every 15 seconds. Disconnect on a row, or Disconnect all for a user, force closes the sessions.

curl http://localhost:4000/v1/mcp/sessions -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
{"worker_pid": 4120, "total_sessions": 2, "by_client": [{"label": "desktop-client", "count": 2}], "by_user": [{"label": "jane@example.com", "count": 2}], "sessions": [{"session_id_prefix": "9f2a6c1e", "client_name": "desktop-client", "client_version": "1.8.0", "user_email": "jane@example.com", "key_alias": "jane-laptop", "idle_seconds": 12.4, "in_flight_requests": 0}]}
curl -X DELETE "http://localhost:4000/v1/mcp/sessions?user_id=jane" -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
{"worker_pid": 4120, "terminated_sessions": 2, "sessions": [...]}

The client's next request has to send a new initialize, which runs authentication again. Sessions on other workers are not listed, so run the delete against each worker behind a load balancer.

{{ops:^/v1/mcp/(access_groups|tools|sessions|network/client-ip)$|^/v1/mcp/server/(register|submissions)$|^/v1/mcp/server/{server_id}/(approve|reject)$}}

Guardrails and logging​

MCP tool calls run the pre, during and post call guardrails attached to the key, team or gateway, and every call is logged with the server, tool, arguments, result size, latency and cost. The Admin UI shows them on the Logs page with the MCP filter.

Errors​

StatusWhereMeaningFix
403 on /mcp or a tool callAny clientThe key and its team have no grant for the server, the tool is outside mcp_tool_permissions, or the server's allowed_tools leaves it out.Grant it, and check the result with GET /v1/mcp/tools.
403 from the client allow listAny clientmcp_allowed_clients is set and the request carries no identity or an unlisted one. The gateway logs "Rejected MCP request from a disallowed client application".Add the client's value on Network Settings, or set mcp_client_id_header.
Server missing for a caller outside the officeAny clientThe server has available_on_public_internet: false and the caller's address is outside mcp_internal_ip_ranges.Check GET /v1/mcp/network/client-ip and the trusted proxy ranges.
429 on a serverAny clientThe team's mcp_rpm_limit for that server, or the server's own rpm, is exhausted.Wait, or raise the limit.
500 mcp_required_fields contains unknown field names: [...]. Check general_settings.mcp_required_fields in your proxy config.POST /v1/mcp/server/registerA field name in the setting is not a server field. The gateway only notices when someone submits a server.Use field names such as description, source_url and alias.
400 Submission is missing required fields: [...]. Configure required fields via general_settings.mcp_required_fields.POST /v1/mcp/server/registerA field the setting requires is empty.Fill in the field and submit again.
400 Registration requires an API key associated with a team. Use a team-scoped key.POST /v1/mcp/server/registerThe key has no team.Submit with a team key.
400 stdio MCP servers cannot be submitted via the user registration workflow. ...POST /v1/mcp/server/registerTeam members may not propose servers that run a local command.Ask a proxy admin to add it.
403 PROXY_ADMIN users should use POST /v1/mcp/server to create servers directly instead of the submission workflow.POST /v1/mcp/server/registerProxy admins create servers directly.Use POST /v1/mcp/server.
400 MCP server is already active. or MCP server is already rejected.Approve, rejectThe submission is already in that state.Nothing to do.
400 Provide session_id_prefix and/or user_id to select the sessions to terminate.DELETE /v1/mcp/sessionsNeither selector was sent.Send one of them.