Skip to main content
Glama
kky42

codex-as-mcp

by kky42

codex-as-mcp

中文版

codex-as-mcp is a small Model Context Protocol (MCP) server that lets MCP clients (Claude Code, Cursor, etc.) delegate work to the Codex CLI.

It exposes two tools that run Codex in the server's current working directory:

  • spawn_agent(prompt: str)

  • spawn_agents_parallel(agents: list[dict])

Under the hood, each agent runs something like: codex exec --cd <server cwd> --skip-git-repo-check --dangerously-bypass-approvals-and-sandbox -.

The prompt is sent through stdin and then closed. This avoids command-line quoting/length issues and prevents Codex from accidentally reading from the MCP server's JSON-RPC stdin pipe.

Note: --dangerously-bypass-approvals-and-sandbox disables sandboxing and confirmation prompts. Use this server only in repos you trust.

Use it in Claude Code

There are two tools in codex-as-mcp tools

You can spawn parallel codex subagents using prompt. alt text

Here's a sample Codex session delegating two tasks in parallel. Codex use case

Related MCP server: peer-cli-mcp

Quick start

1. Install Codex CLI

Requires Codex CLI >= 0.46.0

npm install -g @openai/codex@latest
codex login

# Verify installation
codex --version

Make sure Codex CLI can run non-interactively on your machine (provider + credentials in ~/.codex/config.toml, or via the provider-specific env var it references).

Example: third-party provider + env_key

If you're using a third-party provider, configure it in Codex config.toml and point model_provider at it. When a provider uses env_key, Codex CLI expects that env var to be present when it runs.

Example:

model_provider = "custom_provider"

[model_providers.custom_provider]
name = "custom_provider"
base_url = "https://..."
wire_api = "responses"
env_key = "PROVIDER_API_KEY"
show_raw_agent_reasoning = true

When using codex-as-mcp, make sure the MCP server process has that env var set, so it can pass it through to the spawned codex process. The env var name must match the env_key value above (here: PROVIDER_API_KEY).

Option A (recommended): set env in your MCP client config (if supported)

{
  "mcpServers": {
    "codex-subagent": {
      "type": "stdio",
      "command": "uvx",
      "args": ["codex-as-mcp@latest"],
      "env": {
        "PROVIDER_API_KEY": "KEY_VALUE"
      }
    }
  }
}

Option B: pass env via server args

uvx codex-as-mcp@latest --env PROVIDER_API_KEY=KEY_VALUE

Option C: add via Codex CLI (codex mcp add)

codex mcp add codex-subagent --env PROVIDER_API_KEY=KEY_VALUE -- uvx codex-as-mcp@latest

Security note: passing secrets via command-line args may be visible via process lists on your machine; prefer option A when possible.

2. Configure MCP

Add to your .mcp.json:

{
  "mcpServers": {
    "codex-subagent": {
      "type": "stdio",
      "command": "uvx",
      "args": ["codex-as-mcp@latest"]
    }
  }
}

Or use Claude Desktop commands:

claude mcp add codex-subagent -- uvx codex-as-mcp@latest

If you're configuring Codex CLI directly (for example ~/.config/codex/config.toml), add:

[mcp_servers.subagents]
transport = "stdio"
command = "uvx"
args = ["codex-as-mcp@latest"]
# Increase if you see ~60s tool-call timeouts when running longer Codex tasks.
# tool_timeout_sec = 600

Tools

  • spawn_agent(prompt: str) – Spawns an autonomous Codex subagent using the server's working directory and returns the agent's final message.

  • spawn_agents_parallel(agents: list[dict]) – Spawns multiple Codex subagents in parallel; each item must include a prompt key and results include either an output or an error per agent.

Maintainer live smoke test

The default CI uses unit tests and a fake subprocess path so it can run safely without credentials. Maintainers can additionally run the manually triggered Live Codex smoke GitHub Actions workflow with a real provider by setting repository secret CODEX_LIVE_API_KEY and providing a Responses-compatible base_url/model in the workflow inputs.

Note: current Codex CLI rejects wire_api = "chat"; chat-completions-only providers such as direct DeepSeek API need either native Codex support for that wire API or a Responses-compatible proxy.

Troubleshooting

spawn_agent times out after ~60s

If you see an error like:

tool call failed for `subagents/spawn_agent`
timed out awaiting tools/call after 60s
deadline has elapsed

This is typically a client-side MCP tool-call timeout. spawn_agent does not return until the spawned codex exec process finishes, which can take longer than 60 seconds.

Fix: increase the tool-call timeout in your MCP client.

Codex CLI

In your Codex config (~/.codex/config.toml or ~/.config/codex/config.toml), set a higher tool_timeout_sec for the MCP server:

[mcp_servers.subagents]
transport = "stdio"
command = "uvx"
args = ["codex-as-mcp@latest"]
tool_timeout_sec = 600

MCP Inspector / mcp dev

If you're testing locally with the MCP Inspector, increase request timeouts (or run ./test.sh, which exports these):

