Skip to main content

Module mcp_folder_rule

Module mcp_folder_rule 

Source
Expand description

The MCP servers of a host agent whose folder a container agent can write.

A host agent’s CLI starts the MCP servers of its config on this computer. Where a container agent can write the agent’s working folder or a folder beneath it, or has run in that folder, the host agent gets only the servers AgentMux writes:

  • its config is kept outside the folder (mcp_config_file::host_config_path), and the folder’s own .mcp.json is neither merged into it nor handed to a harness (mcp_config_file::read_for_turn);
  • a Claude Code turn is told to use that config alone (agent_mcp_flag), and the config names the agentmux command by its path (with_the_command_by_path);
  • any other harness, and any agent whose CLI is started by a terminal, session or app-server controller, is not started there (refusal, turn_refusal): what it reads from its folder is its own, and AgentMux has no switch for it;
  • the pane says which servers of the folder’s file were left out (left_out, cli_notice).

“Can write” is asked of container_folders, as the Editor’s language servers ask it; where that can’t be told, the rule holds. “Has run in it” is a mark kept in the shared folder (mark), so the rule still holds when the agent is switched to the host, or another host agent is given the folder, a folder in it or a folder that holds it. A folder no container agent has to do with is not touched by any of this.

Constants§

REFUSAL
What a pane is told when refusal stops its agent.
TURN_REFUSAL
What a pane is told when turn_refusal stops its agent’s turn.
WORKFLOW_REFUSAL
What a workflow step is told when workflow_refusal stops its agent.

Functions§

config_to_import
The text of folder’s own .mcp.json for a host agent that is defined from the folder (an import), which keeps the folder’s servers as its own. None where the rule holds: the agent takes no server from the file.
folder_of
The working folder of the host agent on a pane with meta, expanded, when the rule holds for it.
holds_in
Whether a host agent in work_dir gets only the servers AgentMux writes: a container agent can write the folder or one beneath it, or has run in it, or that can’t be told. Reads the disk and the store.
is_outside
Whether exe may be named as a command to a host agent of work_dir ([outside]).
left_out
The servers of folder’s own .mcp.json that the agent’s config (ours, its text) does not have: the ones a host agent there is not given. By name, sorted, at most [MOST_NAMES]. Only reads the file.
mark
Record that a container agent runs with work_dir as its folder. The mark stays: from now on a host agent in that folder, in one beneath it or in one that holds it gets only the servers AgentMux writes. Best-effort; a failure is logged.
mark_when_moved_to_the_host
mark the folder of an agent whose definition just changed from old to new, when that moved it from a container to the host: the folder was the container’s until now. An agent with no folder of its own named is marked by its turns in the container.
names_every_command_outside
names_the_command_by_path, and every command is a path outside work_dir that no container agent can write ([outside]): what a host turn in a folder the rule holds for is given.
names_the_command_by_path
Whether config (the text of an MCP config) names every command it has by an absolute path (a server reached over the network has none): what a host turn in a folder the rule holds for is given, and nothing else.
not_refused
Err with refusal’s reason when the agent on a pane with meta is not started on this computer: the first line of a controller’s start whose CLI starts with it.
refusal
Why the agent on a pane with meta is not started on this computer by a controller that starts its CLI itself (a terminal agent, a session agent, an app-server agent): the rule holds for its folder, and nothing on that path keeps a CLI to AgentMux’s config, whatever the harness. None for a container agent, for a pane that is no agent’s, and for every other folder.
turn_refusal
Why a turn of the agent on a pane with meta is not started on this computer: as refusal, except for Claude Code, whose turn goes on because the flags it is started with keep it to AgentMux’s config (agent_mcp_flag). Asked only where those flags are added (agent_runtime::with_runtime_flags): the turn of a turn-based agent, and the start of its process ahead of a turn.
with_commands_by_path
with_the_command_by_path, and the same for every other server of the config: a server the person set with a bare command (npx, uvx) is named by the path that name has on this computer’s PATH, outside the folder. A server whose command has no such path is taken out, and the names of those are returned (the agentmux entry is not among them: it is AgentMux’s own).
with_the_command_by_path
config (the text of a host agent’s MCP config) as it is written for work_dir, a folder the rule holds for: the agentmux entry’s command is the absolute path of the agentmux-mcp that ships with this install, never a name. Where no such file ships outside the folder, the entry is taken out: no server rather than one found by name.
workflow_refusal
Why a step of a workflow that runs an agent in work_dir is not started on this computer: the rule holds for the folder, and the step’s Claude Code is started with no flags of AgentMux’s, so nothing keeps it to AgentMux’s settings, servers and instructions. work_dir is the folder the step starts in, as it is: the caller gives the working folder of the process when the step names none. None for every other folder.