MCPs: catalog, activation, and who may add one¶
An MCP must be in the host catalog — version-pinned, vendored, checksummed — before any agent can activate it (Architecture § MCP catalog vs drop-to-add). Authoring the catalog is operator-scope; activating a catalogued MCP is self-scope. Nothing in the manifest schema marks an MCP operator-only — what gates one is where its credential has to live in the secret store.
The verbs and their scopes¶
| Verb | Scope |
|---|---|
mcp catalog add, upgrade, remove |
operator — root or an admin: true agent |
mcp add <mcp> <agent>, mcp remove <mcp> <agent> |
self — the target must be the caller, so self is the usual argument |
mcp catalog list, catalog browse |
read-only, runs locally, ungated |
mcp wired <agent> |
own agent locally; a peer needs admin |
mcp read <mcp> <tool> [<agent>] |
own agent locally; a peer needs admin |
mcp call <mcp> <tool> [<agent>] |
own agent locally; cross-agent is root-only |
Those are all of them. There is no per-agent CLI-tool tier beside this: a capability is
either a host-level binary the agent reaches through plain Bash (zk, anydoc, git,
python), or a catalog MCP wired with mcp add. agentctl tool reaches only the host CLI
tool catalog — tool catalog list and tool catalog add — and grants nothing to an agent.
mcp read and mcp call are one command under two names: the same parser, the same
flags, the same gate. Neither is read-only. The only difference is the table above: mcp
read is on the privileged-read plane, so an admin agent can relay it cross-agent, and it
then runs as the TARGET agent with that agent's credentials.
Both refuse a tool its manifest declares risk: block, and both narrow a short list of
argument keys that reach the local disk or override a policy:
$ agentctl mcp call google-workspace gmail_delete_email --params '{"messageId":"18f"}'
mcp call: google-workspace.gmail_delete_email is declared `risk: block` in its mcp.yaml — it is not reachable from a turnless caller
mcp add and mcp remove are mutating: the invocation is forwarded to agentd, which
checks the caller's uid from SO_PEERCRED and re-execs the verb as root. See agentd and the
unit model.
What mcp add actually does¶
In order:
- Gate on credentials. The secret render runs if the manifest declares
auth: env, or any ofrequired_env/user_env/optional_env. It rebuilds both env files from the secret store, then refuses the wire if anyrequired_envkey does not resolve. The refusal prints the exactagentctl secret set …line per missing key.--forcedowngrades that to a warning and wires anyway; the unit'sEnvironmentFile=-tolerates the gap, so the MCP starts and fails at the first call. - Render the units. A
.socketand a templated@.serviceunder/etc/systemd/system/, whose content depends onscope:. Staged MCPs (npm,uvx) vendor their code into a deploy dir at this point. - Wire the client. A project-scoped
mcpServersentry in the agent's runtime config, pointing at the socket throughmcp-proxy.sh. Anhttp-transport MCP skips the socket and gets a direct{type: http, url}entry with{KEY}placeholders substituted from the agent's secrets. - Record the ledger delta. An add delta on the
toolscategory ofagents.d/<agent>.yaml— not a resolved list. See Config layering § Membership.
Both runtimes take this path, with one substitution at step 3. Steps 1, 2 and 4 are
identical: the same secret render, the same socket and unit pair, the same scope rule, the
same tools: key. Only the client config file differs — ~/.pi/agent/mcp.json on pi,
~/.claude.json on claude.
Two consequences worth knowing:
tools:carries exactly one population — MCPs — on both runtimes. A name intools:is a catalog MCP, resolved straight against the MCP catalog. A host-level binary is not in this key at all: it is installed on every host and reached through plain Bash, with no ledger entry and no per-agent activation.mcp.jsoncarries${KEY}references, never secret values. pi resolves them from the bridge process's environment, which systemd populates from the agent'sEnvironmentFile.
Either config file is read only at process start, so the MCP is not live until the agent
restarts. mcp add says so on its last line.
apply keeps it current. It content-diffs the catalog against the deploy dir on every
run, re-vendors when the dependency inputs change, and bounces the socket — without
restarting the agent.
Credentialed and uncredentialed MCPs¶
The manifest declares four fields that matter here:
| Field | Values | Meaning |
|---|---|---|
auth |
none | env | oauth |
how the server authenticates |
required_env |
key names | activation is refused unless each resolves |
user_env |
key names | per-agent keys, stored under agents.<name> |
optional_env |
key names | rendered if present; never gates |
Of the 22 shipped MCPs, six carry no credential at all (auth: none, empty required_env):
browser, git, agent-message, slack, teams and telegram. Everything else speaks to
somebody's account.
The deb defaults are browser plus the MCP for the agent's own channel, and never a second
channel's:
--channel |
default MCPs |
|---|---|
webview |
browser |
telegram |
browser, telegram |
teams |
browser, teams |
slack |
browser, slack |
A credentialed MCP cannot reach a default set — the catalog tests fail the build on one.
auth: oauth is a two-part credential and the parts have different owners. The client
registration (GOOGLE_CLIENT_ID/GOOGLE_CLIENT_SECRET, or ms365's client and tenant ids)
is one app registration for the host, written to /etc/agentctl/env/google-client.json,
0640 root:agents. The user token is per agent: mcp add creates a 0700 token dir in
the agent's home (~/.google-workspace, ~/.ms365-mcp) and the agent fills it with
agentctl login <provider> self, a self-scope verb.
The cockpit's Connections panel is the same verb, reached without a terminal. The
per-agent right panel's "Connections" section lists one card per wired MCP whose manifest
declares auth: oauth, derived from the catalog rather than from a hardcoded list. Four
providers declare it today:
| provider | catalog MCP | token dir |
|---|---|---|
google |
google-workspace |
~/.google-workspace |
ms365 |
ms365 |
~/.ms365-mcp |
atlassian |
atlassian |
~/.atlassian-mcp |
powerbi |
powerbi |
~/.powerbi-mcp |
claude never appears here: that is the agent's own Anthropic account login, a separate flow
covered in Logging an agent in § A claude agent in the
cockpit.
Pressing Connect calls POST /api/connections/start, which runs agentctl login
<provider> <agent> --json server-side and opens the returned authorize URL in a new tab —
the URL is never rendered into the DOM or written anywhere else. This is how an agent gets an
OAuth token without pasting an authorize URL into a chat message, which it must never do. A
Disconnect button calls POST /api/connections/disconnect, which runs login <provider>
<agent> --clear --json and deletes the provider's local credential-state directory. Both are
ordinary per-agent cockpit routes behind the same identity gate as /api/snapshot.
Diagnostics. The status pill behind each card is agentctl login <provider> self --status
(or the agent's own name in place of self), the same machine-readable probe the panel polls
after a Connect press. It prints one word and exits:
| output | meaning |
|---|---|
logged-in |
a per-agent token cache is present |
needs-login |
no credential — press Connect, or run login <provider> self |
managed |
the credential is shared host infrastructure, not this agent's own token. powerbi with POWERBI_MCP_AUTH_MODE=client_credentials reports this |
Where the credential lives is the admin gate¶
A required_env key resolves from the agent's own shard first, the shared shard as
fallback. Which place a given key can be written to is the admin-vs-self boundary, and it is
enforced on the secret verb, not the mcp verb:
| Store location | Written by | Rendered into | Readable by |
|---|---|---|---|
agents.<name>.KEY |
secret set KEY --agent self — any agent, for itself |
/etc/agentctl/env/agent-<name>.env, 0640 root:<name> |
that one agent |
top-level KEY (shared) |
secret set KEY with no --agent — operator only |
/etc/agentctl/env/mcp-shared.env, 0640 root:agents |
every agent on the host |
A bare secret set (no --agent) targets the shared store and is refused for a non-operator
in as many words:
denied: agent "ana" may only manage its OWN secrets — pass --agent self; shared/host secrets are operator-only
So:
- An agent can self-serve any MCP whose credential it can mint under its own identity.
githubisscope: per_user: each agent sets its ownGITHUB_PERSONAL_ACCESS_TOKEN --agent <name>and then runsmcp add github self.exadeclares the same shape viauser_env.browser,gitandagent-messageneed no secret. - An agent cannot enable an MCP whose credential is an organisation's, held once for the
host:
perplexity'sPERPLEXITY_API_KEY,notion,leanix, the OAuth client registrations. The preflight refuses because the key is not in the agent's own shard and it has no way to put one there. Once the operator seeds the shared shard, the MCP self-serves for every agent on the host.
Two consequences:
- Seeding a shared key is a host-wide grant.
mcp-shared.envis0640 root:agents; every agent's process environment carries it and every agent's shell can read the file. A credential two agents must not both hold goes in a per-agent shard. --forceis not a way around this. It skips the refusal, not the credential: the MCP wires with the key absent and its first call fails.
Two shared keys are subtracted from that render regardless of the store's contents —
AGENTCTL_HOST_OP_SECRET and AGENTCTL_HOST_OP_GRANT_SECRET, which sign root executions. See
Security § Secrets.
scope: shared and scope: per_user¶
scope: decides which unit pair gets rendered:
per_user |
shared |
|
|---|---|---|
| socket | /run/mcp/<name>-<agent>.sock, SocketMode=0600, SocketUser=<agent> |
/run/mcp/<name>.sock, SocketMode=0660, SocketGroup=agents |
| service | User=<agent>, HOME= the agent's home |
no User= line — it runs as root |
| env | agent-<agent>.env, plus mcp-shared.env when auth: env |
mcp-shared.env when auth: env |
| teardown | on that agent's mcp remove |
only when the last agent drops it |
A shared-scope MCP is a root process behind a socket every member of the agents group can
open. One agent activating it makes the socket reachable by every agent on the host, whatever
their own tools deltas say. Use shared only for a stateless server whose whole input is in
the request; anything that touches the filesystem or an identity is per_user. Four of the 22
shipped MCPs are shared — image, leanix, notion and perplexity — and the other 18
are per_user.
No verb consults scope: for authorization. Read it before assuming that "agent A has this
MCP wired and agent B does not" is a boundary.
codemode: how a pi agent calls a tool¶
On the pi runtime the model does not call tools one at a time. It writes JavaScript, which runs in a sandbox that can call tools, and only the script's output and return value enter the model's context. Nested tool results do not. Every catalogued MCP on a pi agent arrives this way by default; a manifest has to opt out.
A script reaches, in one run:
| What a script may call | Condition |
|---|---|
every codemode and deferred MCP tool |
whether or not it is active |
every direct tool, built-ins included — bash, read, edit, write |
while it is active |
So a shell command and several MCP calls belong in one script, which costs one top-level tool call and returns one result. Three things a script does that separate tool calls cannot:
- Batch independent calls concurrently (
Promise.allSettled) instead of serially. - Chain a call whose arguments come from the previous result, with no round trip between.
- Filter a large result down to the part that matters, so only that part is returned.
Nested calls run through the same tool pipeline as a top-level call, so argument validation
and the risk: gate apply identically. The sandbox has no network, no filesystem and no
module loader: it reaches outside only through the tools above, and bash is one of those
tools rather than something the script shells out to on its own.
exposure: — whether a pi agent's model sees a tool directly¶
An MCP tool is codemode by default: it is not declared to the model, which reaches it
by writing a script, and the top-level tool call is codemode with the MCP tool's own name
only inside that script. A manifest opts out of that default with one of two optional
top-level keys:
| key | shape | values |
|---|---|---|
exposure |
a scalar, for every tool the server offers | codemode | deferred | direct | hidden |
tool_exposure |
a flat <tool>: <exposure> map, overriding per tool |
the same four |
exposure: direct
tool_exposure:
send_message: direct
In the shipped catalog the channel servers (slack, teams, telegram) declare direct,
and agent-message declares it for send_message alone. Everything else is on the default.
Both keys are read only by the pi runtime — the claude runtime declares every MCP tool to the
model unconditionally and ignores them. Neither reaches a built-in tool (bash and the
rest): a built-in is not an MCP tool and stays declared to the model.
direct and codemode are not alternatives. direct controls one thing only: whether the
model is handed the tool as its own declaration. A direct tool stays callable from inside a
codemode script while it is active. hidden is the only value that takes a tool off both
paths.
Declare direct for a tool whose output is a message to the owner. The cockpit and the
owner-facing outbound renderer both key on the top-level tool name to paint a message bubble
instead of a tool chip, so an owner-facing tool left on codemode is not rendered as a
message.
Neither key is a security control: the risk: gate applies identically to a direct call and
to one made inside a codemode script.
What an agent can self-serve, in full¶
Self-scope, no operator needed:
agentctl secret set <KEY> --value <v> --agent self # its own shard
agentctl secret get <KEY> # rewritten to --agent self
agentctl mcp add <mcp> self # activate a CATALOGUED MCP (same verb on both runtimes)
agentctl mcp remove <mcp> self
agentctl login <provider> self # its own oauth token (cockpit: the Connections panel does this, see above)
agentctl apply self
agentctl agents restart self
Operator or admin agent only:
agentctl mcp catalog add <name> --npm <pkg@ver> # pin a NEW MCP into the catalog
agentctl mcp catalog upgrade <name> --to <ver> # move a pin
agentctl mcp catalog remove <name>
agentctl secret set <KEY> --value <v> # the SHARED shard — no --agent
agentctl mcp add <mcp> <some-other-agent>
agentctl mcp read|wired <mcp> … <some-other-agent>
The operator curates what exists and holds what is shared; the agent chooses from it for itself. An agent cannot introduce a new server, move a version pin, grant itself a credential it does not already own, or touch a peer.
The gate model is not this boundary¶
Everything above is authorization — who may wire what. The runtime permission gate is
separate: for an irreversible tool call on an MCP that is already wired it either asks a
human (risk: ask) or refuses outright with no approval path (risk: block). That gate is
generated from each manifest's risk: block and matches tool names and command strings.
Both tiers are live in the shipped catalog:
| tier | declared by | tools |
|---|---|---|
ask |
ado, agent-message, atlassian, github, gitlab, google-workspace, imap, ms365, notion, powerbi, ynab |
11 manifests |
block |
atlassian (4), google-workspace (9), ms365 (13) |
26 tools |
google-workspace and ms365 additionally declare api_method_tiers: {delete: block},
which refuses a raw DELETE sent straight at one of the vendor API hosts the manifest names
— a call that names no tool, so no per-tool rule can see it.
A block declaration is unappealable on every plane: pi renders it as a hard deny, claude as
a never-permitted policy fragment, and mcp read / mcp call refuse it outright. An agent
that reads its own token out of its environment and calls the vendor's REST API with curl
matches nothing. The full treatment, including the raw-api-access mitigation and its
limits, is in Security § The human floor on sends and
deletes.
Traps¶
- The first apply after a change to the default MCP set restarts every claude agent on the
host, because
~/.claude.jsonis read only at start. mcp catalog removerefuses while any agent still has the MCP wired, and names them.catalog removeon a shipped (deb) item is refused outright — it would return on the nextapt upgrade.agentctl defaults add tools <mcp>validates against the whole MCP catalog, not against the channel-conditional deb default, so a host overlay can bless any catalogued MCP for every agent on the host. See Config layering.mcp removeon a shared MCP leaves the socket running if any other agent still has it, and says which. The agent's own access ends (itsmcpServersentry is gone); the socket's0660 root:agentsmode does not change.mcp catalog adddefaults to the repo overlay, not to/var/lib/agentctl/catalog. The runtime catalog is used only on a host with no repo, or with an explicit--into. Both lose to the overlay on resolution.