Token VaultDocs
Reference

MCP Servers API

Reference for the endpoints that attach MCP servers to a credential, refresh their cached tool lists, and list the built-in presets.

A credential can carry up to 5 MCP servers. Each MCP server is a URL plus header templates. An agent with an MCP grant (uses includes tools in the API) calls the MCP server at /api/mcp/{service}/{server} and never sees the value. How it works for people: MCP servers.

Token Vault stores only the templates. Your webhook replaces ${TOKEN} with the credential when it calls the upstream. A Token Vault sign-in credential uses ${AGENT_SESSION} instead (below).

Rules

RuleValue
MCP servers per credential5
name^[a-z0-9][a-z0-9_-]{0,31}$, unique within the credential
Credential typesPlain text and OAuth (JWT) credentials only, the same as the web app. Both hold a single value for ${TOKEN}. Any other type is refused (400 MCP_SERVER_CREDENTIAL_TYPE_UNSUPPORTED); clearing MCP servers ([]) works on any type
Credential nameMust be URL-safe: letters, digits, . _ ~ -, starting with a letter or digit (422 SERVICE_NOT_HOSTABLE)
urlhttps, up to 2000 characters, port 443 or an unprivileged port (1024 and up). It must not resolve to a private address (SSRF check, 400)
headersUp to 50. Name an HTTP token, value up to 2000 characters, no control characters
${TOKEN}At least one header value must contain it (MCP_SERVER_HEADERS_REQUIRED). On a sign-in credential, ${AGENT_SESSION} instead
Credential-like headersA header whose name contains auth, cookie, token, secret, key, passw, credential, signature or session may hold only the ${TOKEN} placeholder, never a literal (MCP_SERVER_LITERAL_CREDENTIAL)
templateOptional preset id such as github. A short slug

Kinds: ${TOKEN} and ${AGENT_SESSION}

A credential has a kind. Most credentials hold a value, and their MCP servers use ${TOKEN}. A Token Vault sign-in credential holds no value, and its MCP servers use ${AGENT_SESSION}. Token Vault fills that placeholder with the calling agent's own identity pass and calls your MCP server directly.

RuleValue credentialSign-in credential
PlaceholderAt least one header holds ${TOKEN}. ${AGENT_SESSION} is refusedAt least one header holds ${AGENT_SESSION}. ${TOKEN} is refused
Credential-like headerHolds only ${TOKEN}Holds only ${AGENT_SESSION}
Hop headers (Host, Content-Length, X-Forwarded-*, X-Real-Ip, X-Mcp-Key, X-Agent-Key)Allowed by the header rules422 MCP_SERVER_HEADER_INVALID
urlhttps and a public addressThe same, and it must not be a Token Vault address (422 SIGNIN_URL_ON_TOKEN_VAULT)
Who may add or re-pointSee belowA person with a recent sign-in only. A key or agent gets 403 HUMAN_ONLY. Removing is allowed to anyone with tokens:update
Tool listCached, with tools.countNot cached. tools is {"perAgent": true} and there is no schema fetch
PathThrough your webhookDirect from Token Vault

GET on a sign-in credential adds "kind": "tv_signin" at the top. Value credentials have no kind field.

POST /api/tokens/sign-in

Create a Token Vault sign-in credential. Scope: tokens:create. Needs the kill switch off (423 VAULT_LOCKED).

curl -s -X POST https://api.tokenvault.uk/api/tokens/sign-in \
  -H "Authorization: Bearer $TVKEY" -H "Content-Type: application/json" \
  -d '{"serviceName":"home-hub"}'
200 OK
{ "success": true, "serviceName": "home-hub", "kind": "tv_signin" }

Then set its MCP server with PUT /api/tokens/{service}/mcp-servers, and give agents MCP access (uses: ["tools"]) with the Grants API.

HTTPCodeWhen
400USE_SIGNIN_ROUTEPOST /api/tokens was called with tokenType: "TVSignIn"
409NAME_TAKENThe name exists, of any kind
403QUOTA_EXCEEDEDOver the credential cap
422SERVICE_NOT_HOSTABLEThe name cannot appear in a URL
409SIGNIN_NO_VALUEYou asked for a value action on it: credential ticket, store ticket, OAuth connect, rotate, refresh, TOTP code, or POST /api/tokens over it
409SIGNIN_TOOLS_ONLYA grant with value, or any key grant

Your webhook stores a name-only row for it. The webhook contract does not change.

GET /api/tokens/{service}/mcp-servers

The MCP servers on a credential ([] when none). Scope: tokens:list.

curl -s https://api.tokenvault.uk/api/tokens/github/mcp-servers \
  -H "Authorization: Bearer $TVKEY"
200 OK (signed-in human)
{
  "servers": [
    {
      "name": "github",
      "url": "https://api.githubcopilot.com/mcp/",
      "headers": { "Authorization": "Bearer ${TOKEN}", "Accept": "application/json, text/event-stream" },
      "template": "github",
      "tools": { "count": 41, "fetchedAt": "2026-11-02T09:31:12+00:00" }
    }
  ]
}
FieldTypeNotes
name, url, headersAs saved
templatestringOnly if set
tools.countintegerCached tool count
tools.fetchedAtISO 8601 or nullWhen the list was last fetched
tools.stalebooleanFetched for an older URL or headers; a refetch is pending or failed
tools.errorstringThe last fetch failed with this code
tools.truncatedbooleanThe list hit the cache cap

Tool bodies are never in this response.

