Skip to main content
Glama

Qoder in Codex

Run Qoder CLI agents as delegated subagents from ChatGPT/Codex through the Model Context Protocol (MCP).

The Codex parent agent keeps control of the conversation. It delegates a self-contained task with qoder_spawn, polls with qoder_wait, and verifies the resulting workspace changes itself. Qoder is not merely selected as a chat model: its full CLI agent loop can inspect and edit files in the allowed workspace.

This is an independent project, not an official OpenAI or Qoder integration. Qoder tasks do not appear in Codex's native /subagents list.

Features

  • Two fixed routing tiers

    • fast → DeepSeek-Flash for simple, mechanical, low-complexity tasks.

    • pro → Kimi-K3.1-Pro for everything else or when complexity is uncertain.

  • Real workspace delegation through Qoder CLI, with no tools disabled by the bridge.

  • Asynchronous lifecycle: queued, running, completed, failed, and cancelled.

  • Dynamic Codex workspaces: newly trusted Codex projects are picked up on every spawn without restarting the bridge.

  • Windows and Linux stdio MCP configurations.

  • Concurrency control: at most two tasks overall and one active task per tier; same-tier tasks queue.

  • Model auditing: returns raw modelUsage and actual_models; ambiguous audits and auto fallback fail the task.

  • Safer defaults: accept_edits, no permission-bypass flag, path validation, bounded output, redacted diagnostics, and private prompt attachments that are always cleaned up.

  • No automatic task retries and no persistent Qoder sessions created by the bridge.

Related MCP server: AI CLI MCP Server

How it works

Codex parent agent
  └─ qoder MCP stdio server
      └─ task manager and concurrency queue
          └─ Qoder CLI agent (fast or pro)
              └─ shared, validated workspace

Codex parent then inspects and accepts the actual changes.

Qoder does not inherit the parent conversation. Every delegated task must therefore include the relevant context, requirements, and acceptance criteria.

Requirements

  • Node.js 18 or newer; Node.js 24 is recommended.

  • A Codex version that supports stdio MCP servers and default_tools_approval_mode.

  • Qoder CLI CN (qoderclicn) with access to these models:

    • DeepSeek-Flash

    • Kimi-K3.1-Pro

  • A Qoder login or a Qoder CN personal access token (PAT).

The bridge has been exercised with Qoder CLI CN 1.1.74, Codex 0.153.4 on Linux, and Codex 0.166.0 on Windows.

Installation

git clone https://github.com/duyaOmega/qoder-in-codex.git
cd qoder-in-codex
npm ci
npm test

Keep the checkout at a stable absolute path. The Codex MCP configuration will start src/index.js from that directory.

Authentication

Use one of the following methods.

Option A: Qoder CLI login

Authenticate the standalone CLI according to its normal login flow:

qoderclicn login
qoderclicn --list-models

Confirm that both required models appear. If the CLI is already authenticated, no PAT-file setting is needed.

Option B: Reuse a PAT without putting it in Codex config

Create a private environment file outside all shared workspaces and allowed roots, for example:

QODERCN_PERSONAL_ACCESS_TOKEN=your_real_token

Set QODER_MCP_PAT_FILE to that file's absolute path. The bridge reads the token only when starting a Qoder task and passes it directly to the child process. It does not write the token into task results or diagnostics.

Do not commit this file, place it in the repository, or paste the real token into config.toml.

Codex MCP configuration

Merge one [mcp_servers.qoder] block into the Codex config.toml used by the Codex process. Replace every placeholder with a real absolute path.

Ready-to-edit templates are also available in deploy/codex-mcp.toml and deploy/codex-mcp.windows.toml.

Linux

[mcp_servers.qoder]
command = "/absolute/path/to/node"
args = ["/absolute/path/to/qoder-in-codex/src/index.js"]
env = { QODERCLI_PATH = "/absolute/path/to/qoderclicn", QODER_MCP_ALLOWED_ROOTS = "/home/YOUR_USER/projects", QODER_MCP_CODEX_CONFIG = "/home/YOUR_USER/.codex/config.toml", QODER_MCP_PERMISSION_MODE = "accept_edits" }
startup_timeout_sec = 10
tool_timeout_sec = 35
default_tools_approval_mode = "approve"
supports_parallel_tool_calls = true

For a remote Codex workspace, all paths—including cwd passed to the tools—are paths on the remote Linux host, not local Windows paths.

Windows

