Token VaultDocs
Agents and Apps

How MCP clients sign in

Token Vault is an OAuth 2.1 authorization server for MCP, so clients register themselves, you press Authorize once, and they get a tvsess_ session.

Token Vault is both the authorization server and the protected resource for its MCP URLs. A client that speaks the MCP authorization spec connects with no pasted key: you approve once in a browser and pick the agent it acts as.

This page is about signing an MCP client in to Token Vault. Connecting a credential to Google or GitHub with your own OAuth app is a different flow: see OAuth apps.

claude mcp add --transport http --scope user tokenvault https://api.tokenvault.uk/api/agents/mcp
# in Claude Code: /mcp, Authenticate, pick the agent, Authorize

This applies to /api/agents/mcp and to every MCP server URL /api/mcp/{service}/{server}. Per-app commands are in Connect your apps.

The flow

Loading diagram...

Discovery

The first call without a token fails with a pointer to the metadata:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://api.tokenvault.uk/.well-known/oauth-protected-resource"

An MCP server URL points at its own document, /.well-known/oauth-protected-resource/api/mcp/{service}/{server}. Both name Token Vault as the authorization server:

curl -s https://api.tokenvault.uk/.well-known/oauth-protected-resource/api/mcp/github/github
{
  "resource": "https://api.tokenvault.uk/api/mcp/github/github",
  "authorization_servers": ["https://api.tokenvault.uk"],
  "bearer_methods_supported": ["header"]
}
curl -s 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"]
}

Standards

StandardRole
RFC 9728Protected resource metadata (global and per MCP server)
RFC 8414Authorization server metadata
OAuth 2.1 + RFC 7636PKCE with S256 only. Public clients, no client secrets.
RFC 7591Dynamic client registration. No pre-shared client_id.
RFC 8707Resource indicators: a session is bound to the URL it was issued for.
RFC 7009Revocation (POST /api/mcp-oauth/revoke)
RFC 7662Introspection (POST /api/mcp-oauth/introspect), see Introspection

https://tokenvault.uk/oauth/authorize is a page in the web app. You sign in, then:

  1. Pick the Agent the client acts as. Its access and policies apply.
  2. Press Authorize.
  3. The client receives its code on the redirect and exchanges it for tokens.

A suspended agent cannot be authorized.

Tokens

TokenLifetimeUse
tvsess_...3600 secondsSent as Authorization: Bearer to the MCP URL.
tvrefresh_...Until revoked or the agent is suspendedExchanged for a new tvsess_. Every refresh re-checks the agent's status.
tvagent_...Until rotatedThe static alternative: paste into a header for headless use.

All resolve to the same (user, agent) identity, with the same access and policies. A tvsess_ issued for one URL is refused on another. A session with no agent behind it (identity only) is refused with IDENTITY_ONLY_SESSION. MCP URLs need the mcp:use scope, not credentials:read.

Trusted hosts

Hosted clients redirect back to an https host of their own. Token Vault only sends a code to hosts you have trusted, and it never asks at consent time: a link crafted by someone else must not be able to trust a host for you. Add hosts ahead of time under Settings > Trusted hosts ("Redirect hosts MCP clients may use").

  • Exact hostnames only. No wildcards, scheme or path (pasting a full URL keeps the host).
  • Up to 20 hosts. Adding needs a sign-in within the last 5 minutes and access not to be stopped; removing always works.
  • Loopback redirects (Claude Code, Cursor, Codex, Gemini CLI) need no entry.
  • The operator of your Token Vault may pre-trust some hosts. Those show read-only.

An untrusted host fails at Authorize:

{
  "error": "invalid_request",
  "error_description": "Redirect host example-client.com is not trusted. Add it in Token Vault → Settings → Trusted MCP redirect hosts, then retry.",
  "untrustedHost": "example-client.com"
}

Sessions and ending them

ActionEffect
Sessions on the agent's Connect tab: end one or allThe client has to sign in again.
Suspend the agentToken Vault re-reads the agent on every call, so the next call is refused (401) and refresh fails with invalid_grant.
Delete the agentSame, permanently.
POST /api/mcp-oauth/revokeKills one tvsess_ or tvrefresh_ now.
Stop all accessToken Vault refuses new requests at once. A gateway that caches introspection results can keep accepting a session for up to 60 seconds.
A time_window or other policyChecked on every call, not just at sign-in.

Limits

Per IP: register 30 per hour, authorize 30 per hour, token 60 per hour per client, revoke 60 per hour, introspect 600 per minute. See Rate limits.

Next steps

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