Skip to content

Route opted-in MCP elicitations through Guardian#19431

Merged
cd-oai merged 3 commits into
mainfrom
cd/mcp-guardian
May 6, 2026
Merged

Route opted-in MCP elicitations through Guardian#19431
cd-oai merged 3 commits into
mainfrom
cd/mcp-guardian

Conversation

@cd-oai
Copy link
Copy Markdown
Contributor

@cd-oai cd-oai commented Apr 24, 2026

Motivation

Browser Use origin-access prompts are MCP elicitations, not direct tool-call approval prompts, so they were bypassing the Guardian approval path. We need a generic opt-in that lets eligible MCP elicitations use Guardian when the current turn already routes approvals there.

Description

Add a generic elicitation reviewer hook in codex-mcp and wire codex-core to pass a Guardian reviewer callback when creating the MCP connection manager. The reviewer validates explicit mcp_tool_call opt-in metadata, builds a Guardian MCP tool-call review request from server/tool/connector metadata and tool params, and maps Guardian approval, denial, timeout, and cancellation decisions back to MCP elicitation responses.

The new option to trigger this in the _meta object is:

"codex_request_type": "approval_request",

Testing

  • RUST_MIN_STACK=8388608 NEXTEST_STATUS_LEVEL=leak cargo nextest run --no-fail-fast --cargo-profile ci-test --test-threads 2
  • cargo clippy --tests -- -D warnings
  • cargo fmt -- --config imports_granularity=Item --check
  • cargo shear
  • pnpm run format
  • python3 .github/scripts/verify_cargo_workspace_manifests.py
  • python3 .github/scripts/verify_tui_core_boundary.py
  • python3 .github/scripts/verify_bazel_clippy_lints.py
  • git diff --check

@cd-oai cd-oai requested a review from a team as a code owner April 24, 2026 19:56
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@cd-oai
Copy link
Copy Markdown
Contributor Author

cd-oai commented Apr 24, 2026

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Apr 24, 2026
@cd-oai cd-oai requested a review from dylan-hurd-oai April 24, 2026 20:40
Comment thread codex-rs/core/src/config_loader/mod.rs Outdated
Comment thread codex-rs/core/src/session/mcp.rs Outdated
Comment thread codex-rs/core/tests/suite/approvals.rs Outdated
Comment thread codex-rs/core/tests/suite/request_permissions_tool.rs Outdated
Copy link
Copy Markdown
Collaborator

@dylan-hurd-oai dylan-hurd-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the main thing we need to address here is that MCP's shouldn't be able to opt-in to guardian specifically, only to whether an elicitation is an approval request, and then the harness should route the elicitation based on the user's configuration.

@cd-oai cd-oai force-pushed the cd/mcp-guardian branch 3 times, most recently from 4fc1a3b to 6908752 Compare May 6, 2026 16:39
Motivation

Browser Use origin-access prompts are MCP elicitations, not direct tool-call approval prompts, so they were bypassing the Guardian approval path. We need a generic opt-in that lets eligible MCP elicitations use Guardian when the current turn already routes approvals there, without hardcoding behavior to browser-use or letting servers force Guardian in user-review modes.

Description

Add a generic elicitation reviewer hook in codex-mcp and wire codex-core to pass a Guardian reviewer callback when creating the MCP connection manager. The reviewer validates explicit mcp_tool_call opt-in metadata, builds a Guardian MCP tool-call review request from server/tool/connector metadata and tool params, and maps Guardian approval, denial, timeout, and cancellation decisions back to MCP elicitation responses.

Centralize MCP approval metadata keys in codex-protocol. Update Browser Use origin-access metadata to opt in to Guardian review while keeping display params empty for manual approval, and update TUI/Electron elicitation cards to honor tool_params_display.

Keep the rebased test suite hermetic from host /etc/codex config by adding test-only system config path overrides, update permission tests for explicit Guardian feature gating, and shard the approval matrix so nextest stays within its timeout budget.

Testing

- RUST_MIN_STACK=8388608 NEXTEST_STATUS_LEVEL=leak cargo nextest run --no-fail-fast --cargo-profile ci-test --test-threads 2
- cargo clippy --tests -- -D warnings
- cargo fmt -- --config imports_granularity=Item --check
- cargo shear
- pnpm run format
- python3 .github/scripts/verify_cargo_workspace_manifests.py
- python3 .github/scripts/verify_tui_core_boundary.py
- python3 .github/scripts/verify_bazel_clippy_lints.py
- git diff --check
@cd-oai cd-oai force-pushed the cd/mcp-guardian branch from 5ac7e33 to 1b9d3a8 Compare May 6, 2026 17:05
@cd-oai cd-oai enabled auto-merge (squash) May 6, 2026 18:46
@cd-oai cd-oai merged commit 346070a into main May 6, 2026
26 checks passed
@cd-oai cd-oai deleted the cd/mcp-guardian branch May 6, 2026 19:42
@github-actions github-actions Bot locked and limited conversation to collaborators May 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants