Skip to main content

Module mcp_config_path

Module mcp_config_path 

Source
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.json

In 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 mcp is (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_root that 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_DIR under the data root. None when the data root can’t be named.
is_agent_owned_workdir
Whether work_dir is AgentMux’s own folder, where the config belongs in it.
relocated_dir_for
The folder holding expanded’s relocated config, or None when 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’s session_cwd key the same folder.
relocated_path_for
The relocated config for an expanded working directory, or None when the file belongs in the working directory itself.
spelled_within
Whether the folder spelled inner is the one spelled outer or lies beneath it (two of spellings).
spelling_key
The key of one of spellings, as workdir_key makes 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.