MCP clients
The gateway serves every MCP server you register through one Streamable HTTP endpoint, /mcp, so a client connects once and sees the tools of every server its key may use. Each MCP client stores that connection in its own file format and reads secrets in its own way, which is why a snippet that works in one client fails in the next. This page gives a configuration per client that works as written, and the MCP gateway page covers registering the servers themselves.
A real-world scenario
A platform team registered a Jira server and a docs server on the gateway. Half the developers use Cursor, the others VS Code, and two managers want the tools in Claude Desktop. The admin creates one key per person with the two servers granted, sends each person the block for their client from this page, and tells them to keep the key in an environment variable. Everyone sees jira-search_issues and the docs tools within a minute, the Live Connections tab lists each session by person, and when a contractor leaves the admin blocks one key.
Before you start
- At least one MCP server registered on the gateway, see the MCP gateway page. MCP Servers in the Admin UI lists them.
- The gateway reachable from the client over HTTPS, for example
https://gateway.example.com. Claude Desktop custom connectors also need it reachable from the public internet, see Claude Desktop. - Node.js only if you use the
mcp-remotebridge for Claude Desktop, ornpxfor the MCP Inspector. - A virtual key for each person, made as in the next section.
Make a key for MCP clients
Give each person their own key so their tool calls, spend and sessions stay separate, and so one person can be cut off without touching anyone else.
- In the Admin UI open Virtual Keys (
/ui/api-keys) and click + Create New Key. - Under Key Details, choose Key Ownership (You for yourself, or Service Account for a shared bot) and set Key Name to who and which client, for example
jane-mcp. Leave Key Type on AI APIs, so the key can call tools and models but cannot change the gateway. - In Models, pick the models the person also calls with this key, for example
claude-sonnet-5-5. An empty Models list lets the key call every model the gateway serves, so pick at least one. - Open Optional Settings, then MCP Settings, and under Allowed MCP Servers pick the servers or access groups the person may use, for example
jiraanddocs. - In Optional Settings, set Max Budget (USD), for example
100, with Reset Budget on monthly, because tool calls can carry a cost too, and a Requests per minute Limit (RPM) such as60, so a client stuck in a loop slows down instead of hammering the servers. - Click Create Key and copy the key. It is shown once.
The same key from the API, with the master key or a proxy admin's key:
curl -X POST https://gateway.example.com/key/generate \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \
-d '{"key_alias": "jane-mcp", "key_type": "llm_api", "models": ["claude-sonnet-5-5"], "object_permission": {"mcp_servers": ["jira", "docs"]}, "max_budget": 100, "budget_duration": "30d", "rpm_limit": 60}'
The answer carries the new key in key and echoes the grant in object_permission. Access control covers access groups, tool permissions and toolsets, and make a key for a tool explains the other fields.
Steps
-
Get a key that may reach the servers, as in make a key for MCP clients.
-
Check the key from a terminal. The call lists the tools the key will see.
curl https://gateway.example.com/v1/mcp/tools -H "Authorization: Bearer $SPANWAY_API_KEY" -
Add the gateway to your client with the block for it under client configurations. Use
https://gateway.example.com/mcpfor every server the key may use, orhttps://gateway.example.com/mcp/jirafor one server. -
Restart the client or reload its MCP servers and open its tool list.
-
In the Admin UI open MCP Servers, then Live Connections. Your session is listed with the client name, version, user and key alias.
Expected result
The client lists the tools namespaced as <server>-<tool>, for example jira-search_issues and jira-get_issue, so two servers can expose a tool with the same name. A tool call shows on Logs against your key with the server's cost.
Client configurations
Two rules hold for every client. A JSON configuration file is not run through a shell, so a bare $SPANWAY_API_KEY is sent as those literal characters and the gateway answers 401. Use the client's own variable syntax shown below or paste the key. The gateway reads the key from Authorization: Bearer <key> or from x-spanway-api-key, and x-spanway-api-key wins when both are sent, so a client that fills Authorization with its own OAuth token can still send a virtual key.
Claude Code
Add the gateway from a terminal. The shell expands the variable, so the key is stored in Claude Code's own settings. --scope user makes the server available in every project you open. Without it, Claude Code saves the server for the current project only, and another repository does not see the gateway tools.
claude mcp add --transport http --scope user spanway https://gateway.example.com/mcp \
--header "Authorization: Bearer $SPANWAY_API_KEY"
claude mcp list
To share the setup with a project, put it in .mcp.json at the project root without the key. Claude Code expands ${SPANWAY_API_KEY} from each developer's environment.
{
"mcpServers": {
"spanway": {
"type": "http",
"url": "https://gateway.example.com/mcp",
"headers": {"Authorization": "Bearer ${SPANWAY_API_KEY}"}
}
}
}
Cursor
Open ~/.cursor/mcp.json for every project, or .cursor/mcp.json in one project, and add the entry. Cursor expands ${env:SPANWAY_API_KEY}, so start Cursor from an environment where that variable is set. The Cursor tab of MCP Servers, Connect in the Admin UI shows an equivalent block. It sends the key in x-spanway-api-key, which the gateway also accepts, and adds an x-mcp-servers header that limits the session to the servers it names.
{
"mcpServers": {
"spanway": {
"url": "https://gateway.example.com/mcp",
"headers": {"Authorization": "Bearer ${env:SPANWAY_API_KEY}"}
}
}
}
VS Code
VS Code reads .vscode/mcp.json in the workspace. Its top level key is servers, not mcpServers, every remote entry needs "type": "http", and ${input:...} asks for the key once and keeps it in VS Code's secret storage. Run MCP: List Servers from the Command Palette to start the server and see its output.
{
"inputs": [
{"type": "promptString", "id": "spanway-key", "description": "Spanway virtual key", "password": true}
],
"servers": {
"spanway": {
"type": "http",
"url": "https://gateway.example.com/mcp",
"headers": {"Authorization": "Bearer ${input:spanway-key}"}
}
}
}
Claude Desktop
Claude Desktop adds remote MCP servers as custom connectors, not through its JSON file. Adding a connector by URL works on the Free, Pro, Max, Ultra, Team and Enterprise plans. On a personal plan open Customize, then Connectors, click + Add and Add custom connector. On Team and Enterprise plans an owner adds it under Organization settings, Connectors, Add, Custom, Web. Enter https://gateway.example.com/mcp.
To send a virtual key, pick No sign-in and then add a request header Authorization with Bearer <your key>. The Request headers section is a beta that only some organizations see, so it may be missing from the dialog. Without it, leave the sign-in on and use the gateway's own login instead, see OAuth.
Custom connectors are called from Anthropic's cloud, not from your computer, so the gateway must be reachable on port 443 from Anthropic's IP ranges. A gateway on localhost or a private network needs a public HTTPS address or Anthropic's MCP tunnel, which carries the connection into the private network. If you register your own OAuth client for the connector, its redirect URL is https://claude.ai/api/mcp/auth_callback. For a gateway on a private network or on your own computer, run the mcp-remote bridge from claude_desktop_config.json instead, and see Claude Desktop for that setup and for routing the app's model calls through the gateway.
MCP Inspector
The MCP Inspector is the protocol's own test client and the quickest way to see what the gateway serves. Start it with npx @modelcontextprotocol/inspector, set Transport Type to Streamable HTTP, enter https://gateway.example.com/mcp, add the Authorization header with Bearer <your key> under the authentication settings, and click Connect. List Tools shows the same tools your other clients will see.
Errors
| What you see | What it means | Fix |
|---|---|---|
401 right after connecting, with the literal text $SPANWAY_API_KEY in the client log | The client sent the variable name, because a JSON file is not expanded by a shell. | Use the client's syntax above, ${SPANWAY_API_KEY} for Claude Code, ${env:SPANWAY_API_KEY} for Cursor, ${input:...} for VS Code, or paste the key. |
401 Authentication Error, Invalid proxy server token passed | The key is wrong or deleted. | Check the key with the curl in step 2. |
401 Authentication Error, Key is blocked. Update via `/key/unblock` if you're an admin. | The key is blocked. | Ask the admin to open the key in Virtual Keys and click Unblock Key. |
| VS Code shows no server | The file uses mcpServers or the entry has no "type": "http". | Use the VS Code block above. |
| Claude Desktop cannot add the connector | The gateway is not reachable from Anthropic's cloud on port 443. | Give the gateway a public HTTPS address or use Anthropic's MCP tunnel, or use the mcp-remote bridge on your machine. |
| Claude Desktop shows no Request headers section | Request header sign-in is a beta your organization does not have yet. | Use the gateway's OAuth sign-in, see OAuth, or the mcp-remote bridge with the key. |
404 mcp-session-id was terminated by an administrator. Send initialize to start a new session. | An admin closed your session on Live Connections. | Restart the client or reconnect the server. |
404 on /mcp/<name> | No server is registered under that name. | Check the name on MCP Servers, or use /mcp for every server. |
| The client connects but lists no tools | The key has no grant for any server, or the server's allowed_tools leaves nothing. | Grant the server, see access control. GET /v1/mcp/tools shows what the key gets. |
Troubleshooting
- Run the curl from step 2 with the same key. If it lists the tools, the gateway side is fine and the problem is the client's configuration.
- Open the client's MCP output. Claude Code shows each server's state with
claude mcp listand more withclaude --debug. VS Code shows it under MCP: List Servers, Show Output. - Compare the URL and header the client sends with the block above, and check that the variable it reads is set in the environment the client was started from.
- Look for the session on Live Connections. No session means the client never completed
initialize, so the problem is the URL, TLS or the network, see connect any client.
Related
- MCP gateway for registering servers and the tool namespace.
- MCP access control for grants, allowed clients and sessions.
- MCP OAuth for clients that sign in instead of sending a key.
- Connect any client for base URLs, headers and connection errors.
- Cursor and VS Code with GitHub Copilot for the model side of those editors.
- The MCP Servers page for the Connect tab snippets and Live Connections.