All concepts
11 — Concept

The MCP server

Claude and ChatGPT connect to an organisation’s tools as the person who signs in, with that person’s role and permissions — off until an admin turns it on, signed in through the app’s own OAuth server.

An AI client, acting as one person

From kit 0.41.0 the app is an MCP server. Claude (claude.ai, Claude Desktop and Claude Code) and ChatGPT connect to it at /mcp, and each connection acts as the one person who signed in, in one organisation, with that person's role and permissions and nothing more. A knowledge-base document shared with a group stays invisible to someone outside the group, exactly as it is in the browser. Support users cannot connect at all, and a client never carries a platform admin's reach, even when the person who connected it has it.

Nothing about the person is cached on the connection. Every call reads their membership, role, groups and block status again, so a role change applies to the next call and a removed member's connections are revoked in the same transaction as the removal. The kit's own tools are the knowledge tools chat already uses: search, list and read documents, and look up facts. A test calls each one as an outsider and proves a group-only document, its facts and its entities do not exist for them, and that every answer matches what chat would give the same person.

Off until the deployment ships it and an organisation turns it on

The server is behind the environment-gated mcp feature flag. Until a deployment lists mcp in FEATURES_ENABLED, every MCP and OAuth path answers 404. Once it ships, each organisation's owners and admins still have to turn it on, at Settings → MCP, where the rest of the controls live:

SettingWhat it does
The switchoff by default; turning it off suspends every connection without revoking it
Server URLthe organisation's own /mcp/t/<slug> under multi-tenancy, /mcp under single, with setup snippets for Claude and ChatGPT
Who can connecteveryone, admins only, or chosen groups
Exposureread-only tools (the default), all tools after a confirmation, or a ticked selection
Toolsgrouped by provider, each with a read-only or writes badge and its 30-day call count; a tool that cannot reach a client is greyed with the reason
Connected clientsevery live connection: the person, the client, read or read-and-write, last used, with Revoke and Revoke all

Each person also sees their own connections, in every organisation, under Profile → Connected apps, and can revoke any of them there.

zsh — connecting Claude Code
curl -si -X POST https://app.example.com/mcp | head -1HTTP/2 401claude mcp add --transport http acme-tools https://app.example.com/mcp/t/acme
Then /mcp inside Claude Code opens the app's own sign-in in the browser.

OAuth 2.1, with the app as its own authorization server

A client never holds an API key, a session cookie or a CLI key: /mcp refuses all three. It holds an OAuth access token, issued by the app itself from tables in Postgres. The token lasts an hour, is stored only as a hash, belongs to a grant for one person, one organisation and one client, and is accepted only on the exact URL the grant was made for.

Clients are identified by a client metadata document (CIMD): the client id is an https URL, and the app fetches the JSON document behind it to learn the client's name and redirect addresses. That fetch only goes to a public host on the default port, follows no redirect and reads at most 5 KB. There is no dynamic registration and no list of pre-registered clients. PKCE with S256 is mandatory, an authorization code is single-use and lives sixty seconds, and a refresh token rotates on every use.

Sign-in is the app's own login page, so every sign-in method, the single-sign-on policy, the sign-up mode and blocking apply unchanged. The consent page then shows the client's name beside the host its id was verified on, the organisations where the person may connect, the scopes and the tools. There are two scopes: mcp:read and mcp:write. A tool that writes needs mcp:write as well as the person's own permission; a read-only connection that calls one is refused with 403 insufficient_scope, and the client asks the person to consent again.

Why the app's own login. An MCP connection is one more way for a person to act in an organisation, so it should be admitted by the same rules as every other way. Reusing the login page means an organisation that requires single sign-on, a deployment that is invite-only and a blocked account all behave on the OAuth path exactly as they do in the browser, with no second copy of those rules to keep in step.

Limits and the call log

Each request carries one call: a batch of JSON-RPC messages is refused, and no request is held open. Calls are capped per minute per connection (60), per person across all their connections in the organisation (120) and per organisation (600), checked in that order; each cap is a setting. A client over a cap gets a tool error telling it when to retry, not a 429. A model called by a tool is billed and capped as it is from chat, under the organisation's own limits.

Every result opens with a line telling the client's model that it is data, not instructions, and is cut off at 60,000 characters. Each call is logged with who made it, through which connection, which tool, the outcome and how long it took, never its arguments or its result. The log is kept for 90 days, and each call is also a span in the trace.

One tool list for chat, agents and MCP

There is no separate MCP API to build. A tool is declared once and serves three surfaces: the chat panel, agent runs and the MCP server. surfaces keeps a tool off any of them (absent means all three), an optional mcp block sets the title and hints a client shows, and toolsFor(surface, ctx) is the one filter every surface calls. A tool marked as having side effects needs mcp:write and is hidden under the default read-only exposure. A tool with no handler, or one that needs a person's approval, is never offered over MCP.

So a plugin's tools reach MCP clients with no extra wiring: the plugin lists them in tools, with no route and no authentication of its own, and they appear under the plugin's name in Settings → MCP. The analytics plugin offers its cube queries this way, to MCP clients and agent runs but not to chat.

From kit 0.47.0 a tool also answers one governance question: can it send your data outside your organisation, by email, a webhook, a web request or by publishing a page? That is its egress field, answered from what the handler itself does; calling the app's own models is not egress. A second field, readsContent, says whether it hands organisation text to a model. Every kit tool answers both. From kit 0.49.0 the egress answer is required: a tool without it fails the gate and pnpm plugin check, and at run time chat, agent runs and MCP refuse the whole tool list rather than run it. A copy upgrading to 0.49.0 answers its own tools through one decision, pnpm kit:upgrade --decide tool-egress, which proposes an answer for each from what its handler does and asks the person to confirm; a published plugin's tools are answered by the plugin's own release.

From kit 0.51.0 an organisation's autonomy limit on a unit reaches MCP: that unit's tools that write or send data out stay listed but answer a 403 autonomy_limited tool error, because a connected app cannot stop to ask a person. A tool with a URL source rule, such as a page reader, answers 403 egress_refused over MCP: the kit has no record of what the person typed or which search returned the URL, so it cannot show the URL came from either. Both errors are in the call log. MCP is not judged by the trifecta, because the connected app runs its own loop.

Adding a tool with a coding agent

The kit ships an /rf-mcp skill that turns the server on for a deployment, adds a tool to the app or a plugin, connects Claude or ChatGPT to a local instance through a tunnel, and maps every 401, 403 and missing tool to its cause. When the agent opens a tool file, a rules file loads with the checklist for a safe tool: the tenant and the person come from the tool's context, never from its arguments; group-visible rows are read through the same visibility helpers the core tools use; every tool that writes, sends or charges says so; and no description names a brand.

The test helper callMcpTool connects as a given member and calls a tool over the real /mcp, tokens and exposure included. Every tool owes three cases: a member of a second organisation sees none of the first's rows, a member outside a group does not see that group's rows, and a write tool is unlisted under read-only exposure and refused to a read-only token.

Under your name, not the kit's

Everything a client and its user see carries the deployment's own APP_NAME and the organisation's name: the server's name, its instructions, the consent page and every error. A test sets the app name to "Acme Tools" and fails if "Rocketflare" appears in any response, and pnpm plugin check warns on it in a plugin tool's title or description.

What it does not do yet: only clients that publish a client metadata document can connect, which today means Claude and ChatGPT (Cursor only supports dynamic registration, and VS Code is untested). ChatGPT cannot reach a local wrangler dev, so test it on staging. The server offers tools only, with no resources or prompts, and renaming an organisation's slug breaks connections made on its URL until the client reconnects.