MCP
Register local and remote MCP servers from JSON files, expand credentials from the shell or the vault, gate tools by risk, log in to servers that need OAuth, and serve theuth itself to other MCP clients.
theuth is an MCP client. Drop server definitions as JSON into
<data_dir>/mcp/; the directory is watched, each server is connected, and
its tools register beside the built-ins under their own names. Risk gates and
OAuth logins live beside the files. theuth is also an MCP server, off by
default: see theuth as an MCP server.
Files and shapes
Only files directly in <data_dir>/mcp/ with a .json extension are
read, sorted by path. Any file name works; mcp.json has no special
meaning. Subdirectories (including repos/) are never scanned. Three shapes
are accepted, detected structurally (an entry is an object with command or
url):
// one bare entry: the server is named after the file stem (filesystem.json → "filesystem")
{ "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/me/projects"] }// named entries at the top level
{
"filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/me/projects"] },
"grafana": { "url": "https://grafana.example.com/mcp", "headers": { "Authorization": "Bearer {{secret:grafana}}" } }
}// one wrapper key of any name: the shape Claude Desktop, Cursor and OpenCode files use
{ "mcpServers": { "github": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "$(gh auth token)" } } } }Fields per entry:
| Field | Transport | Meaning |
|---|---|---|
command | stdio | executable as a string, or an array whose first element is the executable (OpenCode style) |
args | stdio | string array, appended after an array command |
env (or environment) | stdio | object of string values; keys are not expanded |
cwd | stdio | working directory; a relative path resolves against <data_dir>/mcp/, so "cwd": "repos/<name>" runs from a clone |
url | HTTP | streamable HTTP endpoint; presence of url is what selects the remote transport |
headers | HTTP | object of string values |
oauth | HTTP | {client_id, client_secret, scopes, redirect_uri}; see OAuth below |
enabled: false or disabled: true | both | the entry is skipped |
A type field (sse, http, stdio) is accepted and ignored: everything
remote is streamable HTTP. Non-string values inside args, env and
headers are dropped silently. If two files define the same server name the
first file by path wins and the log says duplicate mcp server name.
Expansion of credentials
At connect time the harness expands command, each args element, each
env value, url and each headers value, in this order:
{{secret:NAME}}(and{{secret:NAME:-N}}for an older version) is filled from the secrets vault. An unknown name fails the connection withunknown secret NAME; secret_list shows the names.- If the result still contains
$or a backtick, it is run through your login shell (/bin/shwhen none) as an unquoted heredoc, so$VAR,${VAR:-default},$(cmd)and backticks expand; quotes stay literal and\$escapes. A failing command is logged with the unexpanded string and the value is kept as written. On a platform without a login shell the value is kept as written with a warning.
cwd is never expanded. Expansion happens once per connection, not on every
reconcile, and nothing expanded is written back to the file.
{
"github": {
"command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "{{secret:github}}" }
},
"postgres": {
"command": "uvx", "args": ["mcp-server-postgres", "${DATABASE_URL}"]
},
"linear": {
"url": "https://mcp.linear.app/mcp",
"oauth": { "scopes": ["read", "write"] }
}
}When the harness shows an entry (the /mcp menu, the desktop Settings page),
values after credential-looking flags (-p, or a flag containing token,
secret, pass, key, auth, credential, bearer) are masked
<redacted>, env is listed by name only, headers are omitted and URLs are
reduced to scheme, host, port and path.
Tool names
A server's tools register under their remote names. When two running servers
offer the same name, or a built-in already has it, each registers as
<server>__<name> instead; the prefix drops again when the clash goes away,
so a name can flip when a server is turned off. A remaining clash hides the
tool with mcp tool <name> from <server> hidden: clashes with <owner> in the
log. The /mcp menu shows as <name> beside a tool whose registered name
differs.
Hot reload
A filesystem watcher on <data_dir>/mcp/ (non-recursive) feeds a reconcile
after a 300 ms debounce. Added or changed entries connect (20 s connect
timeout, error no response within 20s), removed or changed entries drop
their child process and tools, and the gates file is re-read on every pass. A
file with invalid JSON is skipped with mcp file skipped in the log and its
servers disappear; other files still load. The harness's own writes
(/mcp add, gate changes) go through a temp file and rename, so the watcher
never sees a half-written file.
The TUI status line shows mcp <connected>/<total> and connecting … or
N failed; the /mcp rows show ● connected, ○ login required,
○ not connected or ○ off.
Which machine runs a server
mcp/*.json replicate to every engine of your mesh,
but a server runs only on its home: the machine it was added on (/mcp add, the UI, add_mcp_server), or for a hand-written file the machine that
wrote it. Homes live in <data_dir>/mcp/homes.yaml, which replicates too;
the log says mcp: <name> home is <machine> once per server. Other machines
list the server as not running here (home is 333) and its tools do not
appear there.
Settings › Tools › MCP shows each server's home and its state on this
machine, with Run everywhere (start it on every machine; for servers
whose runtime is installed everywhere, or remote URLs), Only on <home>,
Move home here and Turn off here.
A start that fails because the command is not on this machine shows not installed here (<command> is not installed on <machine>); every failed
start is retried after 30 s, doubling up to 30 min, and immediately when its
entry changes. The log gets one line per change of state, not per attempt.
A server homed on a machine that is no longer paired runs on one machine
still in the mesh until its home is paired again; its home is not rewritten
(Move home here makes the move permanent). Edit homes.yaml by hand with care: while it does not parse,
homes stay as they were and nothing is written to it.
Upgrade note. After the upgrade, servers run only on their home machine (for existing files, the machine that last wrote them) unless Run everywhere is set. Set it once on servers that work on every machine.
Risk gates: mcp/config.yaml
Every MCP tool gets a risk class for the approval gate.
Default: the server's annotations (readOnlyHint: true is read_only,
destructiveHint: true is destructive, otherwise mutating, which prompts
under the default policy). Override in <data_dir>/mcp/config.yaml:
servers:
kubernetes:
risk: read_only # every tool of the server unless a tool line says otherwise
tools:
pods_delete: destructive
helm_uninstall: off # off = not registered at all
teams:
risk: off # server not even startedValues are read_only, mutating, destructive, off; a tool line beats
the server line, which beats annotations. Unknown fields fail loudly; an
invalid file logs mcp gates invalid (values are read_only | mutating | destructive | off), all default and every tool falls back to annotations.
The /mcp menu writes this file (comments are not preserved): Space cycles
annotations → read_only → mutating → destructive, Backspace resets the
line, Enter on a running server asks s (hide for this chat) or a (off,
written to the file). Set risk: read_only once on a server you trust and
its tools stop prompting.
On desktop the same switches are in a chat's ⋯ menu › Tools… (or /tools,
/mcp): Off here hides a server's tools from that chat and its
subagents, a tool's switch hides one tool, Off always writes off. The
composer's tools button beside + has the same per-chat checkbox for each
server plus a switch that turns the server on or off for every chat (off
writes the off gate and stops it; on clears that gate and starts it). Hides
for one chat are saved with the chat, so they survive a restart and a move to
another machine, and a hidden server stays hidden when it reconnects. The
harness's own tools have the same two scopes by category on the Builtins
tab of that popover and of Settings › Tools (see
Builtins switches).
Remote servers and OAuth
Remote entries use streamable HTTP. If a header named Authorization (any
case) is present the connection is plain and no OAuth is attempted. Otherwise
the client wraps the transport with an OAuth manager whose token store is
<data_dir>/oauth/mcp/<server>.json (written privately, mode 0600, via a
temp file and rename).
A server that answers the initialize request with a 401 challenge is
recorded as ○ login required with the error
<server>: login required (/login <server>). Only you can log in:
/login <server>in the TUI, Signal or Telegram, or/theuth login <server>on Slack, orlon the server's row in/mcp, or the Login action in the desktop Settings.- The harness starts a loopback listener on
127.0.0.1, opens your browser (the TUI also printslogin: open <url>), and waits up to 300 s (timed out waiting for the browser). On success the server restarts logged in. - Without
oauth.client_idthe client registers itself dynamically with the server (client nametheuth). Servers that do not support dynamic registration need a pre-registeredclient_id(andclient_secretif the registration has one). oauth.redirect_uriis for servers that only accept a pre-registered loopback URL, for examplehttp://localhost:8765/callback: the port in it is the port the listener binds. Without it the listener uses an ephemeral port andhttp://127.0.0.1:<port>/callback.oauth.scopesis sent when non-empty.
/logout <server> deletes the token file and restarts the server. /login
with no argument lists providers first, then every MCP server that has an
auth state, marked logged in or login required. A stdio server answers
<name> is a stdio server; nothing to log in to.
Adding servers from the UI
| Command | Effect |
|---|---|
/mcp | menu of servers and tools with status and risk; →/← opens a server's tools |
/mcp add <json> | parse one server from {"name": {...}}, {"mcpServers": {"name": {...}}} or a server object with a name field; it is connected first and written to <data_dir>/mcp/<name>.json only if the connection succeeds |
/mcp add <git url> | git clone --depth 1 into <data_dir>/mcp/repos/<name> (a URL ending in .git or on github.com, gitlab.com or codeberg.org); the reply shows the README head and reminds you to build it and then add an entry with "cwd": "repos/<name>". No entry is written |
/mcp sync (or s in the menu) | git pull --ff-only in every repo under mcp/repos/; servers whose cwd is inside an updated repo restart |
Server and repo names must match [a-z0-9][a-z0-9._-]*. Slack has
/theuth mcp [add <url|json>|sync], Signal and Telegram /mcp [add <url|json>|sync], and
the model has add_mcp_server / remove_mcp_server (destructive) and
add_mcp_repo / sync_mcp (mutating). The user's git binary is used; MCP
cloning reports that git is missing and everything else keeps working.
Security notes
- MCP tools run with whatever access the server process has. A stdio server started from your login shell inherits your environment.
- An MCP tool always consumes
{{secret:…}}placeholders in its arguments, so a call carrying one asks for approval under the default policy and the server, not the model, sees the value. - Unannotated tools prompt. If a server you trust is noisy, gate the server
read_onlyrather than turning approvals off. - Server
stderris logged line by line asmcp stderr: …inlogs/theuth.log.<date>; check it before assuming a configuration error. mcp/*.jsonandmcp/config.yamlreplicate to the other engines of your mesh; keep credentials as placeholders or shell expansions, never as literals, so a token never leaves the vault.
theuth as an MCP server
theuth can serve its own meetings, notes, knowledge, notebooks, sessions, tasks, briefs and calendars to any MCP client (Claude Code, Codex, Cursor, another agent). It is off by default and lives in Settings › Tools › Serve over MCP:
| Control | Does |
|---|---|
| switch | starts or stops the listener and writes mcp_server.enabled to config.yaml; the row shows running on http://127.0.0.1:<port>/mcp |
| Port | mcp_server.port, default 7788 (the engine's RPC is 7777); loopback only |
| Token | the bearer token, shown as its first 8 characters; Rotate mints a new one and ends every open MCP session |
| Copy MCP config | the block for Claude Code, Codex (config.toml), Cursor or stdio (t mcp), token filled in |
| Recent calls | the last 20 audit lines |
mcp_server:
enabled: false # default
port: 7788Transports and auth
-
Streamable HTTP at
http://127.0.0.1:<port>/mcp. The listener binds127.0.0.1only; there is no setting for another address. Every request needsAuthorization: Bearer <token>(otherwise 401); aHostother than127.0.0.1:<port>orlocalhost:<port>and a non-loopbackOriginare refused with 403 (DNS-rebinding guard); any other path is 404. No CORS headers are sent. -
The token is the vault row
mcp.server.token(64 hex characters), created the first time the server starts. It never appears inconfig.yaml. -
stdio:
t mcp(with--data-dirwhen not the default) bridges stdio to the same catalogue for clients that only start commands:{ "mcpServers": { "theuth": { "command": "t", "args": ["--data-dir", "/Users/me/.theuth", "mcp"] } } }It talks to the running engine over its local RPC (the
<data_dir>/tokencredential, not the MCP bearer token), so it needs the engine up but not the HTTP listener. It exits when stdin closes, its parent goes away or the engine connection drops. Both transports return identical results. -
t mcp --session <id>is a different server: the shim an external coding agent gets from theuth (skills,send_messageand text tools), see Delegation.
Tools
44 tools: 25 read-only (annotated readOnlyHint) and 19 that write. Lists
page with limit (1 to 200, default 50) and an opaque cursor.
| Area | Read | Write |
|---|---|---|
| Meetings | meeting_list, meeting_get, meeting_transcript, meeting_summary, meeting_briefs, meeting_search, meeting_speakers | meeting_edit, meeting_set_project, meeting_set_event, meeting_set_template |
| Briefs | brief_search, brief_get, brief_list | brief_put, brief_delete |
| Knowledge | knowledge_search, knowledge_get, knowledge_list | knowledge_put, knowledge_delete |
| Documents | doc_list, doc_markdown | doc_create, doc_set_project, doc_rename, doc_delete (to the trash) |
| Notebooks | notebook_list, notebook_items, notebook_search | |
| Sessions | session_list, session_read | |
| Tasks | task_list, task_get | task_create, task_update, task_move, task_comment |
| Artifacts | artifact_list (metadata) | |
| Calendar | calendar_events, calendar_sources | calendar_source_add, calendar_source_delete, calendar_source_refresh |
What is shared and what is kept
- Private sessions are excluded:
session_listnever lists them,session_readrefuses them andartifact_listdrops their artifacts. - Every result passes the vault's redaction, like tool output, so a stored secret value comes back as its placeholder.
- Every call, over either transport, appends one line to
<data_dir>/mcp/server-audit.jsonl: time, transport (httporstdio), the client's name, the tool, a SHA-256 of the arguments (never the arguments), success and duration. Past 50 MB the file moves toserver-audit.jsonl.1and a new one starts. - Write tools have no theuth-side gate. A client holding the token can
create, change and delete notes, knowledge, tasks, briefs and calendar
sources without an approval card; whatever approvals apply are the
client's. Rotating the token cuts off every HTTP client;
t mcpdoes not use it.
Tools and permissions
Built-in tools by group, the read_only / mutating / destructive risk classes, tools.policy and approvals, per-session bypass, MCP gates and subagent caps.
Skills
Markdown skills the model loads on demand, front matter, the prompt index, always-on skills, git skill repos, bundled skills and the commands and tools that manage them.