Keys and agents see less. The path and query of url and all headers can hold a literal secret next to ${TOKEN}, so a non-human caller gets only the origin: "url": "https://api.githubcopilot.com" and "urlRedacted": true when a path was dropped. There is no headers field.

PUT /api/tokens/{service}/mcp-servers

Replace the credential's whole MCP server list. {"servers": []} removes them all. Scope: tokens:update. Needs the kill switch off.

Body fieldTypeRequiredNotes
servers[].namestringyes
servers[].urlstringyes
servers[].headersobjectyesHeader name to template
servers[].templatestringnoPreset id
curl -s -X PUT https://api.tokenvault.uk/api/tokens/github/mcp-servers \
  -H "Authorization: Bearer $TVKEY" -H "Content-Type: application/json" \
  -d '{
    "servers": [{
      "name": "github",
      "url": "https://api.githubcopilot.com/mcp/",
      "headers": { "Authorization": "Bearer ${TOKEN}", "Accept": "application/json, text/event-stream" },
      "template": "github"
    }]
  }'

The response has the same shape as GET. New MCP servers show tools.count: 0 until the background fetch finishes.

What counts as a redirect. Adding an MCP server, or changing a URL or headers, points the credential somewhere new. Then:

  • A human needs a sign-in within 5 minutes (401 REAUTH_REQUIRED).
  • A key or agent cannot do it (403 HUMAN_ONLY), whatever scopes and grants it holds. An MCP server that a key set would keep getting the credential after the key's grant, or the key, had expired.
  • If a Who can read policy covers the credential, it is web-app only (403 WEB_CONSOLE_REQUIRED).

Removing MCP servers, or changing only template, needs none of that.

After saving, Token Vault fetches each new or changed MCP server's tool list through your webhook, in the background. The PUT never waits for it and never fails on it. Removing an MCP server deletes its cached tool list. A MCP_SERVERS_UPDATED event is recorded in Activity.

Grants that name a removed MCP server keep the stale name. The endpoint answers SERVER_NOT_FOUND until an MCP server of that name is added again.

Errors

HTTPCodeWhen
400MCP_SERVER_CREDENTIAL_TYPE_UNSUPPORTEDThe credential is not Plain text or JWT (for example Composite, TOTP, Certificate, SSHKey, RawCredential)
400(bare detail)URL not https, bad port, private address
404(bare detail)Token '...' not found.
422MCP_SERVERS_CAPMore than 5 MCP servers
422MCP_SERVER_NAME_INVALIDBad name
422MCP_SERVER_NAME_DUPLICATEDuplicate names
422MCP_SERVER_HEADERS_REQUIREDNo headers, or none holds the kind's placeholder (${TOKEN}, or ${AGENT_SESSION} on a sign-in credential)
422SIGNIN_URL_ON_TOKEN_VAULTA sign-in MCP server whose URL is a Token Vault address
422MCP_SERVER_HEADER_INVALIDBad header name or control characters
422MCP_SERVER_LITERAL_CREDENTIALA credential-like header holds a literal
422MCP_SERVER_INVALIDBad template
422SERVICE_NOT_HOSTABLEThe credential name cannot appear in a URL
401 / 403REAUTH_REQUIRED, HUMAN_ONLY, WEB_CONSOLE_REQUIRED, SCOPE_DENIEDSee above
423VAULT_LOCKEDYou stopped all access
422 MCP_SERVER_LITERAL_CREDENTIAL
{
  "detail": {
    "code": "MCP_SERVER_LITERAL_CREDENTIAL",
    "message": "Header 'Authorization' carries a credential, so its value must use ${TOKEN}; a literal value would be stored at Token Vault. Store the credential at your webhook instead."
  }
}

POST /api/tokens/{service}/mcp-servers/{name}/schema

Fetch one MCP server's tool list now, through your webhook. Scope: tokens:update. No recent sign-in, because nothing is redirected. A key or agent still needs the same live value grant as for the PUT.

curl -s -X POST https://api.tokenvault.uk/api/tokens/github/mcp-servers/github/schema \
  -H "Authorization: Bearer $TVKEY"
200 OK
{ "name": "github", "tools": { "count": 41, "fetchedAt": "2026-11-02T09:40:03+00:00" } }

A failed fetch is still 200, with tools.error set.

HTTPCodeWhen
404MCP_SERVER_NOT_FOUNDNo MCP server of that name
409MCP_SERVER_CHANGEDThe MCP server was removed or changed during the fetch. Try again
429RATE_LIMITEDWithin 10 seconds of the last fetch. Top-level body with retryAfter

GET /api/config/mcp-templates

Presets for the Add flow and the CLI. Public: no credential is involved.

200 OK
{
  "templates": [
    {
      "id": "github",
      "name": "GitHub",
      "url": "https://api.githubcopilot.com/mcp/",
      "headers": { "Authorization": "Bearer ${TOKEN}", "Accept": "application/json, text/event-stream" },
      "docsUrl": "https://github.com/github/github-mcp-server"
    }
  ]
}
idurl
githubhttps://api.githubcopilot.com/mcp/
linearhttps://mcp.linear.app/mcp
sentryhttps://mcp.sentry.dev/mcp

All three use Authorization: Bearer ${TOKEN} and Accept: application/json, text/event-stream.

MCP server URL and policies

  • The URL of an MCP server is https://api.tokenvault.uk/api/mcp/{service}/{server} (endpoint reference).
  • A policy can attach to an MCP server with entityType: "mcp_server" and entityId: "{service}:{server}".

CLI

tvault mcp-servers add github --preset github
tvault mcp-servers ls github
tvault mcp-servers templates

See tvault CLI.

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