This document outlines the integration with OpenAI Codex CLI v0.75.0+, highlighting breaking changes, new features, and implementation details for the MCP server wrapper.
This MCP server is optimized for codex CLI v0.75.0 or later for full feature support.
Version History:
- v0.75.0: Added
codex reviewcommand, sandbox modes, full-auto mode - v0.74.0: Introduced
gpt-5.2-codexmodel - v0.50.0: Introduced
--skip-git-repo-checkflag, removed--reasoning-effortflag - v0.36.0-v0.49.x: Not compatible with this MCP server version (use older MCP releases)
- Resume command moved under exec
- Old:
codex resume <id> - New:
codex exec resume <id> - Impact: MCP server updated to use new command structure
- Old:
-
--skip-git-repo-checkflag now required- Required when running outside git repositories or in untrusted directories
- Prevents "Not inside a trusted directory" errors
- Impact: All exec-based MCP server commands include this flag
-
--reasoning-effortflag changed- The standalone flag was removed in codex CLI v0.50.0
- Now passed via
-c model_reasoning_effort=<level>config flag - Impact: MCP server updated to use new config-based approach
- Authentication Method Change
- Old Method:
OPENAI_API_KEYenvironment variable - New Method:
codex login --api-key "your-api-key" - Storage: Credentials now stored in
CODEX_HOME/auth.json - Impact: Users must re-authenticate using the new login command
- Old Method:
- Command:
codex review(top-level subcommand) - CLI Flags:
--uncommitted: Review staged, unstaged, and untracked changes--base <branch>: Review changes against a base branch--commit <sha>: Review changes introduced by a specific commit--title <title>: Optional title for review summary
- MCP Tool: New
reviewtool with all parameters exposed
- CLI Flag:
--sandbox <mode> - Modes:
read-only: No file writes allowedworkspace-write: Writes only in workspace directorydanger-full-access: Full system access (dangerous)
- MCP Parameter:
sandboxparameter in codex tool
- CLI Flag:
--full-auto - Description: Sandboxed automatic execution without approval prompts
- Equivalent to:
-a on-request --sandbox workspace-write - MCP Parameter:
fullAutoboolean parameter
- CLI Flag:
-C <dir> - Description: Set working directory for the agent (global option)
- MCP Parameter:
workingDirectoryparameter in codex tool and review tool
- Default Model:
gpt-5.2-codex(optimal for agentic coding tasks) - CLI Flag:
--model <model-name> - Supported Models:
gpt-5.2-codex(default, specialized for agentic coding)gpt-5.1-codex(previous coding model)gpt-5.1-codex-max(enhanced coding)gpt-5-codex(base GPT-5 coding)gpt-4o(fast multimodal)gpt-4(advanced reasoning)o3(OpenAI reasoning model)o4-mini(compact reasoning model)
- Usage: Model parameter available in
exec,resume, andreviewmodes (use-c model="..."for review/resume)
- CLI Flag:
-c model_reasoning_effort="<level>" - Levels:
minimal,low,medium,high - MCP Parameter:
reasoningEffortparameter in codex tool - Note: The standalone
--reasoning-effortflag was removed in v0.50.0, now uses quoted config values for consistency
- Command:
codex exec resume <conversation-id> - Automatic ID Extraction: Server extracts conversation IDs from CLI output (supports both "session id" and "conversation id" formats)
- Regex Pattern:
/(conversation|session)\s*id\s*:\s*([a-zA-Z0-9-]+)/i - Fallback Strategy: Manual context building when resume unavailable
- Session Integration: Seamless integration with session management
- Output: Codex CLI emits
threadIdin MCP responses - Server Behavior: This MCP server surfaces
threadIdin tool response metadata and content element metadata when present.structuredContentis only emitted whenSTRUCTURED_CONTENT_ENABLEDis truthy and is disabled by default. - Regex Pattern:
/thread\s*id\s*:\s*([a-zA-Z0-9_-]+)/i - Structured Output: The codex tool advertises an
outputSchemaforstructuredContent(currentlythreadId) when enabled.
The following Codex CLI features are not currently exposed through the MCP server:
| Feature | CLI Flag | Notes |
|---|---|---|
| Image Attachments | -i, --image |
Attach images to prompts |
| OSS/Local Models | --oss, --local-provider |
LMStudio/Ollama support |
| Config Profiles | -p, --profile |
Named configuration profiles |
| Approval Policy | -a, --ask-for-approval |
Fine-grained approval control |
| Additional Dirs | --add-dir |
Extra writable directories |
| JSON Output | --json |
JSONL event stream output |
| Output Schema | --output-schema |
Structured JSON output |
| Output File | -o, --output-last-message |
Write response to file |
These features may be added in future versions based on user demand.
Note: This MCP server provides web search capability through the dedicated websearch tool. The tool uses codex --search exec to enable Codex's native web_search tool, providing:
- Customizable result count (1-50 results)
- Search depth control (basic/full)
- Streaming progress updates
- Integration with Codex's search-enabled models
See the Tools section in README.md for usage examples.
Codex CLI added static MCP callback URI support. This MCP server forwards the callback URI via environment variable when provided.
- Env Var:
CODEX_MCP_CALLBACK_URI - MCP Parameter:
callbackUri(takes precedence over the env var)
IMPORTANT: All exec options (--model, -c, --skip-git-repo-check, -C, --sandbox, --full-auto) must come BEFORE subcommands (resume).
// Basic execution (v0.75.0+)
['exec', '--model', selectedModel, '--skip-git-repo-check', prompt]
// Execution with new parameters (v0.75.0+)
['exec', '--model', selectedModel, '--sandbox', 'workspace-write', '--full-auto', '-C', workingDir, '--skip-git-repo-check', prompt]
// Resume mode (v0.75.0+) - All exec options BEFORE 'resume' subcommand
['exec', '--skip-git-repo-check', '-c', 'model="modelName"', '-c', 'model_reasoning_effort="high"', 'resume', conversationId, prompt]
// Code review (v0.75.0+)
['-C', workingDir, 'review', '-c', 'model="modelName"', '--uncommitted', '--base', 'main', prompt]
// Code review with model config before subcommand (also accepted)
['-C', workingDir, '-c', 'model="modelName"', 'review', '--uncommitted', '--base', 'main', prompt]Important: Resume Mode Limitations
The codex exec resume subcommand has a limited set of flags compared to codex exec:
- ✅
-c, --config- Configuration overrides (use for model selection) - ✅
--enable/--disable- Feature toggles - ❌
--model- Not available (use-c model="..."instead) - ❌
--sandbox- Not available in resume mode - ❌
--full-auto- Not available in resume mode - ❌
-C- Not available in resume mode ⚠️ --skip-git-repo-check- Must be placed onexeccommand BEFOREresumesubcommand
Important: Review Mode Limitations
The codex review subcommand also has limited flags:
- ✅
-c, --config- Configuration overrides (use for model selection) - ✅
--uncommitted,--base,--commit,--title- Review-specific flags - ✅
--enable/--disable- Feature toggles - ❌
--model- Not available (use-c model="..."instead) - ❌
--sandbox- Not available in review mode - ❌
--full-auto- Not available in review mode - ✅
-C- Global option beforereview ⚠️ -cis accepted bycodex reviewand can also be passed beforereviewas a global option
Key Changes in v0.75.0:
- Added:
codex reviewsubcommand for code reviews - Added:
--sandboxflag for sandbox modes (exec only) - Added:
--full-autoflag for automatic execution (exec only) - Changed:
codex resumemoved tocodex exec resume - Note: Resume subcommand and review command have limited flag support
Key Changes in v0.50.0:
- Added:
--skip-git-repo-checkflag (exec only) - Changed:
--reasoning-effortto-c model_reasoning_effort=<level>
const conversationIdMatch = result.stderr?.match(/conversation\s*id\s*:\s*([a-zA-Z0-9-]+)/i);
if (conversationIdMatch) {
sessionStorage.setCodexConversationId(sessionId, conversationIdMatch[1]);
}- Authentication Errors: Clear messaging for login requirement
- Model Validation: Graceful handling of invalid model names
- Network Issues: Proper error propagation and user feedback
- CLI Availability: Detection of missing Codex CLI installation
-
Check Current Version:
codex --version
-
Update Codex CLI (if below v0.75.0):
npm update -g @openai/codex # or brew upgrade codex -
Verify Version (must be v0.75.0 or later):
codex --version # Should show v0.75.0 or higher -
Test New Features:
# Test code review codex review --uncommitted # Test sandbox mode codex exec --sandbox workspace-write --skip-git-repo-check "list files"
-
Install Codex CLI (v0.75.0+):
npm install -g @openai/codex # or brew install codex -
Verify Version:
codex --version # Must be v0.75.0 or later -
Authenticate:
codex login --api-key "your-openai-api-key" -
Configure (Optional):
# Edit ~/.codex/config.toml to set preferences # Example: # model = "gpt-5.2-codex" # model_reasoning_effort = "medium"
-
Test Setup:
codex exec --skip-git-repo-check "console.log('Hello, Codex!')"
- Default to gpt-5.2-codex: Optimal for agentic coding without configuration
- Context-Aware Suggestions: Better model recommendations based on task type
- Consistent Experience: Same model across session interactions
- Native Resume Priority: Use Codex's built-in conversation continuity
- Fallback Context: Only when native resume unavailable
- Token Optimization: Minimal context overhead for better performance
- Graceful Degradation: Continue operation despite CLI issues
- Automatic Retry: For transient network issues
- Clear Error Messages: Actionable feedback for user troubleshooting
- CLI Command Validation: Verify correct parameter passing
- Conversation ID Extraction: Test various output formats
- Error Scenario Handling: Comprehensive failure mode coverage
- Malformed CLI Output: Handle unexpected response formats
- Network Interruptions: Graceful handling of connectivity issues
- Model Availability: Handle model deprecation or unavailability
- Always specify model explicitly when behavior consistency is critical
- Use appropriate reasoning effort based on task complexity
- Implement proper error handling for CLI interactions
- Monitor session lifecycle to prevent memory leaks
- Start with default settings for optimal experience
- Use sessions for complex tasks requiring multiple interactions
- Choose reasoning effort wisely to balance speed and quality
- Keep CLI updated for latest features and bug fixes
-
Authentication Failures
- Solution: Run
codex login --api-key "your-key" - Verify: Check
CODEX_HOME/auth.jsonexists
- Solution: Run
-
Model Not Available
- Solution: Use default
gpt-5.2-codexor try alternative models - Check: Codex CLI documentation for available models
- Solution: Use default
-
Resume Functionality Not Working
- Solution: System falls back to manual context building
- Check: Conversation ID extraction in server logs
-
Performance Issues
- Solution: Lower reasoning effort or use faster models
- Monitor: Response times and adjust parameters accordingly