MCP Endpoint
Reference for POST /api/agents/mcp, Token Vault's own MCP server with five credential tools, tvagent_ or OAuth session auth, and the optional aggregated tool list.
POST /api/agents/mcp
Token Vault's own MCP server (serverInfo.name: tokenvault-credentials). Any MCP client can connect over streamable HTTP. It exposes five tools for the caller's own grants.
To call a credential's MCP servers (GitHub, Linear, your own), use the MCP server URL instead: /api/mcp/{service}/{server}.
claude mcp add --transport http --scope user tokenvault https://api.tokenvault.uk/api/agents/mcpOther apps: Connect your apps.
Authentication
Both identities resolve to the same agent, grants and policies.
- OAuth 2.1 (hosted clients and IDEs). The client discovers Token Vault's authorization server from a
401, registers itself and gets atvsess_...session in-client. See OAuth for MCP clients. - Static key.
Authorization: Bearer tvagent_...(orx-agent-key) for scripts and agents you configure by hand.
The agent needs the mcp:use scope (a classic agent has it). There is no MCP switch to set. An older agent can still carry a stored "MCP off" setting and is then refused with "MCP access is not enabled for this agent". Clear it with Turn MCP on on the agent's Connect tab, or PATCH /api/agents/{id} with {"mcpEnabled": true}. An under-scoped agent gets 403, not 401, because signing in again cannot help. A suspended agent gets 401.
Auth is required on every JSON-RPC method, including initialize. A missing or invalid credential gets:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://api.tokenvault.uk/.well-known/oauth-protected-resource"
Content-Type: application/json
{"jsonrpc":"2.0","id":null,"error":{"code":-32001,"message":"Missing agent API key"}}-32001 is Token Vault's auth error. The message is one of: Missing agent API key, Invalid agent API key, Invalid agent API key format, Invalid or expired session, Agent is suspended or deleted, Agent key has expired (all 401), MCP access is not enabled for this agent and Agent lacks the mcp:use scope (both 403).
Tools
| Tool | Arguments | Returns |
|---|---|---|
list_credentials | none | The caller's live grants with metadata. No credential material |
get_credential | service | A signed, short-lived URL to your webhook's /v1/credential. Needs a grant that includes value |
whoami | none | This agent's id, name, status, owner, grants and attached policy names |
show_credential | service | Metadata for one granted service. No credential material |
credential_history | service, limit (1 to 50, optional), cursor (optional) | This agent's own recent access events for one service |
Why a URL and not the value?
The MCP transport runs through Token Vault, and Token Vault never carries credential bytes. get_credential returns a one-time URL. The agent fetches it and receives the value directly from your webhook, the same path as the REST 307. The other four tools return only metadata that Token Vault holds in its control plane.
list_credentials
Each grant is enriched with the credential's description, display name and tags, and with a slice of your webhook's own listing (tokenType, expiryTime, hasRefreshToken). The webhook lookup is best effort: if it fails you get the metadata-only fields.
Rows carry no uses or servers (MCP servers). An MCP-only grant is listed like any other, and get_credential on it returns GRANT_TOOLS_ONLY.
{
"grants": [
{
"serviceName": "github",
"grantExpiresAt": null,
"refreshPolicy": "none",
"description": "GitHub token for CI",
"displayName": "GitHub",
"tags": ["ci"],
"tokenType": "PlainText",
"expiryTime": null,
"hasRefreshToken": false
}
]
}get_credential
{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": { "name": "get_credential", "arguments": { "service": "github" } }
}The result is a text block that contains the fetch URL:
Credential for github (zero-knowledge mode):
Fetch your credential directly from:
https://hook.example.com/v1/credential?ticket=...&service=github
Grant expires: Never
...The agent then runs GET on that URL. Same 60-second ticket as the REST path.
whoami
{
"id": "agent-1",
"name": "CI Bot",
"status": "active",
"ownerId": "firebase-uid",
"grants": [{ "serviceName": "github", "grantExpiresAt": null, "refreshPolicy": "none" }],
"policies": [{ "name": "Business Hours", "ruleTypes": ["time_window"] }]
}It never returns the owner's email or a policy's rule settings, only the policy name and rule types.
show_credential
{ "type": "object", "properties": { "service": { "type": "string" } }, "required": ["service"] }Returns the same fields as one list_credentials entry. An ungranted service gets the same ambiguous NO_GRANT error as get_credential, so the tool cannot enumerate services.
credential_history
{
"type": "object",
"properties": {
"service": { "type": "string" },
"limit": { "type": "integer", "minimum": 1, "maximum": 50 },
"cursor": { "type": "string" }
},
"required": ["service"]
}{
"history": [{ "eventType": "AGENT_CREDENTIAL_ACCESS", "timestamp": "2026-10-25T10:00:00+00:00", "outcome": "success" }],
"nextCursor": "eyJ0cyI6..."
}A page can return fewer rows than limit
Each call reads one page of at most 100 activity rows for the agent, then filters to service. A call can return fewer than limit rows, even zero, while older history remains. Pass nextCursor back as cursor until it is absent.
Aggregated tools (one URL for all your MCP servers)
Where your Token Vault has the aggregator enabled, tools/list on this endpoint also lists the tools of every MCP server the agent may use, so one URL reaches them all. It is a prototype and not enabled on every deployment. Check mcpAggregateEnabled in GET /api/config.
- Tool names are
{toolPrefix}__{tool}when a credential has one MCP server, and{toolPrefix}_{server}__{tool}when it has several. A name must match[A-Za-z0-9_-]{1,64}. Tools that cannot be named so are skipped, and names two tools would share are all dropped. - The result carries
_metawith the counts. - A
tools/callon such a name runs the same checks as the MCP server endpoint and goes through your webhook's/v1/proxy. Token Vault sees the upstream tool list and results, never the credential.
With the flag off, tools/list returns only the five tools above. The MCP server URL works either way.
Rate limiting
initialize, tools/list and notifications/* are protocol bookkeeping. They skip the per-agent floor and never strike the penalty box. They count against mcp_handshake (120 a minute per agent) and the account ceiling.
Every other method, in particular tools/call, shares the same floor counter and penalty box as GET /api/agents/credentials. credential_history also has its own ceiling of 20 a minute per agent. All numbers: Rate limits.
A JSON-RPC batch is rate-limited as one unit. Batches are not supported: a batch body gets a single -32600 error.
{ "jsonrpc": "2.0", "id": null, "error": { "code": -32600, "message": "Batch requests are not supported" } }Two error shapes
A denial arrives as one of two shapes, depending on where it was decided.
Before the tool runs (penalty box, floor, handshake limit, account ceiling): a JSON-RPC error, HTTP 429, with Retry-After.
{
"jsonrpc": "2.0",
"id": 7,
"error": {
"code": -32029,
"message": "Rate limit exceeded.",
"data": { "code": "RATE_LIMITED", "retryAfter": 12 }
}
}Inside the tool (grant, scope, policy, kill switch): an ordinary JSON-RPC result, HTTP 200, with isError: true and a machine-readable structuredContent.
{
"jsonrpc": "2.0",
"id": 7,
"result": {
"content": [{ "type": "text", "text": "Error [NO_GRANT]: No grant for service 'stripe'." }],
"isError": true,
"structuredContent": { "code": "NO_GRANT", "message": "No grant for service 'stripe'." }
}
}structuredContent.code | Meaning |
|---|---|
NO_GRANT | No grant, or no such service. Deliberately identical, so a probe learns nothing |
GRANT_EXPIRED | The grant lapsed (deleted on this call) |
GRANT_TOOLS_ONLY | The grant lacks value. Use the credential's MCP server instead |
POLICY_DENIED | A policy refused. Adds policy, and retryAfter for a rate limit or a closed time window. policyId, appliedVia and ruleSettings are never returned on this endpoint; the owner sees them in Activity |
SCOPE_DENIED | A scoped agent lacks credentials:read. Adds missingScope |
RATE_LIMITED | Over the no-grant miss limit (10 a minute) |
VAULT_LOCKED | You stopped all access |
IDENTITY_ONLY_SESSION | The tvsess_ session is identity-only |
WEBHOOK_NOT_CONFIGURED | No webhook bound |
INVALID_ARGUMENT | service missing, not a string, or contains / |
Full bodies and the human-only fields: Denials.
Policies and revocation
Policies apply to the agent, the credential and their labels, exactly as for REST. That covers time_window, ip_allowlist, rate_limit, max_usage, geo_restrict and access_channel. (manual_approval denies every call.) Suspending the agent stops both paths. For OAuth sessions, every request re-checks the agent: after a suspend the next call is refused (401) and a refresh fails with invalid_grant. And POST /api/mcp-oauth/revoke ends a session at once.
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.
Agent Credentials API
Reference for GET /api/agents/credentials, covering accepted keys, the 307 redirect and ticket, list mode, grant checks and the error catalogue.
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.