Token VaultDocs
ReferenceOAuth

OAuth Endpoint Reference

Every OAuth 2.1 endpoint for MCP clients with request and response shapes, including discovery, registration, authorize, token, refresh, revoke and the resource (audience) rules.

Token Vault is the OAuth 2.1 authorization server for MCP clients. All endpoints live on the API domain, except the consent page. Clients read the paths from the discovery documents and never hard-code them. Errors follow RFC 6749 §5.2 ({"error", "error_description"}). Every endpoint is rate limited; 429 carries Retry-After.

MethodPathPurpose
GET/.well-known/oauth-protected-resource[/...]Which authorization server governs a resource
GET/.well-known/oauth-authorization-serverServer capabilities and endpoint URLs
POST/api/mcp-oauth/registerDynamic client registration (RFC 7591)
(browser)https://tokenvault.uk/oauth/authorizeConsent page (authorization endpoint)
POST/api/mcp-oauth/tokenCode exchange and refresh
POST/api/mcp-oauth/revokeToken revocation (RFC 7009)
POST/api/mcp-oauth/introspectSee Introspection
GET, DELETE/api/agents/{id}/sessions[/{handle}]List and end an agent's sessions
GET, PUT/api/account/mcp-redirect-hostsTrusted redirect hosts

Discovery

Each protected resource has its own metadata document (RFC 9728). The client gets the URL from the WWW-Authenticate header of the 401 it receives.

ResourceMetadata path
Token Vault's own MCP (/api/agents/mcp)/.well-known/oauth-protected-resource or /.well-known/oauth-protected-resource/api/agents/mcp
One credential MCP server/.well-known/oauth-protected-resource/api/mcp/{service}/{server}
Legacy proxy/.well-known/oauth-protected-resource/api/proxy/{proxy_id}/mcp
curl https://api.tokenvault.uk/.well-known/oauth-protected-resource/api/mcp/github/repos
{
  "resource": "https://api.tokenvault.uk/api/mcp/github/repos",
  "authorization_servers": ["https://api.tokenvault.uk"],
  "bearer_methods_supported": ["header"]
}

The document for Token Vault's own MCP has only resource and authorization_servers. The per-server and per-proxy documents add bearer_methods_supported. The server answers for any well-formed path and reads no data, so an unknown server still gets metadata (the MCP route itself refuses it).

curl https://api.tokenvault.uk/.well-known/oauth-authorization-server
{
  "issuer": "https://api.tokenvault.uk",
  "authorization_endpoint": "https://tokenvault.uk/oauth/authorize",
  "registration_endpoint": "https://api.tokenvault.uk/api/mcp-oauth/register",
  "token_endpoint": "https://api.tokenvault.uk/api/mcp-oauth/token",
  "revocation_endpoint": "https://api.tokenvault.uk/api/mcp-oauth/revoke",
  "code_challenge_methods_supported": ["S256"],
  "grant_types_supported": ["authorization_code", "refresh_token"],
  "response_types_supported": ["code"],
  "token_endpoint_auth_methods_supported": ["none"]
}

token_endpoint_auth_methods_supported is ["none"]: all clients are public clients, there is no client_secret, and PKCE S256 is mandatory.

Register (RFC 7591)

POST /api/mcp-oauth/register HTTP/1.1
Host: api.tokenvault.uk
Content-Type: application/json

{"client_name":"my-agent-runtime","redirect_uris":["http://127.0.0.1:43117/callback"]}
201 Created
{
  "client_id": "kX3...16-byte-urlsafe...",
  "redirect_uris": ["http://127.0.0.1:43117/callback"],
  "token_endpoint_auth_method": "none"
}

