Skip to content

MCP tool calls always cancelled in exec mode with 'user cancelled MCP tool call' #5

@calvintkm

Description

@calvintkm

Auto-mirrored from upstream for the consensus-loop backlog. Do not edit below by hand.

Upstream: openai#16685
Area / crate: codex-exec (+ codex-mcp)

Acceptance criteria

  • MCP tool calls invoked under codex exec must complete (not be auto-cancelled with 'user cancelled MCP tool call'). Identify the regression that cancels them in exec mode and restore correct behavior; add a test exercising an MCP tool call in exec mode.

Original upstream report (openai#16685)

Bug Description

All MCP tool calls are immediately cancelled when using `codex exec` mode. This affects every MCP server, not just specific ones.

Reproduction

1. Any MCP server in `~/.codex/config.toml`:
```toml
[mcp_servers.minimal]
command = "node"
args = ["/path/to/any-mcp-server.js"]
```

2. Run exec mode:
```bash
codex exec --json --full-auto "Call the MCP tool"
```

3. Observed JSONL output:
```json
{"type":"item.started","item":{"type":"mcp_tool_call","server":"minimal","tool":"count","status":"in_progress"}}
{"type":"item.completed","item":{"type":"mcp_tool_call","server":"minimal","tool":"count","status":"failed","error":{"message":"user cancelled MCP tool call"}}}
```

Key Evidence

  • Reproduces with the trivial MCP SDK example server (the `count` tool from `@modelcontextprotocol/sdk/examples/server/progressExample.js`) — not specific to any particular MCP server
  • Direct stdio MCP client calls to the same servers succeed — the servers themselves are healthy
  • Removing all hooks and AGENTS instructions doesn't change the behavior — hooks are not involved
  • Codex log outputs: `request_user_input is not supported in exec mode`
  • `codex features list` shows `codex_hooks = false`

Diagnosis

Codex exec mode appears to hit an MCP elicitation/user-input path during tool invocation. Since exec mode doesn't support interactive input, this triggers cancellation of the MCP tool call.

The cancellation happens very quickly after the tool call starts — it's not a timeout, it's an early abort.

Environment

  • codex-cli 0.118.0
  • macOS (Apple Silicon)
  • Node.js v22.22.0
  • Multiple MCP servers tested (context-mode, minimal SDK example)

Full Session Report

Detailed investigation with exact commands, outputs, and chronology:
https://gist.github.com/murataslan1/e0290cb0862f57fff4a0e2936b6a77d8

Metadata

Metadata

Assignees

No one assigned

    Labels

    crnd:human:autoController may continue without maintainer intervention.crnd:lifecycle:managedItem is managed by consensus-loop.crnd:phase:implementingImplementation worker is active.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions