Expand description
agentmux-mcp — MCP stdio server that exposes AgentMux’s MuxAPI tools
(Terminal, Message, Memory, Pane, …) to Claude.
Claude Code launches this binary as an MCP server (via .mcp.json’s
"command": "agentmux-mcp" entry, auto-injected by agent_config.rs).
Communication is JSON-RPC 2.0 over stdin/stdout.
The Terminal tool’s background run (formerly Shell) starts a
persistent shell on agentmux-srv and returns at once with a shell_id;
output streams into the conversation as a ShellNode row, unblocking.
Env vars (inherited from agentmux-srv’s agent env injection): AGENTMUX_LOCAL_URL — sidecar HTTP base URL AGENTMUX_AUTH_KEY — X-AuthKey header secret AGENTMUX_BLOCKID — block UUID for shell event scoping (preferred). Injected by agent_handlers/input.rs into every persistent subprocess env; inherited by this MCP subprocess. AGENTMUX_AGENT_BUS_ID — MuxBus routing identifier (fallback only). Often set to the agent type string (e.g. “claude”) in .mcp.json, NOT the block UUID — do not use it as the shell scope unless AGENTMUX_BLOCKID is absent.
Modules§
- desktop_
input 🔒 - What
Desktopdoes to a native app’s window: mapping a point in a screenshot to the screen, reading a key chord, and (on Windows) sending the input (docs/specs/SPEC_DESKTOP_DRIVING_2026_10_20.md §5.1–5.2). - doctor 🔒
agentmux-mcp doctor [--heal]: why this agent’s AgentMux tools aren’t connected, run from its shell with no MCP session (docs/specs/SPEC_AGENT_MCP_SELF_HEAL_2026_10_10.md §7). It checks what a person would check by hand: that this binary starts and answers MCP, also through Claude Code’s shell prefix the way the CLI starts it; the agent’s.mcp.json; what srv saw and tried; and Claude Code’s own log for the server. Read-only, except--heal, which asks srv to run the repair for the caller’s own pane.- gateway_
fwd 🔒 agentmux-mcp gateway-fwd: the gateway forwarder srv runs as a helper container on the agents network (Docker Desktop), so a container agent’s model-gateway request carries proof of which container it is from (agentmux_common::gateway_stamp; srv’s side iscontainer::gateway_fwd).- heartbeat 🔒
- The heartbeat to srv: every few seconds this process says it is alive, how
old its oldest unanswered call is, and how far behind its async runtime
runs. srv’s self-heal (
backend::mcp_health, #2614) restarts the server when the beats stop, or the runtime has stopped turning, or a call has outlived every deadline. - identity 🔒
- Agent identity at the MCP boundary, jekt ids and outgoing jekt / UI-automation signatures. Split out of main.rs unchanged (SPEC_LARGE_FILE_MODULE_ANALYSIS_2026_09_30.md §4.2).
- self_
keys 🔒 - Identity M4d-3: this agent’s signing keys, fetched from srv
(
GET /agentmux/agents/self/keys) rather than only read from.mcp.json(SPEC_AGENT_IDENTITY_CARRIED_NOT_DERIVED_2026_09_23.md§6.5.10). - serve 🔒
- The MCP request loop: JSON-RPC lines in, JSON-RPC lines out, with every
tools/callrunning as its own task under its own deadline, so one call that never returns can’t hold up the others (docs/reports/ on #2614: a window call hung for 1800 s and every later call, to any tool, hung behind it, for ten hours, until the agent restarted). - srv_
http 🔒 - HTTP helpers for calls to the sidecar srv. Split out of main.rs unchanged (SPEC_LARGE_FILE_MODULE_ANALYSIS_2026_09_30.md §4.2).
- tool_
helpers 🔒 - Helpers the tool handlers share: cron, durations, quit-self and bulk-stop outcomes, delivery text. Split out of main.rs unchanged (SPEC_LARGE_FILE_MODULE_ANALYSIS_2026_09_30.md §4.2).
- tool_
schemas 🔒 - MCP tool schemas — the
inputSchemaJSON advertised to the client, oneconstper tool. - tools 🔒
call_tool’s handlers, one file per tool family (docs/specs/SPEC_LARGE_FILE_MODULE_ANALYSIS_2026_09_30.md §4.2 (a)). Each family’scallhandles the tools it owns and returnsnot_in_family()for any other name, so no tool list is written twice.- window_
blackout 🔒 - The blackout of a
UIwindow capture of an AgentMux window (docs/specs/SPEC_DEEP_LINKS_ONE_FRAMEWORK_2026_11_20.md §7, G5). - window_
capture 🔒 - Window capture and discovery, plus the audit log both write.
Structs§
- Loop
Entry 🔒 - Metadata kept alongside each running loop’s task handle.
Functions§
- agent_
token_ 🔒headers - The headers every request to srv carries.
- call_
tool 🔒 - granted_
services_ 🔒kept_ fresh - Which Google services this agent has a grant on, for
tools/list: asked of srv now, again every minute and right after the agent changes a grant, becausetools/listis answered at once and never waits on srv. TheNotifyis woken when the set changes, so the client is told to list the tools again (it does not on its own). - main 🔒
- run 🔒
- scope_
block_ 🔒id - The block this process scopes its calls to.
- start_
pulse 🔒 - The runtime’s pulse, and the heartbeat to srv from a thread of its own, so a starved runtime is seen from outside (heartbeat.rs).
- tool_
runner 🔒 - Runs each tool call against srv at
local_url, scoped toblock_id.
Type Aliases§
- Loop
Registry 🔒 - In-process registry of running loops, keyed by loop_id. Lives for this MCP process’s lifetime (== the agent session), so loops are reaped automatically when the agent pane closes.