feat(v1): expose MCP tools to Codex - #2140
Conversation
ApprovabilityVerdict: Needs human review Unable to check for correctness in c533f05. This PR enables MCP support in the Codex harness with new namespace normalization and configuration logic. Multiple unresolved review comments question the design approach, and the feature enablement introduces significant new runtime behavior that warrants human review. You can customize Macroscope's approvability policy. Learn more. |
0f970d7 to
778fdc1
Compare
| if mcp_urls: | ||
| prompt = "\n\n".join( | ||
| [ | ||
| "Task-specific MCP tools are already configured and directly available.", |
There was a problem hiding this comment.
we should not alter the prompt, we don't do this for other harnesses, either
| for arg in self._mcp_config_args(index, name, url) | ||
| ] | ||
| direct_mcp_namespaces = [ | ||
| f"mcp__{self._mcp_server_name(index, name)}" |
There was a problem hiding this comment.
why change mcp server names here?
| ] | ||
|
|
||
| @staticmethod | ||
| def _mcp_server_name(index: int, name: str) -> str: |
There was a problem hiding this comment.
why change mcp server names here?
| return f"vf_{index}_{label}" | ||
|
|
||
| @classmethod | ||
| def _mcp_config_args(cls, index: int, name: str, url: str) -> list[str]: |
| @pytest.mark.e2e | ||
| @pytest.mark.codex | ||
| @pytest.mark.docker | ||
| async def test_codex_resume_with_tool(run_v1, tmp_path): |
778fdc1 to
39fef46
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 39fef46. Configure here.
39fef46 to
9eb12ab
Compare
9eb12ab to
c533f05
Compare
…fload Picks up 35 main commits: the v1 structure cleanup (#2146) that retires StrictBaseModel and renames _NODE_DUMP_EXCLUDE -> EXCLUDE_FIELDS, the ruff 0.16 / ty tooling bump (#2147, #2148), runtime-on-agent + agent config stamped on the trace (#2106), Reward score/weight records (#2119), MCP tools for Codex (#2140), and assorted v1 fixes. Resolutions: - trace.py: main's restructure subsumes this branch's block wholesale — EXCLUDE_FIELDS already carries multi_modal_data, and TRACE_VERSION=1 is main's deliberate reset (this branch never touched it). Took main. - graph.py: kept the raw-mm sidecar validators and previous_multi_modal_data; adopted main's plain BaseModel now that StrictBaseModel is gone. - clients/train.py: kept the is_multimodal import — still used by the bridge path that threads previous_multi_modal_data. Ruff 0.16 flagged two spots this branch added that main's cleanup pass never saw: a constant getattr in the ingress offload walker, and the blind except at the prepare_request_body boundary (annotated noqa, per main's own convention at rollout boundaries).

Summary
Validation
uv run ruff check --fix .uv run pytest tests/— 909 passed, 63 skipped (credentialed e2e cases requirePRIME_API_KEY)uv run pre-commit run --all-filesty (ci parity)Note
Medium Risk
Changes how Codex is launched with external MCP dependencies and namespace mapping; misconfiguration could break tool exposure or resume segments, but scope is limited to the Codex harness.
Overview
Codex rollouts can now use task MCP HTTP servers on both initial
execandexec resume --lastsegments, aligned with other agent harnesses.CodexHarnesssetsSUPPORTS_MCP = Trueand threadsmcp_urlsinto_config_args, which emits a single-c mcp_servers={...}table (so dotted server IDs are not split as TOML paths) withrequired=trueand fixed startup/tool timeouts. When MCP is present, it also setsfeatures.code_mode.direct_only_tool_namespacesusing namespaces derived from server names—sanitizedmcp__prefixes, SHA1 suffixes on collisions, and 49-character truncation—to match Codex v0.144.5’s exposed tool namespaces while keeping Verifiers server IDs unchanged in config.Reviewed by Cursor Bugbot for commit c533f05. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Expose MCP tools to Codex by passing server URLs and namespaces through
CodexHarnessSUPPORTS_MCP = TrueonCodexHarnessso the harness advertises MCP capability at runtime.launchandresumein harness.py to passmcp_urlsinto_config_args._config_argsnow builds a TOMLmcp_serversconfig entry (withrequired=true, 60s startup timeout, 600s tool timeout) and afeatures.code_mode.direct_only_tool_namespaceslist from the provided URLs.[a-zA-Z0-9_]chars replaced with_,mcp__prefix enforced), collision-detected with a 12-hex SHA1 suffix, and truncated to 49 chars if needed.Macroscope summarized c533f05.