[mcp_servers.qoder]
command = "C:/Program Files/nodejs/node.exe"
args = ["C:/path/to/qoder-in-codex/src/index.js"]
env = { QODERCLI_PATH = "C:/Users/YOUR_NAME/AppData/Roaming/npm/node_modules/@qodercn-ai/qoderclicn/bundle/qoderclicn.js", QODER_MCP_ALLOWED_ROOTS = "C:/Users/YOUR_NAME/projects", QODER_MCP_CODEX_CONFIG = "C:/Users/YOUR_NAME/.codex/config.toml", QODER_MCP_PAT_FILE = "C:/Users/YOUR_NAME/.config/qoder/pat.env", QODER_MCP_PERMISSION_MODE = "accept_edits" }
startup_timeout_sec = 10
tool_timeout_sec = 35
default_tools_approval_mode = "approve"
supports_parallel_tool_calls = true

Remove QODER_MCP_PAT_FILE when using a persistent Qoder CLI login instead.

The Windows example invokes the Qoder JavaScript bundle through Node directly. This avoids .cmd shim and shell-quoting problems. Locate the installed bundle with your npm prefix if the example path differs.

After changing MCP configuration, start a new Codex session or restart Codex. Then verify registration:

codex mcp list
codex mcp get qoder

Workspace behavior

A task cwd must be an existing absolute directory and must pass validation at both queueing and execution time.

It is accepted when it is inside at least one of:

  1. QODER_MCP_ALLOWED_ROOTS, an optional list of static roots.

  2. A project marked trust_level = "trusted" in the Codex config named by QODER_MCP_CODEX_CONFIG.

Codex trusted projects are read afresh for every task. After the initial MCP setup, creating and trusting a new Codex workspace does not require another MCP restart or config edit.

Use your platform's path delimiter for multiple static roots:

  • Linux/macOS: /path/one:/path/two

  • Windows: C:/path/one;D:/path/two

When dynamic Codex trust is enabled, the bridge rejects the user-home root and the Codex configuration tree even if broad trust entries exist. Realpath checks also prevent lexical-prefix and symlink escapes. These checks are an application-level guard, not an operating-system sandbox.

Using it from Codex

Ask the Codex parent agent something like:

Use qoder_spawn in the current workspace with tier=pro.
Delegate a self-contained task to fix the failing parser test.
Use qoder_wait until the task reaches a terminal state.
Then inspect the diff and run the relevant tests yourself before reporting completion.

Use fast only for mechanical work such as a narrowly specified file generation or simple rename. Use pro for debugging, reviews, refactors, multi-step edits, and uncertain tasks.

Always let the parent agent verify the final files. A completed Qoder task is not a substitute for independent acceptance.

MCP tools

qoder_spawn

Starts a task and returns immediately.

Argument

Required

Description

task

yes

Complete, self-contained task and relevant context. Maximum 256 KiB of UTF-8 text.

cwd

yes

Absolute working directory in the MCP server's host environment.

tier

no

fast or pro; defaults to pro.

The result includes task_id, status, requested model, and workspace path.

qoder_wait

Waits briefly for a state change without blocking the MCP connection for the full task duration.

Argument

Required

Description

task_id

yes

UUID returned by qoder_spawn.

timeout_sec

no

Integer from 0 to 25; defaults to 20.

Terminal results can include final content, session ID, turn count, duration, raw modelUsage, actual_models, exit code, and a stable error object.

qoder_cancel

Cancels a queued task or terminates a running task. Cancellation is idempotent. On Linux, the bridge terminates the Qoder process group, first with TERM and then KILL after a grace period.

Real-task smoke verification

The included verifier calls qoder_spawn exactly once, polls until a terminal state, and prints the structured result. It does not retry.

The following example consumes one real Qoder task and enforces a persistent one-spawn budget:

QODERCLI_PATH=/absolute/path/to/qoderclicn \
QODER_MCP_ALLOWED_ROOTS=/absolute/path/to/workspace \
QODER_MCP_CODEX_CONFIG=/home/YOUR_USER/.codex/config.toml \
QODER_MCP_PERMISSION_MODE=accept_edits \
QODER_MCP_MAX_SPAWNS=1 \
QODER_MCP_BUDGET_FILE=/absolute/private/path/smoke-budget.json \
node scripts/verify-mcp.js \
  --tier fast \
  --cwd /absolute/path/to/workspace \
  --task "Create smoke-result.txt containing exactly SMOKE_OK and no trailing newline. Do not change any other file. Verify the file yourself."

Check the returned status and actual_models, then independently inspect smoke-result.txt.

Configuration reference

Environment variable

Default

Purpose

QODERCLI_PATH

qoderclicn

Qoder CLI executable or JavaScript bundle.

QODER_MCP_ALLOWED_ROOTS

empty

Static workspace roots separated by the platform path delimiter.

