Skip to content

🤖 [codex] Add MCP config overlay support#92

Merged
jonandersen merged 5 commits into
block:mainfrom
robmaceachern:robmaceachern/codex-mcp-config-support
May 8, 2026
Merged

🤖 [codex] Add MCP config overlay support#92
jonandersen merged 5 commits into
block:mainfrom
robmaceachern:robmaceachern/codex-mcp-config-support

Conversation

@robmaceachern

@robmaceachern robmaceachern commented May 6, 2026

Copy link
Copy Markdown
Contributor

🤖 Drafted by my AI agent.

Summary

  • Generate Codex .codex/config.toml from shared ai-rules/mcp.json, with optional ai-rules/codex-config.toml overlay support for repo-owned Codex settings.
  • Merge generated MCP server tables with the Codex overlay before serializing TOML, so server-name collisions produce one valid table with overlay values taking precedence.
  • Match Firebender's source-overlay model for supplemental agent config, including cleaning the generated Codex config file when MCP/config generation is removed.
  • Update Codex MCP tests and docs for the overlay model.

Why

Codex project config can include more than MCP server definitions. Letting repositories define ai-rules/codex-config.toml gives them a source-controlled place for shared Codex settings while still deriving MCP server entries from the common ai-rules/mcp.json source.

If the overlay defines a server that is also generated from ai-rules/mcp.json, the overlay wins for overlapping fields. The generator resolves those tables before writing TOML, so .codex/config.toml remains parseable while still allowing project-specific overrides, such as customizing a generated rlib server.

Alternatives Considered

  • Preserving arbitrary existing .codex/config.toml content and adding generated MCP server tables was considered, but it leaves shared Codex settings outside source control and can produce duplicate TOML tables when an existing target server name overlaps with ai-rules/mcp.json.

Validation

  • cargo fmt --all --check
  • ./scripts/clippy-check.sh
  • cargo test
  • Verified against ios-register origin/main ai-rules/mcp.json: generated Codex config includes actionable-ci-results and rlib, and parses with tomllib.

This PR description was drafted with AI assistance.

@robmaceachern

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

let content = merge_generated_mcp_block(&base_content, &generated_block);

P2 Badge Avoid duplicating existing mcp_servers tables

When .codex/config.toml already contains a user-defined [mcp_servers.<name>] table and ai-rules/mcp.json contains the same server name, this merge path appends another [mcp_servers.<name>] in the generated block instead of reconciling/replacing it. TOML does not allow defining the same table twice, so the resulting config becomes invalid and Codex can fail to load MCP settings for that project. This is reproducible with any name collision between preserved user config and generated servers.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@robmaceachern
robmaceachern marked this pull request as ready for review May 6, 2026 19:13

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0c29551e8b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/codex.rs Outdated
@robmaceachern robmaceachern changed the title 🤖 [codex] Add Codex MCP config support 🤖 [codex] Add MCP config overlay support May 6, 2026
@robmaceachern

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 366dd72c08

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/codex.rs Outdated
Comment thread docs/mcp.md Outdated
@jonandersen
jonandersen merged commit bcbdf61 into block:main May 8, 2026
9 checks passed
@jonandersen jonandersen mentioned this pull request May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants