@sigrun/ext-mcp
v0.5.0
Published
MCP extension for sigrun (pi-durable): registers MCP server tools as <server>/<toolname> tools
Readme
@sigrun/ext-mcp
Register MCP server tools as pi-durable tools, named <server>/<tool>.
Config: the extension's settings (<configDir>/settings/sigrun-mcp.json,
edited in Settings → sigrun-mcp). Each entry under "servers" names an MCP
server — stdio ("transport": "command") or remote ("transport": "url"):
{
"servers": {
"github": {
"transport": "command",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"exposure": "codemode",
"timeout": 120
},
"search": {
"transport": "url",
"url": "https://mcp.example.test/mcp",
"headers": { "Authorization": "Bearer <token>" },
"exposure": "direct"
}
}
}Header and env VALUES are secrets: on save they move to the secrets store
(servers/<name>/headers/<Header>, servers/<name>/env/<KEY>) and the file
keeps only the names. Other extensions read the registry through the
mcp.servers published hook (name, resolved enabled, exposure,
toolExposure), answered fresh from settings on every call.
Upgrading from mcp.json: on the first boot with no servers in
settings, an existing mcp.json (SIGRUN_MCP_CONFIG or
<configDir>/mcp.json) is imported once — secrets into the secrets store,
the disabled alias folded into enabled, pi's codemode-deferred
normalized to codemode — with a log line and a primary-admin notice. The
file is never read again; when settings already have servers, an mcp.json
is ignored with a log line.
The sigrun-ext-mcp oauth <server> CLI reads the server from the same
settings file plus the sigrun-mcp secrets section (config dir resolution:
SIGRUN_CONFIG_DIR → $XDG_CONFIG_HOME/sigrun → ~/.config/sigrun), and
stores tokens as <configDir>/mcp-tokens.json (0600). On first read or
write, an existing legacy store beside the resolved mcp.json is renamed
to that location; an already-present new store wins.
Server fields
command,args(stdio) — how to spawn the server.url(remote) — the server endpoint (http/https). Streamable HTTP is the transport; a legacy HTTP+SSE server (2024-11-05 shape — GET stream +endpointevent + message POSTs) is adopted automatically, so no adapter process is needed.headers(remote) — extra request headers (auth etc.), sent on every request. For per-user servers, configuredAuthorizationis removed; only that user's scoped token supplies it.env(stdio) — extra environment variables for the child process. For per-user servers, configuredMCP_ACCESS_TOKENis removed; only that user's scoped token supplies it.credentials—"user"(default) or"shared". User-credential servers start per user in the host's service jail; remote user servers connect with the user's scoped token. Existing installs needing one system-wide server must explicitly select"shared".sharedAuthority— required, non-empty one-line reason whencredentialsis"shared". Shared MCP servers hand every permitted user's agent the admin's credential for that service; the settings section displays this reason and warning beside the server.users— optional string allowlist for a shared server. Only those users may call its tools. A non-empty list is valid only withcredentials: "shared"; an empty list means unset (all users) on any server. To deny everyone, setenabled: false. Ownerless calls fail closed.availability—"all"(default) or"opt-in". The per-user settings section stores each server's enablement as a flat boolean keyed by its bare server name."all"starts enabled;"opt-in"starts disabled.enabled(defaulttrue) — skip the server entirely whenfalse. The legacydisabledalias folds intoenabledon import/read; a server that spells out both contradictorily is a config error and fails loudly.timeout— per-request wire timeout in seconds (default60). A request that gets no reply by its deadline rejects. A server that keeps sendingnotifications/progressfor a pending request never dies at the deadline while it keeps reporting work — progress resets the deadline.exposure— how the server's tools register (see below). Default"codemode".toolExposure— per-tool overrides ofexposure: an object mapping tool names (exact) or*-globs (e.g."get-*") to exposure words. An exact name always wins; among matching patterns the FIRST one in config order wins.oauth(stdio) — the authorization-code (PKCE) flow block. Shared servers usesigrun-ext-mcp oauth <server>and the file token store. Per-user servers usePOST /v1/ext/sigrun-mcp/oauth/<server>/start, thenPOST /v1/ext/sigrun-mcp/oauth/<server>/completewith{ "redirectedUrl": "<full redirected URL>" }; the CLI refuses these servers so their credentials cannot enter the shared store.
Per-user PKCE state stays in memory for ten minutes and is scoped to the
authenticated user and server. Completion stores only the raw access token in
that user's token:<server> secret. It then retires and reconnects that
user's catalog connection. Core owns the process lifecycle: releasing the last
handle arms idle-stop, so a still-live child keeps its original environment
until that timer fires or it crashes; the extension cannot force a relaunch
through the host contract. An already idle-stopped server launches fresh on
the next activation and reads the new token immediately.
userServers is the separate admin policy for user-supplied servers:
"none" (default), "remote", or "all". It is distinct from the admin
catalog's credentials and availability fields above. Catalog names
starting u_ are reserved for those user-supplied servers and rejected.
When enabled, the Your MCP servers part of the extension's settings page
accepts a JSON object under the servers key (the declared per-user
schema). Entries use the same validation rules as the operator registry;
a user server name may not start with u_. Its tools publish only to that
user as u_<server>/<tool>. "remote" permits URL servers and ignores stdio;
"all" permits URL servers too. A live policy change reconciles every active
user, retiring disallowed connections and removing their tools without a
restart: lifecycle events re-read the policy from settings. A catalog server
literally named servers is rejected because it would shadow this settings
namespace.
Named limitation — all and user-supplied stdio: sigrun declares per-user
services statically at load and passes no server name to UserService.start.
Consequently a dynamic, named user-supplied stdio service cannot be launched.
Under "all", such an entry is reported as a configuration error naming the
server; its command is never spawned in sigrun's process, and no tools are
published. "all" does not make user-supplied stdio functional.
Exposure: how tools reach callers
On pi-durable 1.2.0 semantics, "exposure" decides who can call a server's
tools:
| exposure | registration | who can call |
| ----------- | ------------------------- | ------------------------------------- |
| codemode | callers: ["tools"] | scripts only (never model-offered) |
| deferred | deferred: true | the model, once tool_search loads it |
| direct | normal | the model (offered when in the set) |
| hidden | not registered | nobody (config entry kept) |
The codemode-deferred word is kept as an alias for codemode (pi compat).
The default flip — a breaking change
Before 1.2.0, an mcp.json server entry with no exposure field had its
tools offered to the model. Now the default is "codemode": a
default-exposure server's tools are callable by scripts (codemode), never
offered to the model directly. To restore the old behavior, set the server
(or the tool, via toolExposure) to "exposure": "direct":
{ "exposure": "direct" }The mcp_servers system-prompt section lists codemode/deferred servers when
their discovery tool (codemode, tool_search) is offered in the request;
when such servers exist but their tools are unreachable, it appends one
notice line naming the count and the Settings → default tools fix.
Tool naming: <server>/<tool> (decision)
Tools keep the existing <server>/<tool> shape rather than upstream pi's
mcp__<server>__<tool>:
- The upstream codemode section groups tools by
CodemodeNamespace.prefix(longest match wins), and the namespaces are config-side — the host passes the groups, so any naming can namespace trivially: ours groups asprefix: "<server>/"with no rename at all. - The name-addressed surface makes per-tool replacement and
toolExposurepatterns readable ("github/*"), and the existing wire name is already deployed in configs and scripts.
No section-rendering compat requires the upstream spelling; the decision is recorded here per the spec's open item.
Replacement semantics
Replacement works by not installing ours and installing yours: the
name-addressed tool surface (<server>/<tool>) makes per-name replacement
trivial. Co-installing this package with another that registers the same
tool names shadows silently (pi-durable resolves cross-extension duplicates
last-selected-wins) — do not co-install. Sigrun's extension loader
(made the shadowing visible at boot: it console.warns once per duplicate
tool name, naming the extensions and the last-wins resolution) but the
warning changes nothing: last-wins stands. Replace, don't co-install.
