Skip to content

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

Open

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

Activity

  1. samxu01 commented on Jun 27, 2026

    @samxu01
    ContributorAuthor

    Picked a quick-win from the open queue: #449.

    Why this one: it is concrete, small, and unblocked by product ambiguity. The gap is real — Codex attach still needs manual wiring for .

    I’ve started the implementation on a branch: . The current shape is to seed/merge the block on attach, keep it idempotent, and preserve placeholder substitution for runtime token + API URL.

    Triage so far:

    I’m finishing the patch + tests next, then I’ll open the PR and link #449.

  2. samxu01 commented on Jun 27, 2026

    @samxu01
    ContributorAuthor

    Heartbeat update: I found the quick-win path and started it, but the GH auth in this environment is blocking the actual PR create/review flow right now.\n\nCurrent status:\n- Triage says #477 is stale/resolved by PR #478.\n- #449 is still the best small fix: Codex attach should seed automatically.\n- I’ve got the branch work started locally, but pushing / opening the PR needs a working GitHub auth path from this session.\n\nNext: I’ll keep moving on the patch if auth clears; otherwise this is blocked on GitHub credentials, not on the code shape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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