Repository navigation
feat(mcp): support Codex MCP sync and canonical MCP support matrix (#124) - #195
saryeljaramany wants to merge 9 commits into
Conversation
vsn411
left a comment
There was a problem hiding this comment.
Thanks, this addresses the #190 review well:
- it's scoped to Codex and built on
_run_cli(); - the shared
write_private_textis now atomic and symlink-safe, instead of a second writer; - it uses
tomlkit; - the support matrix lives in code, with a test against
ADAPTERS; - it includes real
codex-cli 0.172.0output.
CI is green. Two things before we merge:
- Honour
CODEX_HOME. Codex reads its config from$CODEX_HOME/config.tomlwhen that variable is set, and falls back to~/.codexotherwise.CODEX_CONFIG_PATHis hard-coded to~/.codex/config.toml. For anyone who setsCODEX_HOME, the sync would report success while Codex never sees the server.- Please resolve the path at call time, e.g.
Path(os.environ.get("CODEX_HOME", Path.home() / ".codex")) / "config.toml". - Please add a test that sets
CODEX_HOME.
- Please resolve the path at call time, e.g.
- Evidence for a remote server. The evidence shows a stdio server (
npx mcp-remote). The case that matters most is a remote server with auth headers, written asurl+http_headers, because that's how the defaultsecfoo-memoryserver is synced. Please addcodex mcp get <name> --jsonoutput for aurlserver with a header. It should show a streamable-HTTP transport with the header present (redact the value).
Nits (fine to fold in or leave):
- When
config.tomlhas nomcp_serversyet,tomlkit.table()writes an empty[mcp_servers]header above the[mcp_servers.<name>]tables.tomlkit.table(is_super_table=True)avoids that. - An inline
mcp_servers = { ... }isn't handled. Returning a clear failedSyncResultfor it is enough. - The new
except OSError: passaround the chmod would trip ruff's try/except/pass rule (S110), which #168 is clearing elsewhere. Alogger.debug(...)would avoid it.
Happy to merge once 1 and 2 are in.
…or for an inline table
- codex_config_path() resolves $CODEX_HOME/config.toml at call time, the
file Codex itself reads, falling back to ~/.codex.
- A new mcp_servers table is a super table, so only [mcp_servers.<name>]
headers are written.
- An inline mcp_servers = { ... } returns a failed SyncResult and leaves
the file untouched.
- The chmod fallback logs at debug level instead of a silent pass.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for this. To get it merged sooner, I pushed the review items straight to your branch (14d9547):
I also merged current |
|
Thanks for pushing Here is the requested real-CLI verification for a remote $ codex --version
codex-cli 0.172.0
$ secfoo mcp sync --agent codex
ok secfoo-memory: added to C:\...\codex_home\config.tomlGenerated [mcp_servers.secfoo-memory]
url = "https://api.secfoo.com/mcp"
[mcp_servers.secfoo-memory.http_headers]
Authorization = "Bearer <REDACTED>"Output of {
"name": "secfoo-memory",
"enabled": true,
"disabled_reason": null,
"transport": {
"type": "streamable_http",
"url": "https://api.secfoo.com/mcp",
"bearer_token_env_var": null,
"http_headers": {
"Authorization": "Bearer <REDACTED>"
},
"env_http_headers": null,
"http_headers_helper": null
},
"enabled_tools": null,
"disabled_tools": null,
"startup_timeout_sec": null,
"tool_timeout_sec": null
} |
Part of #124 (Codex MCP sync, symlink-safe atomic writer, and canonical MCP support matrix).
Summary
Following maintainer feedback on closed PR #190, this PR starts cleanly from current
main(509bd9b) and scopes Phase 1 to Codex MCP configuration sync backed by real CLI verification, alongside the symlink-safe atomic writer and the canonical MCP support matrix +secfoo agentsMCP column. Remaining JSON-config agents (copilot,opencode,droid,devin) are left out ofSYNC_SUPPORTED_AGENTSand documented as planned follow-ups so each can land with its own real-CLI evidence.Addresses Feedback from #190
main(0 conflicts): Built directly on top of_run_cli()(fix(mcp): report a missing agent CLI instead of crashing #181) and0600Cursor permissions (fix(mcp): write ~/.cursor/mcp.json owner-only (0600) #182) with zero merge conflicts so CI runs cleanly across all runners.src/secfoo/config.py): Removed duplicate_write_private_filefromsrc/secfoo/mcp.py.write_private_text()now resolves symlinks first (path.resolve()), creates a temporary file next to the real target intarget.parentviaos.O_CREAT | os.O_EXCLat0o600(plusos.fchmod), and replaces atomically viaos.replace()so dotfile manager symlinks (stow,chezmoi) are never overwritten with regular files.tomlkit(src/secfoo/mcp.py):sync_codex()merges[mcp_servers.<name>]entries into~/.codex/config.tomlviatomlkit, preserving comments, whitespace, and existing tables.command,args,env) and streamable-HTTP servers (url,http_headers).SyncResult(Codex does not support SSE).SyncResultconsistently for invalid TOML or non-table roots.~/.codex/config.tomlpermissions to0o600on POSIX when nothing new is added.src/secfoo/mcp.py,src/secfoo/cli.py):CANONICAL_MCP_SUPPORTin code as the single source of truth covering all 10 adapters inADAPTERS.MCPcolumn (per-run,sync,none) tosecfoo agents.--agentoptional onsecfoo mcp sync; when omitted, syncs only installed sync-supported agents found onPATH.docs/REFERENCE.md,docs/agents.md,README.md,src/secfoo/cli.py):secfoo-memory).agynotes to reflect thatagy 1.5.3exposes anagy mcpsubcommand.Real CLI Evidence (
codex-cli 0.172.0on Windows)Verification
git merge-tree --write-tree HEAD main: 0 conflicts againstupstream/main(509bd9b).pytest tests/test_mcp.py tests/test_cli.py tests/test_store_privacy.py: 108 passed, 9 skipped (POSIX permission tests skipped on Windows).secfoo.mcp+secfoo.config): 93% (mcp.py), 83% (config.py), 91% combined.secfoo sensor conformance -- python -m secfoo.sensor -m secfoo.runtime.conformance.sample_app: 6/6 checks passed.secfoo skills validate examples/skills: 2 valid, 0 problem(s).python scripts/check_pypi_version.py:__about__.py: 0.3.2.dev0 PyPI: 0.3.1(exit 0).ruff check: passed with 0 errors on all modified files (0 new findings insrc/secfoo/cli.py).