Currently Available: Need a skilled Software Developer for your next project?
Categories
Coding Agents

How to Call Codex CLI from Claude Code for a Second Opinion: `codex exec` vs. `codex mcp-server`

When Claude Code reviews a code change, you can have it ask OpenAI’s Codex command-line interface (CLI) to review the same project separately. You do this with codex exec, which lets Claude Code run Codex on a single task and read its output once the command finishes.

You may still come across older guides that recommend codex mcp-server, which relied on MCP, the Model Context Protocol to let an AI client connect to tools on a server. OpenAI removed the Codex MCP server on September 5, 2026. Because of that change, you should use codex exec for a second opinion and treat old Codex MCP-server setup instructions as outdated unless OpenAI’s migration guidance confirms a supported path for your version.

Ask Codex for a focused review with codex exec

Run Codex from the project directory and tell it what to inspect. For example:

codex exec "Review the current changes for correctness risks and missing edge cases. Do not edit files."

Your prompt defines the review task, and Codex runs as a separate command-line process. OpenAI documents codex exec for repeatable workflows and pipelines. When you give Codex a narrow question, such as whether a change handles invalid input or introduces a correctness risk, it has a clear target to check.

Claude Code does not automatically pass its conversation history to Codex. You need to include the problem description and review criteria in the prompt, and you need to make sure Codex can read the files you want it to inspect. If you want both tools to follow the same project rules, you can keep shared instruction files such as AGENTS.md and CLAUDE.md in the repository; see how to share project instructions.

Writing “Do not edit files” in the prompt tells Codex what you want, though it does not enforce that limit on its own. A sandbox setting restricts what Codex can touch. For a code review, turn on a read-only sandbox option if your installed CLI supports one. Because flags can change between releases, check the current Codex CLI reference for the exact option and syntax.

If a script calls Codex and needs structured data back, add the --json flag. OpenAI documents that codex exec --json emits JSON Lines events, which gives your script a stream of JSON records to save or parse. That format makes logging easier, though it says nothing about whether Codex’s findings are right. You should still check the command’s exit status and error output alongside the review.

Why the MCP-server route is different

When you use codex exec, Claude Code runs a single command and reads the output when it finishes. When you use an MCP server, Claude Code connects to a running server that advertises tools for Claude Code to discover and call. Anthropic’s Claude Code MCP documentation explains that client-server model and shows how you configure MCP servers in Claude Code.

That option no longer exists for Codex, because OpenAI removed the Codex MCP server according to OpenAI’s dated notice. Claude Code’s general MCP configuration commands will not restore a server that OpenAI removed. Skip older Codex MCP setup commands unless OpenAI’s migration guidance confirms they still apply to your installed version.

Keep in mind that OpenAI only removed the ability to run Codex as an MCP server. Codex can still connect to other MCP servers to pull in external tools or context, which OpenAI walks through in its Docs MCP example.

Choose the route that works now

To get a second opinion today, run codex exec from your project directory with a focused prompt and read-only permissions so Codex cannot modify files. Add --json when a script needs to capture structured events, or leave it off when a person or calling tool only needs plain text output.

The older MCP-server setup let Claude Code discover and call Codex tools over MCP, but OpenAI removed that server, so you can no longer rely on it. The cited documentation does not compare the two approaches on speed, cost, or review quality. Use codex exec and pick the output format that fits whoever reads the result.

What I'm building

Delegate tasks. Get software.

Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.

Take a look at vroni.com

Email updates

Usually a new article and a few links I found interesting.

No spam. Unsubscribe with one click.

Leave a Reply

Your email address will not be published. Required fields are marked *