Skip to main content

Crate agentmux_mcp

Crate agentmux_mcp 

Source
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 Desktop does 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 is container::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/call running 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 inputSchema JSON advertised to the client, one const per 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’s call handles the tools it owns and returns not_in_family() for any other name, so no tool list is written twice.
window_blackout 🔒
The blackout of a UI window 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§

LoopEntry 🔒
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, because tools/list is answered at once and never waits on srv. The Notify is 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 to block_id.

Type Aliases§

LoopRegistry 🔒
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.