Skip to content

fix(server): preserve Codex MCP transports in text generation - #31282

Closed
billvsd wants to merge 1 commit into
pingdotgg:mainfrom
billvsd:fix/lh-1641-codex-mcp-overrides
Closed

billvsd wants to merge 1 commit into
pingdotgg:mainfrom
billvsd:fix/lh-1641-codex-mcp-overrides

Conversation

@billvsd

@billvsd billvsd commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex text generation replaces an entire mcp_servers CLI override table with entries containing only enabled=false. When a launcher supplied an MCP transport through an earlier -c override, this deletes its command/url and Codex exits with invalid transport before generating a title. The same helper serves other text-generation operations.

Append individual mcp_servers.<name>.enabled=false overrides instead, preserving launcher-provided transport fields. Codex splits raw dotted paths without interpreting TOML key quotes, so names containing quotes, backslashes, spaces or Unicode must remain raw argv values. Reject names containing dots, = or NUL before exec because that parser cannot address them safely. The error names the server and suggests renaming it or choosing another system model.

This is a small, focused fix for an obvious configuration layering defect. It does not add provider fallback or change title error presentation; visible failure reporting remains separate from this fix (see #5359).

Validation:

  • Existing text-generation test extended for multiple servers, a quoted/backslashed name, an already-disabled server and trailing plugin/app overrides; rejection cases cover dots, = and NUL.
  • A configuration-only regression exercised the actual makeCodexTextGeneration spawn path through a synthetic managed launcher and Codex CLI 0.159.1. The launcher injects nine stdio/HTTP servers via earlier CLI overrides. exec is intercepted and its generated config arguments are passed to real codex mcp list --json; the test checks every server is disabled and all transport fields are unchanged. No provider/model or MCP calls run. The pinned original source fails with invalid transport; this patch passes, including quotes, backslashes, spaces, Unicode and newline names. The repeatable real-CLI harness is attached to the fork patch release; extract and run regression-harness/run.sh /path/to/checkout /path/to/codex.
  • vp run check:changed 84537c4dd976a89b6ec094f43ae3ef7bee12cb1a --concurrency 1: all required steps pass (format, lint, both knip passes, generated GraphQL check, typecheck of 3 affected packages, 18 tests in 2 files).

Prepared with gpt-6.1-sol (high reasoning), Codex harness in T3 Code.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 5, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 40ef725

Macroscope's review found this PR approvable — Codex text generation now disables MCP servers through leaf overrides, preserving launcher-provided transport settings and rejecting names the CLI cannot safely address. The change remains confined to subprocess configuration and retains existing execution safeguards.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The Codex text-generation runner now disables enabled MCP servers with individual config overrides. It returns a TextGenerationError when an enabled server name contains a dot, equals sign, or null character. Tests cover valid and rejected names.

Changes: Codex MCP override handling

Layer / File(s) Summary
Validate server names and build overrides
apps/server/src/textGeneration/CodexTextGeneration.ts, apps/server/src/textGeneration/CodexTextGeneration.test.ts
The runner creates a separate mcp_servers.<name>.enabled=false override for each enabled server. It rejects names containing ., =, or a null character. Tests cover a quoted name with a backslash and spaces, plus the rejected name cases.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: brycedbjork, macroscopeapp

Merge Risk: Minimal · up to 40ef7

No merge-blocking issue is established. The rejected-name diagnostic remains a boundedness question.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: preserving Codex MCP transport configuration during text generation.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description states the problem (launcher-supplied MCP transports are deleted by a whole-table mcp_servers override, causing Codex to fail with invalid transport), the change (per-server `mcp_s…
Full details: Description check

Explanation

The description states the problem (launcher-supplied MCP transports are deleted by a whole-table mcp_servers override, causing Codex to fail with invalid transport), the change (per-server mcp_servers.&lt;name&gt;.enabled=false overrides, plus rejection of names containing dots, =, or NUL), scope (small focused fix, explicitly excludes provider fallback and error presentation changes, references #5359), and verification (extended tests, a real-CLI regression, and a check:changed run with listed steps). It also names the model and harness used. The template's Scope and approval section asks for a linked triaged issue or maintainer-approved discussion, or an explanation of why a small obvious bug fix qualifies without one. The author gives the explanation ("small, focused fix for an obvious configuration layering defect") but links no issue or approval comment, so that part is only partly met. The Verification section is thorough and states the observed results. The description is mostly complete, so this check passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Additional comments: 1

apps/server/src/textGeneration/CodexTextGeneration.ts-284-284: 1

284-284: Minor · Security & Privacy · Quick win

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Keep the rejected server name out of the error detail.

If mcp list --json returns a long or sensitive name containing a rejected character, this branch copies the full name into TextGenerationError.detail. Report the invalid character category without the raw name, and update the assertion in the test. As per coding guidelines, “Attributes and log annotations stay bounded: no raw payloads, command arguments or output”; the exact value belongs only in cause.

Source: Coding guidelines

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 20e92ff and 40ef725.

Files selected for processing: 2

  • apps/server/src/textGeneration/CodexTextGeneration.test.ts
  • apps/server/src/textGeneration/CodexTextGeneration.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

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

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants