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.
| Method | Path | Purpose |
|---|---|---|
| GET | /.well-known/oauth-protected-resource[/...] | Which authorization server governs a resource |
| GET | /.well-known/oauth-authorization-server | Server capabilities and endpoint URLs |
| POST | /api/mcp-oauth/register | Dynamic client registration (RFC 7591) |
| (browser) | https://tokenvault.uk/oauth/authorize | Consent page (authorization endpoint) |
| POST | /api/mcp-oauth/token | Code exchange and refresh |
| POST | /api/mcp-oauth/revoke | Token revocation (RFC 7009) |
| POST | /api/mcp-oauth/introspect | See Introspection |
| GET, DELETE | /api/agents/{id}/sessions[/{handle}] | List and end an agent's sessions |
| GET, PUT | /api/account/mcp-redirect-hosts | Trusted 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.
| Resource | Metadata 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"]}{
"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). httpsto a public hostname.- A custom scheme (
myapp://callback,cursor://callback,com.example.app:/callback). - Plain
httpto any other host is refused withinvalid_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.
| Parameter | Required | Notes |
|---|---|---|
client_id | yes | From register |
redirect_uri | yes | Exact match to a registered URI |
response_type | yes | code |
code_challenge | yes | BASE64URL(SHA256(verifier)) |
code_challenge_method | yes | S256 only |
state | yes | Opaque, returned unchanged |
resource | no | RFC 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/reposThe 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}/mcpnames that URL asresource. Consent is refused (access_denied) if the chosen agent has no live MCP access (toolsin the API) on that MCP server, so it fails at sign-in and not on the first tool call. - A
resourceon Token Vault's own origin that is not a hosted MCP URL fails with400 invalid_target. - A
resourceon 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
resourcegives an unbound session. /tokenre-checks it: aresourcethat differs from the one on the code fails with400 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{
"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_...{
"access_token": "tvsess_...",
"token_type": "Bearer",
"expires_in": 3600,
"scope": ""
}Every refresh re-checks the owner and the agent before it mints a session:
| Condition | Result |
|---|---|
| Unknown refresh token | 400 invalid_grant "Unknown refresh token" |
| Agent suspended | 400 invalid_grant "Agent is suspended" |
| Agent deleted | 403 invalid_grant "Agent not found" |
| Agent's MCP access is off | 400 invalid_grant "MCP not enabled" |
Agent expired, or lacks mcp:use | 400 invalid_grant "Agent can no longer use MCP" |
resource differs from the refresh token's | 400 invalid_target |
| Owner pressed Stop all access | 503 temporarily_unavailable with Retry-After: 60 |
| Lock check could not complete | 503 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
resourceis not audience-restricted. - An identity-only session (
tv_session) is refused on credential and MCP server routes with403 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>{
"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
}
]
}| Route | Scope | Effect |
|---|---|---|
DELETE /api/agents/{id}/sessions/{handle} | agents:manage | End one session. Returns {"success": true} |
DELETE /api/agents/{id}/sessions | agents:manage | End 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
| HTTP | error | When |
|---|---|---|
| 400 | invalid_request | Missing or malformed parameters, non-S256 PKCE |
| 400 | invalid_grant | Bad, expired or reused code, PKCE failure, unknown refresh token, binding mismatch, vault locked |
| 400 | invalid_client | Unknown client_id |
| 400 | invalid_redirect_uri | Unregistered or disallowed redirect URI |
| 400 | invalid_target | resource is not a hosted MCP URL, or differs from the one on the code |
| 400 | unsupported_grant_type | Anything but authorization_code or refresh_token |
| 401 | invalid_token | Bad Firebase session on the consent page |
| 403 | access_denied | Vault 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 |
| 403 | invalid_grant | Refresh for a deleted agent |
| 503 | temporarily_unavailable, server_error | Refresh while access is stopped, or the lock check failed. Retry-After: 60 |
| 429 | rate_limited | Slow 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.
Token Refresh
How OAuth tokens stay fresh, covering webhook-autonomous refresh, the notify call Token Vault sends, the manual refresh endpoint and its errors, and the pause that stops a loop nobody can fix.
Introspection & Gateway Gating
Validate tvsess_ tokens from your own MCP gateway or webhook with one HTTP call, including the resource (aud) audience check and schedule enforcement.