Token VaultDocs
Agents and Apps

Agents

Create one agent per app, hold its tvagent_ key, manage its access and sessions, and call Token Vault's own MCP tools.

An agent is an identity for one app, script or service. It holds a tvagent_... key, a list of access (which credentials, for what), and optional policies. Every call it makes shows up in Activity under its name.

One agent per app

Make one agent for Claude Code, another for Cursor, another for CI. Activity then shows which app did what, and you can stop one app without the others. An account holds up to 25 agents.

Loading diagram...

Create an agent

Three ways, same result:

On the first run of Add credential, the Who uses it row asks which apps you use. Each ticked app becomes its own agent (claude-code, cursor, script, ...).

The agent page

/agents/{id} has five tabs. The page opens on Connect until the agent has done something.

TabWhat it holds
OverviewStatus (active or suspended), what the agent can do (scopes under Advanced), description, last 24 hours, created date.
ConnectPer-app connect commands, the agent key (Reveal, Copy, Rotate), the tools it sees, and Sessions. See Connect your apps.
Access (n)Credentials this agent can use, with uses, MCP servers, expiry. Edit or revoke each row. See Access.
PoliciesPolicies attached to this agent. See Policies.
ActivityThis agent's events, filtered on who. See Activity.

The More actions menu has Stop / Resume, Rotate key and Delete.

The agent key

GET /api/agents/credentials?service=github HTTP/1.1
Host: api.tokenvault.uk
Authorization: Bearer tvagent_...

Send the key as Authorization: Bearer. Token Vault also accepts an X-Agent-Key header on routes that do not redirect, but GET /api/agents/credentials refuses it with 400 AGENT_KEY_HEADER_NOT_ACCEPTED: clients drop only Authorization (and Cookie) on the cross-host redirect to your webhook, so an X-Agent-Key header would be sent on to the webhook. A ?key= query parameter is rejected: keys in URLs end up in logs and history. The key identifies the agent to Token Vault. It is not a credential for any service.

  • Reveal (Connect tab) shows the key again. Each reveal is audited (AGENT_KEY_REVEALED) and limited to 20 per hour.
  • Rotate key issues a new key and kills the old one at once. Update every machine that holds the old key.
  • Apps that sign in with OAuth (Claude Code, Claude.ai, ...) never need the key. They get a tvsess_ session bound to the agent. See OAuth for MCP clients.

Stop, resume, delete

ActionEffect
StopThe agent's status becomes suspended. Every call is refused with AGENT_INACTIVE. Its access stays as it is. A signed-in app's next call is refused (401) and its refresh fails with invalid_grant. Resume undoes it.
DeleteRemoves the agent, its key and its access. Cannot be undone.
Revoke accessRemoves one credential from the agent (Access tab). The single-row revoke has an Undo toast.
Revoke all accessRemoves every credential from the agent but keeps the identity (Home and the Activity drawer). No undo.
Stop all accessAccount-wide kill switch. See Stop all access.

Connecting apps

There is no MCP switch to set on an agent. An app can connect to an agent that holds the mcp:use scope, and classic agents hold it already. What the app can do depends on the agent's MCP access and policies. To cut an agent off, revoke its access, press Stop on it, or press Stop all access.

An older agent can still carry a stored "MCP off" setting. It is then refused with "MCP access is not enabled for this agent". Fix it with Turn MCP on on the agent's Connect tab, or send PATCH /api/agents/{id} with {"mcpEnabled": true}. That removes the setting. Setting it to false through the API is 400 MCP_TOGGLE_REMOVED. Convert can clear it for you too (Old MCP connection URLs).

Scoped agents

A classic agent has two scopes: credentials:read and mcp:use. It can use only what you grant it.

A scoped agent (kind: "scoped") gets a chosen subset of scopes, for example a provisioning job that may create credentials. A key or agent can only create agents with a subset of its own scopes, and a scope that only a human may hand out cannot be passed on (SCOPE_NOT_DELEGABLE).

tvault agents create --name job-agent --kind scoped --scopes tokens:create

Sessions

The Sessions list on the Connect tab shows each signed-in MCP client (client name, created, last used). End one session or all of them. Ending a session takes effect at once; the client has to sign in again.

GET /api/agents/{id}/sessions
{
  "sessions": [
    {
      "handle": "9f2c1a7e",
      "clientId": "mcp_client_abc",
      "clientName": "Claude Code",
      "createdAt": "2026-11-02T09:14:03+00:00",
      "lastUsedAt": "2026-11-02T10:01:44+00:00",
      "readOnly": false
    }
  ]
}

DELETE /api/agents/{id}/sessions/{handle} ends one; DELETE /api/agents/{id}/sessions ends all. Both need agents:manage. Handles are opaque hashes, never token values.

Token Vault's own MCP tools

Connect to https://api.tokenvault.uk/api/agents/mcp and the agent sees five tools. They never return a credential value.

ToolArgumentsReturns
list_credentialsnoneGranted credentials with expiry and refresh policy.
get_credentialserviceA signed URL to fetch the value from your webhook. Needs access with the Value use.
whoaminoneThe agent's id, name, status, active access and attached policy names.
show_credentialserviceMetadata (description, tags, type, expiry) without the value.
credential_historyservice, limit?, cursor?The agent's own recent access history for one credential (20 per minute).

Where your Token Vault has the single URL enabled, a credential's own MCP servers also show up here as extra tools when the agent holds MCP access. Everywhere, use the per-server URL (/api/mcp/{service}/{server}). See Connect your apps and MCP servers.

get_credential returns a URL, not a token

{ "jsonrpc": "2.0", "id": 2, "method": "tools/call",
  "params": { "name": "get_credential", "arguments": { "service": "github" } } }
{
  "jsonrpc": "2.0", "id": 2,
  "result": {
    "content": [{
      "type": "text",
      "text": "Credential for github (zero-knowledge mode):\nFetch your credential directly from:\nhttps://tv-webhook.example.workers.dev/v1/credential?ticket=eyJ...<elided>.9c1e...&service=github\n\nScope: N/A\nGrant expires: Never\n\nNote: Token Vault does not handle credentials in webhook mode. Use the URL above to retrieve the credential directly from the webhook."
    }]
  }
}

The agent then runs GET on that URL. The ticket lives 60 seconds, and the reference webhook refuses a reused ticket.

Loading diagram...

When it is refused

An agent with MCP access only gets a tool error, not a URL:

{
  "result": {
    "isError": true,
    "content": [{ "type": "text", "text": "Error [GRANT_TOOLS_ONLY]: This grant does not allow reading the credential value; it can only be used through MCP access." }],
    "structuredContent": {
      "code": "GRANT_TOOLS_ONLY",
      "message": "This grant does not allow reading the credential value; it can only be used through MCP access."
    }
  }
}

The same refusal on REST is 403 with {"detail":{"code":"GRANT_TOOLS_ONLY","message":"..."}}. More in Access and Troubleshooting.

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