Skip to content

multiagents setup does not propagate MULTIAGENTS_PORT into codex/claude/gemini config #3

Description

@papajade55-debug

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.jsonmcpServers.multiagents.env) and Gemini CLI (~/.gemini/settings.jsonmcpServers.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:

  1. Detect process.env.MULTIAGENTS_PORT at setup time.
  2. In upsertCodexMultiagentsSection, append an env entry when the port differs from DEFAULT_BROKER_PORT.
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions