Token VaultDocs
Reference

MCP Server Endpoint

Reference for /api/mcp/{service}/{server}, the URL that lets an agent call one credential's MCP server through Token Vault without ever receiving the credential value.

/api/mcp/{service}/{server}

One URL per MCP server attached to a credential. An agent with an MCP grant (uses includes tools in the API) calls the upstream MCP server through Token Vault. Your webhook puts the credential into the upstream request. The agent never gets the value, and neither does Token Vault.

Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS. MCP clients use POST for JSON-RPC.

Example URL
https://api.tokenvault.uk/api/mcp/github/github
SegmentFormat
{service}The credential name. Letters, digits, . _ ~ -, starting with a letter or digit, up to 200 characters
{server}The MCP server name. ^[a-z0-9][a-z0-9_-]{0,31}$

Attach MCP servers to a credential with MCP servers or the MCP servers API. Connect an app: Connect your apps.

Loading diagram...

The direct path for Token Vault sign-in

If {service} is a Token Vault sign-in credential, the call does not go to your webhook. Token Vault does the same checks, then:

  1. Mints an identity-only pass for the calling agent: 15 minutes, audience = the URL of your MCP server. It reuses the pass until 5 minutes before it ends.
  2. Puts the pass in the header template that holds ${AGENT_SESSION}. The caller's own Authorization and x-agent-key headers are removed.
  3. Calls your MCP server directly. The address is checked on every call. Redirects are not followed.
Loading diagram...

Your MCP server checks the pass with introspection. The tool list is not cached, and a sign-in MCP server is not on the combined /api/agents/mcp list (the tool error is SIGNIN_SERVER_NOT_AGGREGATED). A ${TOKEN} MCP server is never called directly, and a ${AGENT_SESSION} MCP server never goes to the webhook.

Authentication

IdentityHeaderNotes
OAuth session tvsess_...Authorization: Bearer tvsess_...From the MCP OAuth flow. Must have been issued for this URL (or name no resource)
Agent key tvagent_...Authorization: Bearer tvagent_... or x-agent-keyFor scripts and CLIs

Scoped API keys (tvkey_...) are not accepted here.

The agent needs the mcp:use scope. There is no MCP switch to set on the agent. An older agent can still carry a stored "MCP off" setting and is then refused with "MCP access is not enabled for this agent"; fix it with Turn MCP on on its Connect tab, or PATCH /api/agents/{id} with {"mcpEnabled": true}. It does not need credentials:read, because it is never handed the value.

A request without valid credentials gets 401 and the challenge for this MCP server:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://api.tokenvault.uk/.well-known/oauth-protected-resource/api/mcp/github/github"
Content-Type: application/json

{"jsonrpc":"2.0","id":null,"error":{"code":-32001,"message":"Missing agent API key"}}

Auth failure messages are the same as on /api/agents/mcp. A tvsess_ issued for a different resource gets 401 with message Session was issued for a different resource, so the client runs the OAuth flow again for this URL.

Resource metadata

GET /.well-known/oauth-protected-resource/api/mcp/{service}/{server} is public and unauthenticated (RFC 9728). It makes no database read: a well-formed pair always gets a document, and the endpoint itself refuses unknown MCP servers.

curl -s https://api.tokenvault.uk/.well-known/oauth-protected-resource/api/mcp/github/github
{
  "resource": "https://api.tokenvault.uk/api/mcp/github/github",
  "authorization_servers": ["https://api.tokenvault.uk"],
  "bearer_methods_supported": ["header"]
}

A malformed service or server gets 404 {"detail":"Not Found"}. The authorization server metadata is at /.well-known/oauth-authorization-server: see OAuth endpoints.

Who may call it

Token Vault reads the agent's grant on {service} and requires all of:

  1. The grant is live (not expired).
  2. Its uses include tools (MCP access).
  3. Its servers (the MCP servers it covers) include {server} (absent servers means every MCP server).
  4. The credential still has an MCP server named {server}.

Nothing else about the credential is read before the grant is accepted, so a caller without one learns nothing about the credential's MCP servers. See Access and the Grants API.

Examples

A client that signed in with OAuth sends plain MCP. These traces use curl with a tvagent_ key.

Initialize
curl -s https://api.tokenvault.uk/api/mcp/github/github \
  -H "Authorization: Bearer $TVAGENT_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"curl","version":"1"}}}'
