DocsAPI Reference

Insights and usage MCP

Let your AI client read Tokamak analytics with your account's permissions.


MCP connections are available when your organization administrator enables Insights & usage MCP in Organization → Settings → MCP. Each organization chooses independently; MCP starts off. Connections are read-only and separate from inference API keys. Turning MCP off revokes that organization's connections. After re-enabling, each user must connect again and give fresh consent.

Set up

The MCP activity panel on the same page shows request counts, outcomes, latency and recent access records. Organization administrators can view all members; everyone else sees their own calls. Choose a period or outcome, expand correlation IDs to troubleshoot a call, or page through older records. The latest page refreshes automatically while visible. History stays available when MCP is disabled, covers up to 30 days, and never shows credentials or tool content. Earlier access refusals are available to operators in service logs; logging failures may leave gaps in history.

  1. Open Organization → Settings → MCP in Tokamak.
  2. Copy the login command shown there. It selects your gateway, email and organization.
  3. Run it locally, review the browser consent screen and allow the categories you need.
  4. Add the displayed stdio server configuration to your MCP client, preserving its other settings.
  5. Ask your client to call tokamak_get_access with your user_email, then request your usage or insights.

For example, on a fictional gateway:

tokamak mcp login --name org-42 --api-url https://gateway.example.test --organization-id 42 --email [email protected]

Clients using the common mcpServers JSON format can add:

{
  "mcpServers": {
    "tokamak": {
      "command": "tokamak",
      "args": ["mcp", "serve", "--name", "org-42"]
    }
  }
}

Client configuration formats vary. The executable must be available to your client. Tokens are stored in your OS credential store, never in this JSON. Linux needs an unlocked Secret Service on the session D-Bus; no plaintext credential fallback is provided. Login callbacks must reach the same machine.

Who can read what?

Your organization authorityUsageInsights
Owner or adminOwn and all membersOwn and all members
Billing administratorOwn and all membersOwn only
Member or team-only administratorOwn onlyOwn only

Features and consent can narrow these rights. Platform-operator status grants no extra access inside an organization. A connection stays bound to one organization even when you switch workspaces in the browser.

Every tool requires your user_email. Email alone is not authentication. For an authorized member lookup, keep your own email and add scope: "member" with member_email; a member cannot gain access by entering an owner's email.

What the client receives

Usage reads the same token-usage records and rollups as Analytics: requests, tokens, decimal-string cost, breakdowns and bounded request lists. Usage cost does not equal a wallet debit; bring-your-own-key usage is not billed.

Insights reads scoped coding activity and sessions. Client-reported activity and cost are not billing evidence. Optional generated summaries may describe sensitive work. Add --summaries when logging in to request that category, then explicitly select it in the browser. Missing or stale cached summaries are reported as such; an MCP read never generates new summaries.

Raw prompt captures, provider secrets, arbitrary SQL and writes are not exposed. Responses describe their scope, period and source. Unknown freshness is not a promise of real-time coverage.

Disconnect

Use Revoke under Your connections on the MCP tab to stop future access. Already returned data cannot be recalled. tokamak mcp forget --name org-42 removes local credentials only; it does not revoke the server grant. Connections expire within 30 days.

Direct HTTP clients must support the registered OAuth flow and include X-Tokamak-User-Email on every authenticated MCP request. Use the local bridge when your client cannot send custom headers.

Connect a server with an organization MCP token

A server-side client, such as a Slack bot, cannot complete a browser login. Give it an MCP token that belongs to your organization instead. It belongs to no person and no agent, so it keeps working when people or agents change.

  1. As an organization admin, open Organization settings → MCP and turn MCP on.
  2. Under MCP tokens, create a token. Choose Usage, Insights or both, and an expiry of up to one year. Generated summaries are never available to a token. Wait for the connected applications to load, then explicitly choose Issued to: an enabled application, or No application (organization only). A loading error does not mean there are no applications: creation stays disabled until Retry succeeds. Organization-only tokens remain available after a successful load, including when the list is empty.
  3. Copy the token and the endpoint it shows. You will not see the token again.
  4. Configure the server to call the endpoint with Authorization: Bearer <token>. For a token issued with No application (organization only), omitting a member header makes the token act for the organization. For an application-bound token, follow the member-consent instructions below.

For an organization-only token, in a client that accepts HTTP MCP servers:

claude mcp add --transport http tokamak https://gateway.example.test/v1/mcp   --header "Authorization: Bearer $TOKAMAK_MCP_TOKEN"

An organization-only token's tools read the whole organization by default, or one member with scope: "member" and member_email; they take no user_email. Everyone who can see what the server posts sees that data, so grant only what the server needs.

Answering for the person who asked

For a token issued to a connected application, the server sends the verified member's public account id (usr_…) in X-Tokamak-Act-For. The member must allow that application in Account → Connected applications for the selected organization. Linking/signing in an account is not consent. Member-scoped access is limited by the member's own permissions, their consent scopes and the token's scopes. Keep the application enabled in the organization. Do not omit the acting member header or substitute the legacy email header for an application-bound token. Never take the acting identity from a model or a chat message.

If you switch organizations or accounts while creating a token or changing consent, the dialog is dismissed and a late response is not shown under the new context. The original request may already have completed: return to the original organization to inspect its tokens, and revoke a token if its one-time secret was not saved.

Legacy email access for organization-only tokens

Where the organization still allows legacy email access, a server that knows who it is answering, such as a Slack bot that reads the asker's email from Slack rather than from the conversation, can send that person's email in X-Tokamak-User-Email with the token. The request then acts for that member: "my usage" is theirs, and they see the organization or another member only if their own role allows it. A member's access through the token never exceeds the token's own. An email that is not a verified, active member of your organization is refused. Only send the header from code you control. Never pass on an email that a user or a model typed.

If your people sign in with one domain and appear elsewhere with another (for example, a Google Workspace alias domain, so [email protected] is also [email protected]), list both under Same people on these domains on the MCP tab. A request naming [email protected] then acts for the member [email protected], but only when exactly one member matches. List only domains where a name always means the same person. A token stops working when it is revoked or expires, or when MCP is turned off for the organization. Its calls appear in MCP activity under the token's name.

On this page