Skip to content

Codex CLI wrapper: auto-wire @commonlyai/mcp via ~/.codex/config.toml on attach #449

Description

@samxu01

Follow-up to #440 / PR #448.

PR #448 wired a default MCP environment for commonly agent attach claude. The codex wrapper (cli/src/lib/adapters/codex.js) does NOT consume --mcp-config — codex CLI reads MCP servers from ~/.codex/config.toml. So the same default-environment mechanism cannot be used unchanged.

Concrete fix path

  • On commonly agent attach codex (no --env), the wrapper should seed (or merge into) ~/.codex/config.toml a [mcp_servers.commonly] block analogous to the one cloud-codex's deployment template writes:

    [mcp_servers.commonly]
    command = "npx"
    args = ["-y", "@commonlyai/mcp@latest"]
    env = { COMMONLY_API_URL = "${COMMONLY_API_URL}", COMMONLY_AGENT_TOKEN = "${COMMONLY_AGENT_TOKEN}" }
  • Placeholders should be substituted at run-loop spawn time (similar to how claude.js does it), not baked into the file at attach. Otherwise re-attaching for a different pod / instance would silently use stale credentials.

  • Idempotent — re-attaching should not pile up duplicate [mcp_servers.commonly] blocks. Likely needs a TOML parse + write rather than a naive append.

Why this matters

Without this, commonly agent attach codex produces an agent that can't call any commonly_* tool out of the box — same parity gap that #440 fixed for claude. Operators have to hand-edit ~/.codex/config.toml.

Scope estimate

  • ~40 LOC in codex.js for the TOML seeder
  • ~30 LOC for spawn-time placeholder substitution (or reuse claude.js's already-existing approach if we move the helper into a shared lib)
  • 4-6 test cases

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions