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
| Rule | Value |
|---|---|
| MCP servers per credential | 5 |
name | ^[a-z0-9][a-z0-9_-]{0,31}$, unique within the credential |
| Credential types | Plain 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 name | Must be URL-safe: letters, digits, . _ ~ -, starting with a letter or digit (422 SERVICE_NOT_HOSTABLE) |
url | https, up to 2000 characters, port 443 or an unprivileged port (1024 and up). It must not resolve to a private address (SSRF check, 400) |
headers | Up 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 headers | A 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) |
template | Optional 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.
| Rule | Value credential | Sign-in credential |
|---|---|---|
| Placeholder | At least one header holds ${TOKEN}. ${AGENT_SESSION} is refused | At least one header holds ${AGENT_SESSION}. ${TOKEN} is refused |
| Credential-like header | Holds 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 rules | 422 MCP_SERVER_HEADER_INVALID |
url | https and a public address | The same, and it must not be a Token Vault address (422 SIGNIN_URL_ON_TOKEN_VAULT) |
| Who may add or re-point | See below | A person with a recent sign-in only. A key or agent gets 403 HUMAN_ONLY. Removing is allowed to anyone with tokens:update |
| Tool list | Cached, with tools.count | Not cached. tools is {"perAgent": true} and there is no schema fetch |
| Path | Through your webhook | Direct 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"}'{ "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.
| HTTP | Code | When |
|---|---|---|
| 400 | USE_SIGNIN_ROUTE | POST /api/tokens was called with tokenType: "TVSignIn" |
| 409 | NAME_TAKEN | The name exists, of any kind |
| 403 | QUOTA_EXCEEDED | Over the credential cap |
| 422 | SERVICE_NOT_HOSTABLE | The name cannot appear in a URL |
| 409 | SIGNIN_NO_VALUE | You asked for a value action on it: credential ticket, store ticket, OAuth connect, rotate, refresh, TOTP code, or POST /api/tokens over it |
| 409 | SIGNIN_TOOLS_ONLY | A 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"{
"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" }
}
]
}| Field | Type | Notes |
|---|---|---|
name, url, headers | As saved | |
template | string | Only if set |
tools.count | integer | Cached tool count |
tools.fetchedAt | ISO 8601 or null | When the list was last fetched |
tools.stale | boolean | Fetched for an older URL or headers; a refetch is pending or failed |
tools.error | string | The last fetch failed with this code |
tools.truncated | boolean | The 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 field | Type | Required | Notes |
|---|---|---|---|
servers[].name | string | yes | |
servers[].url | string | yes | |
servers[].headers | object | yes | Header name to template |
servers[].template | string | no | Preset 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 readpolicy 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
| HTTP | Code | When |
|---|---|---|
| 400 | MCP_SERVER_CREDENTIAL_TYPE_UNSUPPORTED | The 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. |
| 422 | MCP_SERVERS_CAP | More than 5 MCP servers |
| 422 | MCP_SERVER_NAME_INVALID | Bad name |
| 422 | MCP_SERVER_NAME_DUPLICATE | Duplicate names |
| 422 | MCP_SERVER_HEADERS_REQUIRED | No headers, or none holds the kind's placeholder (${TOKEN}, or ${AGENT_SESSION} on a sign-in credential) |
| 422 | SIGNIN_URL_ON_TOKEN_VAULT | A sign-in MCP server whose URL is a Token Vault address |
| 422 | MCP_SERVER_HEADER_INVALID | Bad header name or control characters |
| 422 | MCP_SERVER_LITERAL_CREDENTIAL | A credential-like header holds a literal |
| 422 | MCP_SERVER_INVALID | Bad template |
| 422 | SERVICE_NOT_HOSTABLE | The credential name cannot appear in a URL |
| 401 / 403 | REAUTH_REQUIRED, HUMAN_ONLY, WEB_CONSOLE_REQUIRED, SCOPE_DENIED | See above |
| 423 | VAULT_LOCKED | You stopped all access |
{
"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"{ "name": "github", "tools": { "count": 41, "fetchedAt": "2026-11-02T09:40:03+00:00" } }A failed fetch is still 200, with tools.error set.
| HTTP | Code | When |
|---|---|---|
| 404 | MCP_SERVER_NOT_FOUND | No MCP server of that name |
| 409 | MCP_SERVER_CHANGED | The MCP server was removed or changed during the fetch. Try again |
| 429 | RATE_LIMITED | Within 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.
{
"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"
}
]
}id | url |
|---|---|
github | https://api.githubcopilot.com/mcp/ |
linear | https://mcp.linear.app/mcp |
sentry | https://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"andentityId: "{service}:{server}".
CLI
tvault mcp-servers add github --preset github
tvault mcp-servers ls github
tvault mcp-servers templatesSee 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.
Labels API
Reference for GET /api/labels and PUT /api/labels/{entityType}/{entityId}, the endpoints that tag credentials, agents and API keys so policies can attach to the tag.
OAuth Apps API
Reference for the endpoints behind Connect with your own OAuth app, where the provider redirects to your webhook and Token Vault never sees the code, the token or the client secret.