Codex
@ask-llm/mcp default gpt-6.2-sol → fallback gpt-6.1-terra
OpenAI's Codex CLI is the workhorse reviewer of the pair: code reasoning for targeted reviews, architecture critique, and diff analysis. Claude asks Codex; Codex asks Claude back through the same Ask LLM installation.
Best for: targeted code reasoning, architecture critique, and security review of specific files, the default workhorse reviewer. Not for: whole-repository reads beyond its context window (use Gemini or Antigravity), or fully offline/air-gapped use (it's a hosted model; use Ollama).
Installation
1. Provider CLI (install and sign in yourself)
npm install -g @openai/codex2. Connect Ask LLM to your assistant
npm i -g @ask-llm/mcp && ask-llm setupSetup registers the unified Ask LLM server, which consults Codex through the ask-llm tool with provider: "codex". In Claude Code, the plugin that setup installs also connects the ask-codex tool. In Codex itself, setup installs the workflows and prints the codex mcp add command for you to run; see Install. The tools listed below are those of the Codex server that the Claude Code plugin bundles from @ask-llm/mcp. It replaces the retired standalone @ask-llm/codex-mcp package; see Migration to move an earlier installation to the setup registration.
Prerequisites
- Node.js v24.0.0 or higher
- Codex CLI installed and authenticated. Both GPT-6.2 models were verified on 0.167.0 with a ChatGPT subscription.
Tools
| Tool | Purpose |
|---|---|
ask-codex | Send prompts to Codex CLI. Optional reasoningEffort, noFallback, and outputSchema. Omit sessionId for an ephemeral call, pass sessionId: "" to start a persisted thread, or pass a returned thread ID to resume it |
ask-codex-edit | Propose structured code edits via a read-only codex exec --output-schema pass. Returns edit blocks for the calling client to apply |
get-usage-stats | Per-session token totals + breakdowns. In-memory |
ask-codex-write | Run explicit file-writing tasks, including image generation, with workspace-write permission. Replaces ask-codex({ sandbox: "workspace-write" }) |
ping | Fast connection test to verify MCP setup |
ask-codex, ask-codex-write, and ask-codex-edit return both human-readable text and a structured AskResponse (provider, response, model, sessionId, usage) via MCP outputSchema. Calls are ephemeral by default for privacy: a Thread ID from a call that omitted sessionId is not resumable. To opt into continuity, pass sessionId: "" on the first call; its returned Thread ID is the same value as structuredContent.sessionId, and can be passed back on later calls.
ask-codex and unified ask-llm with Codex show an attribution line before the answer, for example Codex CLI · selected gpt-6.2-astra · reasoning effort configured high. The structured model and reasoningEffort fields reflect the configuration of the successful attempt, including a successful fallback. A cached answer is labelled cached and carries its original configuration with no fresh usage stats. These fields describe Ask LLM's selection and configuration. Independent backend model and reasoning effort are unverified.
For read-only Codex calls, set noFallback: true to bypass the response cache and make one model attempt with the exact model or the normal default. This also bypasses any preferred model even if preferred: true was supplied. The attempt must exit successfully with a completed turn and a nonempty answer. This option is available on ask-codex and on unified ask-llm with provider: "codex".
Requesting a JSON reply
Pass outputSchema to ask-codex to send a strict JSON Schema to Codex. Use an object at the root. For every object, set additionalProperties: false and list every property in required. For a value that can be absent, include null in its type.
{
"prompt": "Summarize the design in one sentence.",
"outputSchema": {
"type": "object",
"properties": { "summary": { "type": "string" } },
"required": ["summary"],
"additionalProperties": false
}
}A valid reply appears as parsed JSON in structuredContent.structuredResult. The original model text remains in structuredContent.response and in the readable reply. If the model's text cannot be parsed or fails the schema, both surfaces retain that text and report a validationError. When Codex rejects the schema itself, the call returns an error with guidance for correcting it.
Schema calls bypass the response cache. Pass the schema on each turn that needs structured output, including when resuming with sessionId. The usual model selection and quota fallback apply. Set noFallback: true for a single attempt.
Models
- Default:
gpt-6.2-sol - codex-pair:
gpt-6.2-sol(GPT-6.2 Sol) athigheffort. Quota fallback stays Terra - Explicit Astra:
gpt-6.2-astra, also used by/astra-reviewathigheffort - Quota fallback:
gpt-6.1-terra, the cheaper, faster GPT-6.1 tier - Overrides:
ASK_CODEX_MODEL,ASK_CODEX_FALLBACK_MODEL, or the per-callmodelparameter
Key Features
- GPT-6.2 Sol access via the official Codex CLI
- Reasoning control: ordinary calls default to
medium;/codex-reviewand/brainstormusehigh; direct calls can requestlow,medium,high,xhigh,max, orultra.ultrais opt-in only (maximum reasoning with automatic task delegation) and is not a review default - Native session continuity: omit
sessionIdfor an ephemeral one-off call; passsessionId: ""on turn one to persist a thread, then pass its returnedthread_idon later turns. Follow-ups usecodex exec resume <id>with the stable-c sandbox_mode="<mode>"grammar (zero replay cost, Codex retains state). - Read-only, non-interactive sandbox: fresh calls use
codex exec --sandbox read-only; resumed calls use the equivalent supported config override-c sandbox_mode="read-only". Both keep second-opinion, review, and edit-proposal calls from modifying the workspace. Codexexecis non-interactive by definition, so no approval prompt can hang the MCP subprocess.ask-codexaccepts onlysandbox: "read-only". Use the separateask-codex-writetool for file creation (e.g./codex-image); it usesworkspace-writeand advertises write access. The unifiedask-llmtool also accepts explicitsandbox: "workspace-write"and is marked writable. - JSONL output parsing for structured responses + token usage
- Automatic quota fallback from GPT-6.2 Sol to Terra
- Structured AskResponse via outputSchema for programmatic clients
- Standard MCP transport works with 40+ clients
npm
- Package: @ask-llm/mcp, which bundles the Codex provider
- Binary:
ask-llm(setup and diagnostics) andask-llm-mcp(the server) - The standalone
@ask-llm/codex-mcppackage and itsask-codex-mcpbinary are retired; see Migration.