Summary
When the user exports a custom MULTIAGENTS_PORT in the environment before running multiagents setup, the setup correctly starts the broker on that port, but does not write the port back into the agent configuration files. As a result, the configured agents (Claude Code, Codex CLI, Gemini CLI) will connect to the default :7899 broker instead of the one the user intended.
Related to (but not the same as) #1, which fixed orchestrator-server.ts to honor MULTIAGENTS_PORT. This issue is about setup / install-mcp.
Reproduction
# State before: clean codex config (no multiagents section)
grep -c "mcp_servers.multiagents" ~/.codex/config.toml
# → 0
# Run setup with a non-default port
MULTIAGENTS_PORT=7900 multiagents setup
# → Broker starts on :7900 (correct)
# Check what ended up in the agent config
grep -A5 "mcp_servers.multiagents" ~/.codex/config.toml
Actual output:
[mcp_servers.multiagents]
command = "/usr/bin/bun"
args = ["/home/.../multiagents/server.ts", "--agent-type", "codex"]
default_approval_mode = "approve"
Expected output (when MULTIAGENTS_PORT is set in env):
[mcp_servers.multiagents]
command = "/usr/bin/bun"
args = ["/home/.../multiagents/server.ts", "--agent-type", "codex"]
default_approval_mode = "approve"
env = { MULTIAGENTS_PORT = "7900" }
The same gap exists for Claude Code (~/.claude.json → mcpServers.multiagents.env) and Gemini CLI (~/.gemini/settings.json → mcpServers.multiagents.env).
Impact
Users who run two brokers side by side (e.g. a legacy broker on :7899 and multiagents on :7900 during a migration window) see their agents silently connect to the wrong broker, producing symptoms like:
Suggested fix
In cli/install-mcp.ts:
- Detect
process.env.MULTIAGENTS_PORT at setup time.
- In
upsertCodexMultiagentsSection, append an env entry when the port differs from DEFAULT_BROKER_PORT.
- Same for the Claude and Gemini JSON writers — already easier since both configs already support
env.
Happy to submit a PR if you want — just wanted to flag it first since the fix surface touches three writers.
Environment
multiagents@0.4.8 (npm)
- Linux Mint 22.3 / Ubuntu 24.04 noble
- Bun 1.3.9
- Codex CLI 0.122.0, Claude Code 2.1.116, Gemini CLI 0.38.2
Summary
When the user exports a custom
MULTIAGENTS_PORTin the environment before runningmultiagents setup, the setup correctly starts the broker on that port, but does not write the port back into the agent configuration files. As a result, the configured agents (Claude Code, Codex CLI, Gemini CLI) will connect to the default:7899broker instead of the one the user intended.Related to (but not the same as) #1, which fixed
orchestrator-server.tsto honorMULTIAGENTS_PORT. This issue is aboutsetup/install-mcp.Reproduction
Actual output:
Expected output (when
MULTIAGENTS_PORTis set in env):The same gap exists for Claude Code (
~/.claude.json→mcpServers.multiagents.env) and Gemini CLI (~/.gemini/settings.json→mcpServers.multiagents.env).Impact
Users who run two brokers side by side (e.g. a legacy broker on
:7899andmultiagentson:7900during a migration window) see their agents silently connect to the wrong broker, producing symptoms like:list_peersreturns emptysend_messagelooks like it succeeded but teammates never see the message/sessions/*returns 404 (the exact scenario that fix(orchestrator): honor MULTIAGENTS_PORT env var for broker URL #1 patched)Suggested fix
In
cli/install-mcp.ts:process.env.MULTIAGENTS_PORTat setup time.upsertCodexMultiagentsSection, append anenventry when the port differs fromDEFAULT_BROKER_PORT.env.Happy to submit a PR if you want — just wanted to flag it first since the fix surface touches three writers.
Environment
multiagents@0.4.8(npm)