codex-mcp-bridge
This server wraps the OpenAI Codex CLI as an MCP bridge, exposing AI-powered tools for code execution, web search, text analysis, code review, structured output, session management, and health monitoring, with subprocess isolation and concurrency control.
AI Code Execution (
codex): Run prompts with file context, resume sessions, control sandbox levels (read-only,workspace-write,full-auto), and adjust reasoning effort. Supports multi-turn conversations and automatic model fallback on quota exhaustion.Web Search (
search): Query the web and receive synthesized answers with source URLs.Lightweight Text Analysis (
query): Analyze or critique provided text without repo context.Native Code Review (
review): Diff-aware review of uncommitted changes, a base branch, or a specific commit in a git repository.Structured Output (
structured): Generate JSON validated against a caller-supplied JSON Schema.Session Management (
listSessions): List active sessions with metadata (turn count, model, timestamps) for orchestration.Health Checks (
ping,mcpStatus): Verify CLI installation and authentication, report concurrency diagnostics (activeCount,queueDepth), and state of other MCP servers.Isolation & Concurrency: Environment allowlisting, no shell escape, secret redaction, FIFO-queued concurrency (default max 3 parallel spawns), and partial response capture on timeout.
Integrates with OpenAI's Codex CLI to provide code execution, web search, and structured output capabilities.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@codex-mcp-bridgereview the current branch for security issues"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
codex-mcp-bridge
MCP server that wraps Codex CLI as a subprocess, exposing code execution, web search, and structured output as Model Context Protocol tools.
Works with any MCP client: Claude Code, Gemini CLI, Cursor, Windsurf, VS Code, or any tool that speaks MCP.
Do you need this?
If you're in a terminal agent (Claude Code, Codex CLI, Gemini CLI) with shell access, call Codex CLI directly. It's faster, cheaper, and zero overhead:
# Review current branch vs main
codex review --base main
# Review uncommitted changes
codex review --uncommitted
# Review with custom focus
codex review --base main "Focus on security and error handling"
# From a worktree (run inside the worktree; `-C` is broken for `review`)
cd /path/to/worktree && codex review --base main
# General analysis
codex exec "Analyze src/utils/parse.ts for edge cases"Use this MCP bridge instead when:
Your client has no shell access (Cursor, Windsurf, Claude Desktop, VS Code)
You need structured output with JSON Schema validation (Codex CLI's
--jsonhas known bugs)You need partial response capture on timeout and automatic model fallback on quota exhaustion
You want subprocess isolation: explicit env allowlist, no shell escape, secret redaction on output, FIFO-queued concurrency (max 3 parallel spawns, configurable via
CODEX_MAX_CONCURRENT)You need multi-turn conversations via session resume (
sessionId/resetSession, inspected vialistSessions)
Worktree note: Codex CLI issue #9084
breaks codex -C /path review .... Run codex review from inside the worktree to avoid it.
Related MCP server: codex-mcp-server
Quick Start
npx codex-mcp-bridgePrerequisites
Codex CLI installed (
npm i -g @openai/codex)OPENAI_API_KEYenvironment variable set, orcodex auth logincompleted
Claude Code
claude mcp add codex-bridge -- npx -y codex-mcp-bridgeGemini CLI
Add to ~/.gemini/settings.json:
{
"mcpServers": {
"codex-bridge": {
"command": "npx",
"args": ["-y", "codex-mcp-bridge"]
}
}
}Cursor / Windsurf / VS Code
Add to your MCP settings:
{
"codex-bridge": {
"command": "npx",
"args": ["-y", "codex-mcp-bridge"],
"env": {
"OPENAI_API_KEY": "sk-..."
}
}
}Tools
Tool | Description |
codex | Execute prompts with file context, session resume, and sandbox control. Multi-turn conversations via session IDs. Use for free-form review prompts; see Code review with this CLI. |
review | Native diff-aware Codex review via |
search | Web search via |
query | Lightweight text analysis. No repo context, no sessions. Runs in an isolated temp directory. |
structured | JSON Schema validated output via Ajv. Data extraction, classification, or any task needing machine-parseable output. |
ping | Health check with CLI version, capabilities, and concurrency diagnostics ( |
mcpStatus | Report what Codex says about each MCP server it knows about: auth type, tool inventory, and whether it initialized. Optional diagnostic mode adds explicit failure states and error text. |
listSessions | List active conversation sessions with metadata (turn count, model, timestamps). |
codex
General-purpose execution. Supports multi-turn conversations via sessionId, sandbox levels (read-only, workspace-write, full-auto), and reasoning effort control. Pass resetSession: true to discard and start fresh. Use listSessions to inspect active sessions before resuming.
Key parameters: prompt (required), files, model, sessionId, sandbox, reasoningEffort, workingDirectory, timeout (default 60s).
search
Web search powered by OpenAI's native search infrastructure via Codex CLI's --search flag. Returns synthesized answers with source URLs.
Key parameters: query (required), model, workingDirectory, timeout (default 120s).
query
Lightweight, non-agentic text analysis. Spawns in an isolated temp directory so the bridge's repo context doesn't leak. Pass text to analyze in the context parameter. Supports reasoningEffort and maxResponseLength.
Key parameters: prompt (required), context, model, reasoningEffort, timeout (default 60s).
review
Thin wrapper around Codex CLI's native diff-aware review. The bridge passes the diff selector to codex exec review --json; upstream Codex owns the review prompt. Requires a real git repository via workingDirectory.
Key parameters: mode (required: uncommitted, base, or commit), workingDirectory (required), base (required for base mode), commit (required for commit mode), title, model, timeout (default 180s).
structured
Embeds a JSON Schema in the prompt and validates the response with Ajv. Returns clean JSON on success, validation errors on failure.
Key parameters: prompt (required), schema (required, JSON string), files, model, workingDirectory, timeout (default 60s).
ping
No parameters. Returns CLI version, auth status, model configuration, and concurrency diagnostics (activeCount, queueDepth).
mcpStatus
Reports per-server MCP state as Codex's own app-server protocol sees it. Unlike every other tool, it deliberately does not suppress Codex's MCP servers or harden the subprocess environment, because both would disable the thing being measured. It therefore boots the servers in ~/.codex/config.toml and is slower than a normal call.
Key parameters: diagnostics (default false), workingDirectory, timeout (per-request, default 90s).
Mode | Cost | What you get |
default | ~6-9s | Inventory: auth type, tool names and counts, and |
| ~10-20s | Adds an explicit |
Reading the output:
unknownis not a failure. It means the inventory carried no server info and no explicit verdict was available. Onlydiagnostics: truecan reportfailed.A
degradedwarning means don't trustunknown. Slow calls have been observed reporting healthy servers as uninitialized, so the tool reports how long the underlying call took and flags the result when it was slow enough to be suspect.builtInmarks a server Codex injects that is not in your config;configuredButUnreportedmarks one in your config that Codex never mentioned.
Example:
atlassian failed auth=oAuth tools=0
error: MCP client for `atlassian` failed to start: MCP startup failed: failed to
refresh OAuth tokens for server atlassian: ... invalid_grant: Grant not found
codex_apps initialized auth=bearerToken tools=117 (builtIn)
linear initialized auth=oAuth tools=57
serena initialized auth=unsupported tools=22All tools attach execution metadata (_meta) with durationMs, model, fallbackUsed, and session info where applicable. See DESIGN.md for details.
Code review with this CLI
This bridge does not bundle reviewer prompts. There are three paths for code review:
Native upstream codex review
codex review --base main
codex review --uncommitted
codex review --base main "Focus on security and error handling"Diff-aware review built into Codex CLI. No bridge involvement. Use this when your client has shell access.
Bridge review tool for native diff-aware review
{
"tool": "review",
"arguments": {
"mode": "base",
"base": "main",
"workingDirectory": "/path/to/worktree"
}
}The bridge runs codex exec review --json from workingDirectory, captures the final review text, and returns review metadata such as threadId, event counts, and redacted command output. It does not accept a prompt.
Bridge codex tool with caller-supplied prompt
{
"tool": "codex",
"arguments": {
"prompt": "<your review prompt + diff or file references>",
"sandbox": "read-only"
}
}The bridge runs codex exec --sandbox read-only with the supplied prompt and returns stdout. Use this for free-form review prompts or review inputs that are not expressible as uncommitted, base, or commit diff selectors.
Representative review prompt
A starting point; adapt freely:
Review the following diff:
<diff content>
Look for:
- Bugs that would surface in production
- Missing error handling on user-supplied input
- Tests modified to silence failures rather than verify behaviour
- Security issues (injection, missing auth checks, secret leaks)
For each finding cite file:line, severity (high/medium/low), and a suggested fix.
Skip style/formatting; assume an autoformatter handles those.The bridge has no opinion on prompt content. See ADR-001 for the rationale.
Configuration
Variable | Default | Description |
| (CLI default) | Default model for all tools |
|
| Fallback on quota exhaustion ( |
|
| Path to CLI binary |
|
| Max concurrent subprocess spawns |
| (unset) | Control which Codex internal MCP servers stay enabled. See DESIGN.md. |
Choosing a Codex MCP server
You need... | Consider |
Structured output, model fallback, concurrency management, session resume | This bridge |
Session threading with | |
Structured patch output with approval policies | |
Minimal | |
Native Codex MCP (experimental, no wrapper needed) |
|
Performance
Codex CLI has minimal startup overhead (<100ms), so wall time is dominated by model inference.
Scenario | Typical time |
Trivial prompt | 9-12s |
Web search | ~17s |
Default timeouts (60-300s) are comfortable for typical workloads.
Bridge family
Two MCP servers, same architecture, different underlying CLIs. Each wraps a terminal agent as a subprocess and exposes it as MCP tools. Pick the one that matches your model provider, or run both for cross-model workflows.
CLI | Codex CLI | Claude Code |
Provider | OpenAI | Anthropic |
Tools | codex, review, search, query, structured, ping, listSessions | query, review, search, structured, ping, listSessions |
Code review |
|
|
Structured output | Ajv validation | Native |
Session resume | Session IDs with multi-turn | Native |
Budget caps | Not supported | Native |
Effort control |
|
|
Cold start | <100ms (inference dominates) | ~1-2s |
Auth |
|
|
Cost | Pay-per-token | Subscription (included) or API credits |
Concurrency | 3 (configurable) | 3 (configurable) |
Model fallback | Auto-retry with fallback model | Auto-retry with fallback model |
Both share: subprocess env isolation, path sandboxing, output redaction (secret stripping), FIFO concurrency queue, MCP tool annotations, _meta response metadata, progress heartbeats.
Development
npm install
npm run build # Compile TypeScript
npm run dev # Watch mode
npm test # Run tests
npm run lint # ESLint
npm run typecheck # tsc --noEmitFurther reading
DESIGN.md - Architecture, MCP server control grammar, sessions, output parsing, response metadata
SECURITY.md - Environment isolation, path sandboxing, output redaction, resource limits
CHANGELOG.md - Release history
License
MIT
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityBmaintenanceLocal MCP server that wraps the headless Claude Code CLI as MCP tools, providing stateless access to Claude's coding capabilities through prompt-based interactions. It enables users to execute Claude Code commands with various prompt formats and structured outputs directly from MCP clients.3MIT
- Alicense-qualityCmaintenanceWraps OpenAI Codex CLI as an MCP server, exposing 8 Codex tools (exec, review, skill list, skill run, status, poll, list jobs, kill) as named tools for use with pi or codex.2,559ISC
- AlicenseAqualityFmaintenanceMCP server that wraps Gemini CLI as a subprocess, exposing its capabilities as Model Context Protocol tools.51306MIT
- Alicense-qualityDmaintenanceWraps OpenAI's Codex CLI as an MCP server, enabling AI clients like KiloCode, Roo Code, and Cline to leverage Codex for code generation, debugging, and analysis through natural language.52MIT
Related MCP Connectors
A paid remote MCP for OpenAI Codex agent coordination MCP, built to return verdicts, receipts, usage
A Model Context Protocol server for Wix AI tools
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/hampsterx/codex-mcp-bridge'
If you have feedback or need assistance with the MCP directory API, please join our Discord server