QODER_MCP_CODEX_CONFIG

unset

Codex config used to discover trusted projects dynamically.

QODER_MCP_PERMISSION_MODE

accept_edits

Qoder permission mode. Unsafe bypass modes are rejected.

QODER_MCP_PAT_FILE

unset

Optional private env file containing QODERCN_PERSONAL_ACCESS_TOKEN.

QODER_MCP_RUNTIME_DIR

system temp

Private task attachments and the default budget file.

QODER_MCP_TASK_TIMEOUT_MS

600000

Maximum Qoder task runtime.

QODER_MCP_MAX_SPAWNS

unlimited

Persistent spawn budget, useful for tests and smoke checks.

QODER_MCP_BUDGET_FILE

runtime budget file

Budget counter shared across MCP restarts.

QODER_MCP_MAX_OUTPUT_BYTES

8388608

Per-stream stdout/stderr safety limit for the CLI runner.

QODER_MCP_MAX_QUEUE

8

Maximum queued tasks.

QODER_MCP_RESULT_TTL_MS

3600000

Retention time for terminal task results.

Model audit behavior

Requested tier names and actual provider-side model identifiers are different. For example, Qoder may report internal identifiers such as dfmodel or kmodel_latest in actual_models.

The bridge fails a task when:

  • modelUsage is missing or contains multiple ambiguous models (MODEL_AUDIT_MISSING).

  • Qoder silently falls back to auto (MODEL_FALLBACK).

  • The CLI exits unsuccessfully or omits a final result record.

This prevents a successful-looking response from hiding an unintended model fallback.

Security notes

  • default_tools_approval_mode = "approve" allows Codex to call these MCP tools without a separate approval prompt. Install the bridge only if you trust it and its configuration.

  • The bridge intentionally does not expose arbitrary model names, raw extra CLI arguments, bypass_permissions, or --dangerously-skip-permissions.

  • Qoder retains its full CLI tool loop. Delegate only bounded tasks and inspect all resulting changes.

  • Keep PAT files, Codex configuration, and other credentials outside shared workspaces.

  • The path allowlist is not a substitute for OS isolation, containers, or a dedicated unprivileged account.

  • Prompt attachments are created privately and removed on every exit path. Nested Qoder SDK state is scrubbed before launching the standalone CLI.

  • Qoder sessions use --no-session-persistence.

Troubleshooting

qoder does not appear in Codex

Run codex mcp get qoder against the same Codex home used by the application. Start a new Codex session or restart the application after editing MCP config.

Not logged in or immediate CLI exit

Run qoderclicn --list-models in a clean terminal. Authenticate with qoderclicn login, or configure QODER_MCP_PAT_FILE correctly. When launching from another Qoder agent, stale nested SDK environment variables can also interfere; the bridge scrubs known nested SDK state.

CWD_OUTSIDE_ROOTS

Confirm that:

  • cwd is absolute and exists on the MCP host.

  • It is inside a configured static root or a currently trusted Codex project.

  • QODER_MCP_CODEX_CONFIG points to the same Codex config that contains the project trust entry.

  • You are not passing a Windows path to a remote Linux MCP server, or vice versa.

MODEL_FALLBACK or MODEL_AUDIT_MISSING

Inspect the returned raw modelUsage. Do not treat the task as verified. The bridge does not automatically retry it.

MCP calls require approval

Ensure the Qoder MCP block contains:

default_tools_approval_mode = "approve"

Restart or start a new Codex session after changing this setting.

Development

npm test
npm audit

The suite uses Node's built-in test runner, a fake Qoder CLI, and a real MCP stdio client. It covers configuration, trusted-workspace reloads, path escapes, attachments, output parsing, model fallback, output limits, cancellation, process-group cleanup, concurrency, budgets, TTL, and the MCP lifecycle.

Linux runs the process-group cancellation test; that Linux-only test is skipped on other platforms.

License

MIT. See LICENSE.

The implementation includes attribution to the earlier cantbeblank96/qodercli-mcp investigation, specifically v0.4.3 at commit c38fccf9bf857babe8601c77feca4966ef6477cc.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables ChatGPT conversations to directly inspect local workspaces and delegate coding tasks to a local Codex agent, with controlled concurrency, reusable sessions, and task/usage tracking.
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to delegate complex coding tasks, refactorings, and automated code reviews to OpenAI Codex and Google Antigravity CLIs, running them autonomously in YOLO mode with process supervision.
      6
      MIT
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables a primary AI coding assistant to delegate tasks to multiple specialized CLI-based sub-agents in parallel, share project context, and synthesize their responses into a single result. It supports using existing subscriptions and local tools without extra markup.
      -