Expand description
Where an agent’s MCP config lives (#3680), shared by srv and agentmux-mcp doctor.
An agent’s working directory may be the user’s own project. A launch used to write
.mcp.json there; now, for a folder AgentMux does not own, the config goes under the data
root, outside the project:
<data root>/mcp/<hash of the expanded working directory>/mcp.jsonIn a folder AgentMux owns the file stays <working directory>/.mcp.json, which Claude Code
reads on its own. srv derives the path to write and read it; agentmux-mcp doctor derives
the same one to diagnose it, so the two cannot disagree.
A container gets the folder as a read-only bind at CONTAINER_MCP_CONFIG_DIR; the file
keeps its name inside it. The folder rather than the file matters: a single-file bind keeps
the inode it was made with, so an atomic rewrite would leave the container on a stale copy.
Constants§
- CONTAINER_
MCP_ CONFIG_ DIR - Where a container agent’s relocated config folder is mounted.
- HOST_
ONLY_ DIR - The folder, under the data root, of what AgentMux keeps for host agents alone. Nothing in it is bound into
a container: a relocated config’s folder under
mcpis (read-only,container::mounts), this one never. The data root is one version’s of one install: what is kept here is written again by a launch, so nothing that must outlive an upgrade belongs in it. - MCP_
JSON - The file name every provider’s workspace MCP config uses.
- RELOCATED_
MCP_ JSON - The file name of the relocated config inside its own folder.
Functions§
- config_
path_ for - Where this agent’s MCP config is: in its working directory when AgentMux owns the folder, else under the data root.
- container_
config_ path - The config’s path inside a container, where its folder is mounted.
- expand_
home - Expand a leading
~against the real home. srv has its own expander (it also honours the dev-instance home override for paths under~/.agentmux); a user’s project expands the same way in both. - host_
only_ dir_ for - The folder under
host_only_rootthat is keyed by an expanded working directory, whoever owns that directory: where srv keeps the config of a host agent whose own folder may not hold it. - host_
only_ root HOST_ONLY_DIRunder the data root.Nonewhen the data root can’t be named.- is_
agent_ owned_ workdir - Whether
work_diris AgentMux’s own folder, where the config belongs in it. - relocated_
dir_ for - The folder holding
expanded’s relocated config, orNonewhen the folder is AgentMux’s own (the file belongs in the working directory itself). A relative path is resolved first, so both the writer and ACP/MSP’ssession_cwdkey the same folder. - relocated_
path_ for - The relocated config for an expanded working directory, or
Nonewhen the file belongs in the working directory itself. - spelled_
within - Whether the folder spelled
inneris the one spelledouteror lies beneath it (two ofspellings). - spelling_
key - The key of one of
spellings, asworkdir_keymakes it for a path. - spellings
- The spellings one folder is compared under: as it is written (absolute,
.and..and links resolved as they are met), and as the filesystem names it when it exists (which also settles letter case on a filesystem that ignores it, and short names on Windows). Each is separator-normalized, with no trailing separator, and case-folded on Windows. One entry when the two are the same. - workdir_
key - A stable, filesystem-safe key for an already-expanded working directory.