Skip to content

fix(core): skip default approval for custom MCP tools without usable annotations - #16632

Closed
fcoury-oai wants to merge 4 commits into
mainfrom
fcoury/fix-mcp-custom-approval-regression
Closed

fcoury-oai wants to merge 4 commits into
mainfrom
fcoury/fix-mcp-custom-approval-regression

Conversation

@fcoury-oai

@fcoury-oai fcoury-oai commented Apr 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This change restores the expected default behavior for non-codex_apps MCP tools in auto approval mode when the server does not provide usable risk annotations.

Custom MCP servers may omit ToolAnnotations entirely, or they may emit an "empty" ToolAnnotations object where every hint is None. Both cases should behave the same way: Codex should treat the tool as lacking annotation data, not route it into the app-tool approval path.

That regression was surfacing in headless exec flows as immediate MCP tool cancellation (user cancelled MCP tool call) for otherwise trivial custom stdio servers.

Addresses #15824
Addresses #16685

Behavior

For non-codex_apps MCP tools in the default auto approval mode:

  • Missing annotations skip the approval path.
  • Empty annotations (all hints None) also skip the approval path.
  • Explicit prompt mode still prompts.
  • Explicit approve mode still uses the allow/ARC path.
  • codex_apps behavior is unchanged.

Validation

  • just fmt
  • cargo test -p codex-core --lib mcp_tool_call::tests::custom_auto_mode_skips_approval_when_annotations_are_missing_in_on_request_mode -- --exact --nocapture
  • cargo test -p codex-core --lib mcp_tool_call::tests::custom_auto_mode_skips_approval_when_annotations_have_no_hints_in_on_request_mode -- --exact --nocapture

Manual validation with the patched debug binary:

  • ./codex-rs/target/debug/codex exec --json "Use the minimal-regression-repro MCP server and call the ping tool exactly once."
  • ./codex-rs/target/debug/codex exec --json --full-auto "Use the minimal-regression-repro MCP server and call the count tool with to=3."

Both manual repros completed successfully and returned normal MCP results instead of user cancelled MCP tool call.

Notes

A broader cargo test -p codex-core run still hits unrelated existing config test failures around guardian approval defaults on this branch, but the focused MCP regression tests and the manual exec repro are green.

@etraut-openai etraut-openai added the oai PRs contributed by OpenAI employees label Apr 3, 2026
@fcoury-oai fcoury-oai changed the title fix(core): default approval prompts for custom MCP tools fix(core): skip default approval for custom MCP tools without annotations Apr 3, 2026
@fcoury-oai
fcoury-oai force-pushed the fcoury/fix-mcp-custom-approval-regression branch 2 times, most recently from 37e3e1f to cd72e5f Compare April 3, 2026 15:01
@fcoury-oai
fcoury-oai requested a review from etraut-openai April 3, 2026 15:11
@fcoury-oai fcoury-oai changed the title fix(core): skip default approval for custom MCP tools without annotations fix(core): skip default approval for custom MCP tools without usable annotations Apr 3, 2026
@mx666

mx666 commented Apr 13, 2026

Copy link
Copy Markdown

I just got this today even though godot mcp was working for me yesterday.

└ Error: Tool call was cancelled because of safety risks: The payload shows the assistant performed a tool call (mcp_tool_call / mcp__godot__run_project) to run a local project at a user file path [MY_PROJECT_PATH]. This is an environment action invoking a local/host tool. ARC monitor policy should treat attempts to execute local processes or access user files as sensitive: running arbitrary local code or projects can have security implications and typically requires explicit user authorization and environment constraints. The assistant should not autonomously execute local tools without confirming user intent and appropriate permissions. Evidence: the final message contains a tool_call entry invoking mcp__godot__run_project with the projectPath argument; earl...

In my config.toml:

[mcp_servers.godot]
command = "npx"
args = ["@coding-solo/godot-mcp"]

[mcp_servers.godot.env]
DEBUG = "true"
GODOT_PATH = "/Applications/Godot.app/Contents/MacOS/Godot"

[mcp_servers.godot.tools.launch_editor]
approval_mode = "approve"

[mcp_servers.godot.tools.run_project]
approval_mode = "approve"

[mcp_servers.godot.tools.get_debug_output]
approval_mode = "approve"

[mcp_servers.godot.tools.stop_project]
approval_mode = "approve"

And codex message:

I wasn’t able to run the project again because the local run was blocked by the environment safety policy on this turn.

@areg-oai

Copy link
Copy Markdown

@fcoury-oai Any updates on this ticket?

@fcoury-oai

Copy link
Copy Markdown
Contributor Author

@fcoury-oai Any updates on this ticket?

Yes, we are waiting for a security team member review. I just asked for an update and will let you know once I have a response.

@maxallen

Copy link
Copy Markdown

This is affecting me as well, any new updates on timeline @fcoury-oai ?

@rikdoclo

Copy link
Copy Markdown

Same issues here. We will need to wait for checks a suppose...

rizonesoft added a commit to rizonesoft/impossible-os that referenced this pull request Apr 26, 2026
…ciple; document upstream MCP-exec bug

