Codex MCP Server

An MCP server connecting Claude, Cursor, and other AI assistants to OpenAI Codex CLI · npm package @trishchuk/codex-mcp-tool · How I use it as an outside advisor to Claude Code →

npm ↗ GitHub ↗ Releases ↗

MCP server connecting Claude/Cursor to Codex CLI. Enables code analysis via @ file references, multi-turn conversations, sandboxed edits, and structured change mode.

Features

Quick Start

claude mcp add codex-cli -- npx -y @trishchuk/codex-mcp-tool

Prerequisites: Node.js 18+, Codex CLI installed and authenticated.

Configuration

{
  "mcpServers": {
    "codex-cli": {
      "command": "npx",
      "args": ["-y", "@trishchuk/codex-mcp-tool"]
    }
  }
}

Config locations: macOS: ~/Library/Application Support/Claude/claude_desktop_config.json | Windows: %APPDATA%\Claude\claude_desktop_config.json

Usage Examples

// File analysis
'explain the architecture of @src/'
'analyze @package.json and list dependencies'

// With specific model
'use codex with model gpt-5.6-sol to analyze @algorithm.py'

// Multi-turn conversations (v1.4.0+)
'ask codex sessionId:"my-project" prompt:"explain @src/"'
'ask codex sessionId:"my-project" prompt:"now add error handling"'

// Brainstorming
'brainstorm ways to optimize CI/CD using SCAMPER method'

// Sandbox mode
'use codex sandbox:true to create and run a Python script'

// Web search
'ask codex search:true prompt:"latest TypeScript 5.7 features"'

// Local OSS model (Ollama)
'ask codex localProvider:"ollama" model:"qwen3:8b" prompt:"explain @src/"'

Tools

ToolDescription
ask-codexExecute Codex CLI with files, models, sessions, and safety controls
batch-codexRun multiple atomic Codex tasks sequentially or concurrently
review-changesRun the native non-interactive Codex review command
do-actExecute, verify with a shell command, and retry fixes
brainstormGenerate ideas with structured creative frameworks
list-sessionsView, delete, or clear MCP conversation mappings
list-skillsList skills visible from the selected workspace
healthDiagnose CLI installation, version, features, and sessions
fetch-chunkRetrieve a chunk from cached change-mode output
pingTest the MCP connection
helpReturn current codex --help output
versionReport Codex CLI, Node.js, platform, and package versions
timeout-testExercise keepalive and timeout behavior

Models

By default the model parameter is omitted and Codex CLI applies the default model from your ~/.codex/config.toml (for example model = "gpt-5.6-sol"). Pass model only when you need to override the configured default for a single call. Reasoning depth is calibrated per tool:

ModelRecommendation
gpt-5.6-solComplex, ambiguous, high-value work; strongest default
gpt-5.6-terraEveryday coding with a better capability/cost balance
gpt-5.6-lunaClear, repeatable, high-volume tasks
gpt-5.5Previous-generation fallback
gpt-5.4Professional coding fallback
gpt-5.4-miniSmall, fast, cost-efficient fallback

GPT-5.6 Sol and Terra can expose max and ultra reasoning. ultra may delegate work to subagents; most tasks should remain on medium or high.

Key Features

Session Management (v1.4.0+)

Multi-turn conversations with workspace isolation:

{ "prompt": "analyze code", "sessionId": "my-session" }
{ "prompt": "continue from here", "sessionId": "my-session" }
{ "prompt": "start fresh", "sessionId": "my-session", "resetSession": true }

Environment:

Local OSS Models (v1.6.0+)

Run with local Ollama or LM Studio instead of OpenAI:

// Ollama
{ "prompt": "analyze @src/", "localProvider": "ollama", "model": "qwen3:8b" }

// LM Studio
{ "prompt": "analyze @src/", "localProvider": "lmstudio", "model": "my-model" }

// Auto-select provider
{ "prompt": "analyze @src/", "oss": true }

Requirements: Ollama running locally with a model that supports tool calling (e.g. qwen3:8b).

Advanced Options

ParameterDescription
modelModel selection
sessionIdEnable conversation continuity
sandboxCompatibility automation: workspace-write + never
searchEnable web search
changeModeStructured OLD/NEW edits
addDirsAdditional writable directories
toolOutputTokenLimitCap response verbosity (100–10,000)
reasoningEffortlow, medium, high, xhigh, max, ultra
ossUse local OSS model provider
localProviderLocal provider: lmstudio or ollama
strictConfigFail on unknown Codex configuration keys
ephemeralDo not persist Codex session files
ignoreUserConfigIgnore $CODEX_HOME/config.toml
ignoreRulesIgnore execpolicy .rules files

CLI Compatibility

Validated against Codex CLI 0.144.3. The server keeps older feature guards, but current releases are recommended. Notable current behavior:

Migration (v2.3.x → v2.4.0): Codex CLI 0.144.3 compatibility audit; added GPT-5.6 Sol/Terra/Luna, max/ultra reasoning, current exec flags, native-only search, and safe compatibility handling for the removed --full-auto flag and on-failure approval policy.

Troubleshooting

codex --version    # Check CLI version
codex login        # Authenticate

Use the health tool for diagnostics: 'use health verbose:true'


Further Reading