Skip to content

Write valid Codex MCP configuration - #284

Merged
Eli Pinkerton (wallstop) merged 2 commits into
migrate/sourced-env-pythonfrom
migrate/codex-mcp-writer
Oct 18, 2026
Merged

Eli Pinkerton (wallstop) merged 2 commits into
migrate/sourced-env-pythonfrom
migrate/codex-mcp-writer

Conversation

@wallstop

@wallstop Eli Pinkerton (wallstop) commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

DISCLOSURE: LLM-GENERATED TEXT

Why: Codex config writes remain in Node and emit invalid Windows paths.

What:

  • Write Codex MCP state with typed Python through uv.
  • Preserve user settings, project trust, and dry-run behavior.
  • Escape Windows paths and preserve unmanaged workspace content.
  • Verify persistence contracts and the Python fallback when uv is absent.

Refs #171.


Note

Medium Risk
Changes affect devcontainer credential loading and Codex/MCP sync on host and container; mistakes could break agent startup or write invalid Codex TOML, though contract tests cover the main paths.

Overview
Codex MCP configuration is moved out of Node into scripts/mcp_codex_config.py, which writes the managed $CODEX_HOME/config.toml block (with JSON-style TOML escaping for Windows paths and Unicode), migrates workspace trust, and prunes stale .codex/config.toml content. configure.mjs now shells to that script via uv or Python 3.9+ when uv is missing.

.env.local loading is refactored so env-local.sh delegates parsing to env_local.py (NUL-delimited, atomic exports, literal values only). Shell precedence and MCP credential override behavior stay the same, with expanded contract tests.

Harness scope maps the new Codex module to test_mcp_codex_config.py; MCP sync tests cover the Python-only Codex path.

Reviewed by Cursor Bugbot for commit eace335. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a294ba0. Configure here.

Comment thread scripts/mcp_codex_config.py
Eli Pinkerton (wallstop) added a commit that referenced this pull request Oct 18, 2026
Windows text streams can use CP1252 while the Node configurator sends UTF-8 JSON. Read and write protocol bytes explicitly as UTF-8, including diagnostics.

The new regression first reproduced corrupted Japanese command and argument paths with PYTHONIOENCODING=cp1252. All six persistence tests, the affected sync/credential suites, strict pyright, and check:gate now pass. Refs #171 and PR #284 review discussion_r4305641307.
Codex persistence still lives in the Node configurator. Move its home-config writer and stale workspace cleanup to Python through uv, with a validated Python fallback when uv is absent.

Preserve managed definitions, trust entries, user settings, dry runs, atomic private writes, and idempotence. Escape Windows paths and control characters as TOML strings. Leave unmanaged workspace whitespace intact.

Validation: all 43 harness test files pass. Five direct persistence contracts cover merge, cleanup, failure, escaping, and TOML parsing. Strict pyright, check:fast, check:gate, and npm pack dry run pass. Unity 6000.5.2f1 Windows passes 393 EditMode and 15 PlayMode tests. No other frontend writer or host bridge is ported. Refs #171.
Windows text streams can use CP1252 while the Node configurator sends UTF-8 JSON. Read and write protocol bytes explicitly as UTF-8, including diagnostics.

The new regression first reproduced corrupted Japanese command and argument paths with PYTHONIOENCODING=cp1252. All six persistence tests, the affected sync/credential suites, strict pyright, and check:gate now pass. Refs #171 and PR #284 review discussion_r4305641307.
@wallstop
Eli Pinkerton (wallstop) changed the base branch from main to migrate/sourced-env-python October 18, 2026 05:59
@wallstop
Eli Pinkerton (wallstop) added this pull request to stack #291 October 18, 2026 05:59
@wallstop
Eli Pinkerton (wallstop) merged commit 3f9babd into main Oct 18, 2026
3 checks passed
@wallstop
Eli Pinkerton (wallstop) deleted the migrate/codex-mcp-writer branch October 18, 2026 06:09
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.

1 participant