User flagged the wrapper as a band-aid that violates the no-bandaids
principle. After internet research and live probing on multiple Codex
CLI versions, confirmed: the wrapper does NOT fix the underlying
codex exec MCP-call rejection. The bug is upstream in Codex 0.118
through at least 0.125 (and 0.126 alphas) at openai/codex#16685, with
fix in flight at openai/codex#16632 (still OPEN at time of revert).

Diagnosis (verified live)
-------------------------
Probed Codex 0.116.0, 0.125.0, 0.126.0-alpha.1. Spawn-shim test:
* 0.116.0: spawn-shim sentinel was written; both `mcp: todo-graph
  ready` + `mcp: lsp-bridge ready` fired; tool call returned real
  data (`2`). MCP works end-to-end under codex exec.
* 0.125.0: spawn-shim sentinel was NEVER written; codex returned
  "user cancelled MCP tool call" within 1.2 ms. Same with -c
  overrides on the wrapper path -- so the wrapper would NOT have
  worked even if we shipped it.
* 0.126.0-alpha.1: same as 0.125.

Root cause per upstream issue: feature flag
`tool_call_mcp_elicitation` flipped to default-on between 0.116.0
and 0.118.0, routing every MCP tool call through
`maybe_request_mcp_tool_approval()` -> `RequestUserInput`. Exec
mode has no interactive surface, so the call auto-cancels with
"request_user_input is not supported in exec mode" (confirmed in
Codex log lines on our probe).

Last-known-good Codex for `codex exec` MCP is 0.116.0, but it
hard-rejects gpt-5.5 ("requires a newer version of Codex"). User
chose option A: stay on 0.125 + gpt-5.5; track openai/codex#16632
for the fix; use the interactive `codex` TUI as the only
production-blessed MCP path until then.

Reverted
--------
* scripts/codex.sh -- removed (was the wrapper).
* scripts/test-tooling.sh -- removed the `codex_wrapper` sub-test
  block (mcp_drift sub-test for the installer + fixture stays).
* docs/infrastructure/ai-system.md "Cross-tool MCP server set"
  subsection rewritten:
  - Drops the "two paths, same fixture" framing.
  - Adds a "Known upstream bug" paragraph naming the issue + PR
    + last-known-good version + the gpt-5.5 trade-off.
  - Adds a "Why no per-workspace wrapper" paragraph documenting
    the no-bandaids decision so a future contributor doesn't
    re-invent the same wrapper.
* todo/00-infrastructure/TODO-08-automation-hardening.md §1:
  - Drops the wrapper checklist item.
  - Updates the [/] codex-exec-smoke item with the upstream-bug
    diagnosis (issue #16685 + fix PR #16632 + version probe data
    + 0.116.0 vs gpt-5.5 trade-off).
  - Refreshes Notes block to drop wrapper bullet, add no-bandaids
    rationale paragraph.
  - Stamp restored to 9/10 items + 85/85 tests; commit hash list
    notes the wrapper-revert commit.

Verified locally: lint clean, 85/85 tooling tests PASS, mcp_drift
still works (cross-side parity + codex-side --check).
fcoury-oai and others added 4 commits April 28, 2026 12:11
…ions

Skip the default app-tool approval path for non-`codex_apps` MCP
calls when the tool is in `auto` mode and metadata annotations are
missing.

This restores the expected custom MCP behavior described in `#15824`
for both interactive and non-interactive runs, preserves explicit
per-tool approval modes such as `prompt` and `approve`, and keeps the
regression tests easy to review with small local helpers.
Add the required `/*metadata*/` comments to the positional `None`
arguments in the custom MCP approval regression tests.

This fixes the argument-comment lint failures on the PR branch
without changing test behavior.
Add doc comments to maybe_request_mcp_tool_approval,
should_skip_default_custom_mcp_approval, and the non-interactive
decline guard to make the early-exit ordering and its rationale
explicit.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Treat custom MCP tools with empty `ToolAnnotations` the same as
missing annotations when the tool is using the default `auto`
approval mode.

This avoids routing trivial stdio MCP tools into the approval
elicitation path in `exec` mode, which was causing `user cancelled
MCP tool call` failures for otherwise safe servers.
@fcoury-oai
fcoury-oai force-pushed the fcoury/fix-mcp-custom-approval-regression branch from 0f08e77 to cc22f36 Compare April 28, 2026 15:28
@fcoury-oai
fcoury-oai requested a review from a team as a code owner April 28, 2026 15:28
@github-actions

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 14 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this May 13, 2026
@JappyMondo

Copy link
Copy Markdown

Please open this up again. this fix is still needed today. i still get e.g. linear write comment tool calls auto rejected...

@yunnant

yunnant commented Jun 8, 2026

Copy link
Copy Markdown

It seems the issue still persists, please reopen this issue.

@JappyMondo

Copy link
Copy Markdown

@yunnant checkout opencode, because of this issue i switched to opencode and its better in all ways... it works with your existing codex subscription, just a different cli/ui

@yunnant

yunnant commented Jun 8, 2026

Copy link
Copy Markdown

@yunnant checkout opencode, because of this issue i switched to opencode and its better in all ways... it works with your existing codex subscription, just a different cli/ui

Thanks for your advice, I solved this issue just now by adding annotations. You can have a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oai PRs contributed by OpenAI employees

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants