chorus icon indicating copy to clipboard operation
chorus copied to clipboard

codex CLI cancels MCP tool calls when chorus is configured as a server

Open chorus-codes opened this issue 6 months ago • 4 comments

Reproduction

`codex exec` (with chorus wired as an MCP server in `~/.codex/config.toml`) cancels the MCP tool call mid-flight, even though:

  • The chorus daemon is healthy and responding (`curl :7707/api/v1/health` → ok)
  • A direct JSON-RPC stdio call to `chorus mcp` works perfectly (`tools/list` and `tools/call` both return real results)
  • The same prompt from gemini CLI (with chorus also configured as MCP) succeeds — `list_templates` returns 6, `create_chat` produces a real chat_id

What codex prints

``` mcp: chorus/list_templates started mcp: chorus/list_templates (failed) user cancelled MCP tool call ```

The "user cancelled" wording is misleading — there's no user in headless `codex exec` to do the cancelling.

Suspected cause

Likely related to #10 (codex hangs in headless reviewer mode when user MCP config is loaded). Both fail in the same shape: codex's MCP integration in non-interactive mode doesn't cleanly drive stdio servers.

Why this matters for chorus

This is the path a non-Claude user takes if they want chorus from codex (e.g., the user in https://github.com/chorus-codes/chorus/discussions screenshots asking "how do I make terminals talk to each other"). If codex can't drive chorus MCP, that whole audience is blocked even though chorus itself works fine.

Workaround verified

Gemini CLI works end-to-end. Chorus MCP server is solid. The blocker is on codex's side, not ours.

Suggested next steps

  1. Document gemini as the reference non-Claude MCP client
  2. If we add chorus-side workarounds for #10 (`--ignore-user-config` or isolated CODEX_HOME), check whether the same isolation fixes this case
  3. Upstream report to codex if it really is a codex bug

Environment

  • Chorus 0.8.28 (server)
  • codex $(codex --version) on Ubuntu 24.04
  • Node 25.x

chorus-codes avatar May 09 '26 08:05 chorus-codes

Fixed in v0.8.29 (just published). Update with chorus update && chorus stop && chorus start. Closing as resolved on main; re-open if you still see the issue after upgrade.

chorus-codes avatar May 09 '26 08:05 chorus-codes

Re-confirmed on v0.8.29 + v0.8.30: codex exec still cancels MCP tool calls when chorus is configured as an MCP server. Direct JSON-RPC works fine, gemini CLI as MCP client works fine, codex doesn't.

This is upstream codex behaviour we can't fix from chorus's side — codex's headless MCP integration cancels stdio servers in non-interactive contexts.

Workaround for users: use Gemini CLI as your chorus MCP client. Verified end-to-end:

echo 'Use chorus MCP. Call list_templates and report the count.' | gemini --model gemini-2.5-flash --yolo

Returns the real template count.

Leaving this open as a tracking issue. If codex fixes their headless MCP behaviour upstream, this should auto-resolve.

chorus-codes avatar May 09 '26 10:05 chorus-codes

Update — also re-verified Opencode CLI works fine as a chorus MCP client (was incomplete in the original report due to a model-namespace auth issue, not chorus):

echo 'Use chorus MCP. Call list_templates and report the count.' | opencode run -m opencode-go/kimi-k2.6 --dangerously-skip-permissions
# → ⚙ chorus_list_templates Unknown
# → 6

So as of v0.8.30 the working chorus-MCP-client matrix is:

Client Status
Direct JSON-RPC ✅
Gemini CLI ✅
Opencode CLI ✅
Codex CLI ❌ (this issue)

Codex remains the only outlier, confirming this is codex-side.

99xAgency avatar May 09 '26 12:05 99xAgency

Resolved (workaround documented in v0.8.31)

After deeper investigation today, the root cause is not a chorus bug:

codex exec blocks all MCP tool calls regardless of approval_policy = "never" in ~/.codex/config.toml. The policy governs shell/file operations only, not MCP. Confirmed by capturing stdio traffic between codex and chorus via a tap wrapper:

codex → chorus: initialize ✓
codex → chorus: tools/list ✓ (returns 9 tools, fast)
codex →        : (silence — no tools/call ever sent)
codex output : "user cancelled MCP tool call"

The cancel happens entirely client-side before any tools/call request leaves codex.

The fix

codex exec --skip-git-repo-check --dangerously-bypass-approvals-and-sandbox \
  'Use chorus MCP. Call list_templates and report the count.'
# → list_templates returned 6 templates.

Verified working. The bypass flag is the only codex exec mode that allows MCP tool calls.

What v0.8.31 changes

Three user-visible places now surface this workaround:

  1. chorus connect output — when codex is detected and connected, prints a one-paragraph Codex headless note
  2. The codex orchestrator status note (visible in chorus's UI) mentions the bypass flag and links here
  3. README MCP section adds a callout under "drive it from any AI CLI"

No code-path change in chorus's MCP server itself — there's nothing to fix on our side. (I did try stripping the SDK's hardcoded taskSupport: 'forbidden' field from tools/list responses on a hunch; reverted because it didn't help.)

Closing

Workaround documented. Interactive codex TUI works fine without any flags; only headless codex exec is affected. Will close as resolved-with-workaround. If codex eventually fixes their headless approval gate to extend approval_policy: never to MCP tools, this will auto-resolve cleanly.

chorus-codes avatar May 09 '26 12:05 chorus-codes