Redirect URI rules:

  • Loopback (127.0.0.1, ::1, localhost, any port).
  • https to a public hostname.
  • A custom scheme (myapp://callback, cursor://callback, com.example.app:/callback).
  • Plain http to any other host is refused with invalid_redirect_uri. So is a custom scheme that is a browser or OS launcher (microsoft-edge:..., googlechrome:..., intent://...) or that carries a second absolute URL right after its scheme.
  • Hosts you trust beyond these come from trusted redirect hosts.

Input bounds: client_name up to 200 characters, at most 10 redirect_uris, each up to 2000 characters. Longer input returns 422.

A registration expires after 7 days unless it completes an authorize. Then it extends to 180 days and extends again on each authorize. An idle client registers again.

Authorize (browser)

Open the consent page with standard OAuth 2.1 parameters.

ParameterRequiredNotes
client_idyesFrom register
redirect_uriyesExact match to a registered URI
response_typeyescode
code_challengeyesBASE64URL(SHA256(verifier))
code_challenge_methodyesS256 only
stateyesOpaque, returned unchanged
resourcenoRFC 8707. The MCP URL the client will call
https://tokenvault.uk/oauth/authorize?client_id=<id>&redirect_uri=http://127.0.0.1:43117/callback&response_type=code&code_challenge=<challenge>&code_challenge_method=S256&state=<random>&resource=https://api.tokenvault.uk/api/mcp/github/repos

The user signs in, picks an agent and presses Authorize. The browser lands on your redirect_uri with ?code=...&state=....

Authorization codes are single use and expire after 60 seconds. A second exchange of the same code fails with invalid_grant.

The resource parameter

resource binds the session to one audience.

  • A client connecting to /api/mcp/{service}/{server} or /api/proxy/{proxy_id}/mcp names that URL as resource. Consent is refused (access_denied) if the chosen agent has no live MCP access (tools in the API) on that MCP server, so it fails at sign-in and not on the first tool call.
  • A resource on Token Vault's own origin that is not a hosted MCP URL fails with 400 invalid_target.
  • A resource on another https origin is accepted and stored. This is how a hub uses Token Vault as its authorization server and checks sessions through introspection. The session is still refused on every Token Vault endpoint.
  • Omitting resource gives an unbound session.
  • /token re-checks it: a resource that differs from the one on the code fails with 400 invalid_target.

Token: code exchange

Accepts application/x-www-form-urlencoded or application/json.

curl -X POST https://api.tokenvault.uk/api/mcp-oauth/token \
  -d grant_type=authorization_code \
  -d code=<code> \
  -d code_verifier=<verifier> \
  -d client_id=<client_id> \
  -d redirect_uri=http://127.0.0.1:43117/callback \
  -d resource=https://api.tokenvault.uk/api/mcp/github/repos
200 OK
{
  "access_token": "tvsess_...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "tvrefresh_...",
  "scope": ""
}

client_id, redirect_uri and the PKCE verifier must match the values the code was minted against, or the exchange fails with invalid_grant.

Token: refresh

curl -X POST https://api.tokenvault.uk/api/mcp-oauth/token \
  -d grant_type=refresh_token \
  -d refresh_token=tvrefresh_...
200 OK
{
  "access_token": "tvsess_...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": ""
}

Every refresh re-checks the owner and the agent before it mints a session:

ConditionResult
Unknown refresh token400 invalid_grant "Unknown refresh token"
Agent suspended400 invalid_grant "Agent is suspended"
Agent deleted403 invalid_grant "Agent not found"
Agent's MCP access is off400 invalid_grant "MCP not enabled"
Agent expired, or lacks mcp:use400 invalid_grant "Agent can no longer use MCP"
resource differs from the refresh token's400 invalid_target
Owner pressed Stop all access503 temporarily_unavailable with Retry-After: 60
Lock check could not complete503 server_error with Retry-After: 60

This is the kill-switch re-check: stopping access ends token issuance at once. A stopped vault answers 503, not invalid_grant, so well-behaved clients keep their refresh token and retry later.

Revoke (RFC 7009)

curl -X POST https://api.tokenvault.uk/api/mcp-oauth/revoke \
  -H 'Content-Type: application/json' \
  -d '{"token": "tvsess_...", "token_type_hint": "access_token"}'

Always returns 200, whether or not the token existed. token_type_hint (access_token or refresh_token) only orders the lookup. Limit: 60 per hour per IP. A 429 comes before any lookup.

Using the session token

A tvsess_ token is audience-bound.

curl -X POST https://api.tokenvault.uk/api/mcp/github/repos \
  -H 'Authorization: Bearer tvsess_...' \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
  • A session issued for one resource (a hub, a proxy, another MCP server) is refused at any other Token Vault MCP URL.
  • A session issued with no resource is not audience-restricted.
  • An identity-only session (tv_session) is refused on credential and MCP server routes with 403 IDENTITY_ONLY_SESSION.
  • The agent's access and policies apply as for a tvagent_ key. See Agent credentials and MCP server endpoint.

Sessions

Sessions are listed and ended per agent. The agent page in the app uses these routes.

GET /api/agents/{id}/sessions HTTP/1.1
Authorization: Bearer <firebase id token or tvkey_ with agents:read>
200 OK
{
  "sessions": [
    {
      "handle": "a1b2c3d4",
      "clientId": "kX3...",
      "clientName": "my-agent-runtime",
      "createdAt": "2026-11-01T09:30:00+00:00",
      "lastUsedAt": "2026-11-02T08:12:44+00:00",
      "readOnly": false
    }
  ]
}
RouteScopeEffect
DELETE /api/agents/{id}/sessions/{handle}agents:manageEnd one session. Returns {"success": true}
DELETE /api/agents/{id}/sessionsagents:manageEnd every OAuth session of the agent

handle is an opaque id; the raw refresh token never appears. Entries with readOnly: true back a tv_session binding and cannot be ended here.

Trusted redirect hosts

Redirect URIs on a host you have not trusted are refused at consent. Manage the list in Settings > Trusted hosts or by API (human sign-in only).

GET /api/account/mcp-redirect-hosts HTTP/1.1
{ "userHosts": ["claude.example.com"], "operatorHosts": ["claude.ai"] }

PUT /api/account/mcp-redirect-hosts with {"hosts": [...]} replaces userHosts. Entries are exact hosts; wildcards are not allowed. operatorHosts are fixed by the deployment.

Error reference

HTTPerrorWhen
400invalid_requestMissing or malformed parameters, non-S256 PKCE
400invalid_grantBad, expired or reused code, PKCE failure, unknown refresh token, binding mismatch, vault locked
400invalid_clientUnknown client_id
400invalid_redirect_uriUnregistered or disallowed redirect URI
400invalid_targetresource is not a hosted MCP URL, or differs from the one on the code
400unsupported_grant_typeAnything but authorization_code or refresh_token
401invalid_tokenBad Firebase session on the consent page
403access_deniedVault locked ("Vault is locked"), agent not found or not yours, agent suspended or deleted, MCP access off and not enabled at consent, no live MCP access on the target MCP server or proxy
403invalid_grantRefresh for a deleted agent
503temporarily_unavailable, server_errorRefresh while access is stopped, or the lock check failed. Retry-After: 60
429rate_limitedSlow down; honour Retry-After

Per-IP limits: register 30/h, authorize 30/h, token 60/h per (IP, client_id), revoke 60/h, introspect 600/min. See Rate limits.

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