Skip to content

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

@murataslan1

Description

@murataslan1

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

    bugSomething isn't workingexecIssues related to the `codex exec` subcommandmcpIssues related to the use of model context protocol (MCP) serversregressionBehaviors that worked in previous versions but were broken due to an update

    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