export MCP_SERVER_REQUEST_TIMEOUT=300000
export MCP_REQUEST_TIMEOUT_RESET_ON_PROGRESS=true
export MCP_REQUEST_MAX_TOTAL_TIMEOUT=28800000

Available Tools

2 tools
spawn_agentB

Spawn a Codex agent to work inside the current working directory.

The server resolves the working directory via ``os.getcwd()`` so it inherits
whatever environment the MCP process currently has.

Args:
    prompt: All instructions/context the agent needs for the task.

Returns:
    The agent's final response (clean output from Codex CLI).
ParametersJSON Schema
NameRequiredDescriptionDefault
promptYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the behavioral disclosure burden. It does disclose that the working directory inherits from the MCP process and that the return is clean Codex CLI output, which is useful. However, it does not mention potential side effects, permissions, or execution constraints, leaving notable gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately structured with a clear opening line, a brief explanatory paragraph, and then Args/Returns sections. It is mostly concise, though the cwd resolution explanation is slightly verbose. Overall, it earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with one parameter and an output schema, the description covers the essential operational detail (cwd resolution) and the return format. It is complete enough for an agent to invoke the tool correctly, though it could add a note about the parallel sibling.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema provides zero parameter descriptions, but the description's 'Args' section explains that 'prompt' should contain all instructions/context needed for the task. This adds meaningful semantics beyond the raw schema, compensating for the lack of schema-description coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool spawns a Codex agent in the current working directory, providing a specific verb and resource. However, it does not explicitly distinguish from the sibling tool spawn_agents_parallel, so it falls short of a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explains how the working directory is resolved but gives no explicit guidance on when to use this tool versus the parallel alternative. There is no mention of criteria like single vs. multiple agents, so the agent is left without clear selection cues.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

spawn_agents_parallelA

Spawn multiple Codex agents in parallel.

Each spawned agent reuses the server's current working directory
(``os.getcwd()``).

Args:
    agents: List of agent specs, each with a 'prompt' entry.
            Example: [
                {"prompt": "Create math.md"},
                {"prompt": "Create story.md"}
            ]

Returns:
    List of results with 'index', 'output', and optional 'error' fields.
ParametersJSON Schema
NameRequiredDescriptionDefault
agentsYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the behavioral disclosure burden. It discloses that each spawned agent reuses the server's current working directory (os.getcwd()) and describes the return structure. This adds valuable context beyond the raw function name, though it does not cover all potential side effects or concurrency details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured: a clear purpose sentence, a behavioral note, and compact Args/Returns sections. Every line earns its place with no redundant information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers the tool's purpose, parameter shape, and return format, which is sufficient for its simplicity. It could be slightly more complete by explicitly referencing the singular spawn_agent alternative, but overall it provides all necessary operational context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has zero description coverage, so the description fully compensates. It explains that agents must be a list of objects with a 'prompt' entry and provides a concrete example, which is much richer than the bare schema definition.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with 'Spawn multiple Codex agents in parallel,' which is a specific verb+resource statement. It clearly distinguishes itself from the sibling tool spawn_agent by emphasizing 'multiple' and 'in parallel'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use when multiple agents need to be spawned concurrently ('Spawn multiple Codex agents in parallel'), and the sibling context reinforces this. However, it does not explicitly state when not to use this tool or mention alternatives by name.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 2 tool updatesv0.1.0
    • First observedspawn_agent
    • First observedspawn_agents_parallel

TDQS

A3.9/5.0
Disambiguation4/5

The two tools are clearly distinguished by singular vs. parallel operation, with descriptions explicitly stating that spawn_agents_parallel handles multiple agents at once. However, both share the core 'spawn agent' purpose, so they could be confused if the agent doesn't read carefully.

Naming Consistency5/5

Both tools use consistent snake_case with the verb 'spawn' followed by a noun, and the parallel tool adds a clear '_parallel' suffix. The naming pattern is predictable and easy to follow.

Tool Count3/5

With only two tools, the server feels minimal. While the focus is narrow (spawning Codex agents), two tools is on the thin side and could arguably be combined into one with a loop.

Completeness4/5

The server covers the fundamental operations: spawning a single agent or multiple in parallel. Minor gaps include lack of configuration options (e.g., working directory or model), but these are not essential for the core purpose.

Maintenance

ActivityStale
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    C
    quality
    D
    maintenance
    Bridges MCP clients with local Codex CLI to execute autonomous coding tasks, manage threads, and inspect history via SQLite state.
    13
    765
    4
    Apache 2.0
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables asynchronous task delegation between Claude Code and Codex CLI through MCP tools, allowing either AI agent to request the other to perform tasks and monitor progress.
    11
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Enables MCP clients like Claude Code and Codex to delegate coding tasks to Cursor's CLI agent, which implements changes in the workspace and returns clean, structured results for review.
    3
    157
    4
    MIT

Latest Blog Posts

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/kky42/codex-as-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server