List tools
curl -s https://api.tokenvault.uk/api/mcp/github/github \
  -H "Authorization: Bearer $TVAGENT_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Session-Id: $SESSION" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'
Call a tool
curl -s https://api.tokenvault.uk/api/mcp/github/github \
  -H "Authorization: Bearer $TVAGENT_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Session-Id: $SESSION" \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"get_me","arguments":{}}}'

The response body is the upstream's response, passed through unchanged. Tool names and results depend on the upstream MCP server. Upstream redirects are not followed.

Errors

Token Vault's own refusals. Anything else is the upstream's status and body.

HTTPShapeCodeWhen
404detailMCP_SERVER_NOT_FOUNDservice or server (the MCP server) is not a valid name
401 / 403JSON-RPC -32001Auth failure (see above)
403detailIDENTITY_ONLY_SESSIONThe session is identity-only
403detailNO_GRANTThe agent has no grant on {service}
403detailGRANT_EXPIREDThe grant lapsed
403detailGRANT_NOT_FOR_TOOLSThe grant lacks tools (value-only)
403detailSERVER_NOT_GRANTEDThe grant's servers list does not include {server}
404detailSERVER_NOT_FOUNDThe credential has no MCP server named {server}
423detailVAULT_LOCKEDYou stopped all access
403 / 429top-level or JSON-RPCPOLICY_DENIEDA policy refused, see Denials
429JSON-RPC (POST) or top-levelRATE_LIMITEDPenalty box, floor or ceiling; or too many no-grant misses
403detailSIGNIN_SESSION_REFUSEDSign-in MCP server: the agent cannot get a pass (suspended, expired, no mcp:use, deleted)
503detailSIGNIN_SESSION_UNAVAILABLESign-in MCP server: the lock state could not be read. Retry-After: 60 (stopped access is VAULT_LOCKED, 423)
502detailSIGNIN_SSRF_GUARD, SIGNIN_UPSTREAM_ERRORSign-in MCP server: its address is refused, or the call failed
500detailPROXY_CONFIG_INVALIDThe MCP server config fits neither the webhook path nor the sign-in path
502detailWEBHOOK_NOT_CONFIGUREDNo webhook bound
502detailWEBHOOK_UNAVAILABLEThe webhook could not be reached
502detailWEBHOOK_AUTH_FAILEDThe webhook rejected Token Vault's signed request
502detailWEBHOOK_REDIRECT_BLOCKEDThe webhook answered with a redirect, which is never followed
502detailUPSTREAM_REDIRECT_BLOCKEDThe MCP server redirected to another address, which is never followed. Set its URL to the final address
503detailWEBHOOK_CIRCUIT_OPENThe webhook failed repeatedly and is paused; Retry-After is set
403detailGRANT_REQUIREDThe webhook reports the stored value is not the creation this access was made for

"detail" means {"detail": {"code", "message"}}. For example:

403, grant covers other MCP servers only
{
  "detail": {
    "code": "SERVER_NOT_GRANTED",
    "message": "This agent's grant for 'github' does not cover server 'docs'."
  }
}
POST 429, penalty box or floor
{
  "jsonrpc": "2.0",
  "id": 3,
  "error": { "code": -32029, "message": "Rate limit exceeded.", "data": { "code": "RATE_LIMITED", "retryAfter": 9 } }
}

A policy rate_limit denial on POST uses the same -32029 error with data.code set to POLICY_DENIED and message Rate limit exceeded by policy. Every other policy denial is the plain 403 body on Denials.

Grant misses (NO_GRANT, GRANT_EXPIRED, GRANT_NOT_FOR_TOOLS, SERVER_NOT_GRANTED, SERVER_NOT_FOUND) are limited to 10 a minute per agent and never strike the penalty box. Past that, the answer is 429 RATE_LIMITED.

Limits and activity

  • Floor: 300 requests a minute per MCP server (proxy_mcp, keyed {service}:{server}). initialize, tools/list and notifications/* are exempt from the floor and from strikes. OPTIONS and DELETE skip the floor. The penalty box and the account ceiling apply. See Rate limits.
  • Policies attach to the entity type mcp_server with id {service}:{server}, in addition to the agent, the credential and their labels.
  • Activity rows have source: "proxy"; the Activity filter is MCP tools.
  • The same checks apply to aggregated tool calls on /api/agents/mcp.

Ready to try it?

Sign in with Google or email. Your credentials stay on your own webhook, and the quickstart gets Claude Code making its first MCP tool call in about 15 minutes.

On this page