Repository navigation
feat: model MCP require_approval as a typed policy - #520
Conversation
Part of vllm-project#145. `require_approval` on an MCP declaration is now `McpApprovalPolicy`: "always", "never", or the Responses API filter object. With no approval step yet, request validation rejects "always", `read_only` filters and a tool listed under both sides, and discovery rejects a declaration whose policy gates a tool the request can call. A filter whose `never.tool_names` covers every callable tool runs as "never" does. Signed-off-by: Sohom Chakraborty <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3ed99f8c6e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let mcp_url = spawn_forecast_mcp().await; | ||
| let ungated = json!({"never": {"tool_names": ["forecast"]}}); | ||
| for stream in [false, true] { | ||
| let fixture = support::TestFixture::new_with_responses(mcp_inference_responses( |
There was a problem hiding this comment.
Add recorded MCP coverage for the approval-filter contract
For the newly accepted object-valued require_approval, this test uses a local MCP stub and synthetic inference responses. A search of all cassette YAML/JSON found no filter-form request, and record_mcp_cassettes.sh:169 still hard-codes "never", so the claimed Responses-compatible filter semantics lack recorded provider/gateway evidence. The “Cassette decision” guidance in .agents/skills/pr-review/SKILL.md, required by AGENTS.md, explicitly requires that coverage for material wire-contract/tool-loop changes. Extend the existing counter recorder with an ungated never.tool_names scenario, capture OpenAI and gateway observations, and add replay assertions for the MCP call and echoed policy.
AGENTS.md reference: AGENTS.md:L7-L11
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Done in 212ebe6. record_mcp_cassettes.sh has an approval case (the mcp-approval items scenario), recorded against OpenAI and the gateway, and mcp_tool_test.rs replays both: OpenAI's answer for each form against requires_approval, the policy echo, and the gateway's call or 400.
|
Thanks for working on this. The approval execution path doesn't need to be part of this PR, but this first step already decides which Please extend the existing MCP recorder (
For each, the recordings should show what OpenAI returns (an How to record. Read # OpenAI reference
OPENAI_API_KEY=... python crates/agentic-server-core/tests/cassettes/record_cassette.py \
--mode items --items-scenario mcp-approval --turns <N> --no-stream \
--model <model> --openai https://api.openai.com \
--output crates/agentic-server-core/tests/cassettes/mcp/mcp-approval-openai.yaml
# Gateway, started with the servers' hosts allowed (AGENTIC_MCP_ALLOWED_HOSTS=learn.microsoft.com)
python crates/agentic-server-core/tests/cassettes/record_cassette.py \
--mode items --items-scenario mcp-approval --turns <N> --no-stream \
--model <served model> --gateway http://localhost:9000 \
--output crates/agentic-server-core/tests/cassettes/mcp/mcp-approval-gateway.yamlThen add replay tests that assert both providers' recordings. |
main moved the README's MCP configuration section to docs/guides/configuration.md; the require_approval paragraph moves with it. Signed-off-by: Sohom Chakraborty <[email protected]>
From review: an `mcp-approval` items scenario in record_cassette.py, run by record_mcp_cassettes.sh with MCP_RECORD_CASE=approval, records one non-streaming turn per form against the Microsoft Learn MCP server. Replay tests check OpenAI's answer for each form against requires_approval, the policy echo, and the gateway's call or 400. The recordings show that OpenAI echoes a filter with both sides (null when absent) and each side's read_only and tool_names (an empty list when absent). The policy now serializes the same way. Signed-off-by: Sohom Chakraborty <[email protected]>
|
The recordings are in
What they settle:
Replay tests in |
@sohom-cs Thanks for the work. we also need to keep gateway behavior recording in the repo. I know since the whole path execution it is not settle in this PR in the next PR the whole gateway behavior must be completed. for now in this PR maybe dont add the behavior and support to openapi yet. |
franciscojavierarceo
left a comment
There was a problem hiding this comment.
Thanks for the fix! The typed policy and recorded OpenAI/gateway filter cases cover the new contract.
…-identity main added the typed require_approval entry (vllm-project#520) under a new Changed heading of the unreleased changelog, where this branch adds its session id entry under Added. Both are kept, Added first. Signed-off-by: Sohom Chakraborty <[email protected]>
Summary
Part of #145. This is the typed policy from step 3 of my plan there, done first: step 1 (emitting
mcp_approval_request) needs a per-tool answer to whether a call needs approval.require_approvalis anOption<String>today and only"never"validates, so the issue's filter form,{"never": {"tool_names": [...]}}, doesn't parse. This PR addsMcpApprovalPolicy("always","never", or the Responses API filter object) withrequires_approval(tool), which follows the Responses API default: a tool not listed undernever.tool_namesneeds approval. A filter is echoed and stored as the Responses API echoes it, which the recordings below show: both sides,nullwhen absent, each withread_only(nullwhen absent) andtool_names([]when absent). String forms are unchanged.There is no approval step yet, so a request gets a 400 naming the server and tool when a tool it can call would need approval.
"always"keeps today's rejection and message, and aread_onlyfilter or a tool listed under bothalwaysandneveris rejected too. A filter whosenever.tool_namescovers every callable tool runs as"never"does. Configured servers are unchanged.The OpenAPI document,
docs/guides/configuration.md(main moved the README's MCP section there),docs/design/mcp-gateway-integration.mdand CHANGELOG are updated;McpToolParam::require_approvalchanges type for embedders.Next (step 1): end the round with an
mcp_approval_requestinstead of rejecting a gated tool.Test Plan
McpHandler::validate.GatewayExecutors::mcp_server_toolswith a replayed listing: accepted and rejected policies, with and withoutallowed_tools.mcp_tool_test, against a stub MCP server: JSON and SSE requests with aneverfilter complete themcp_calland echo the filter in the response and the stored one; gating policies fail with a 400 before any inference request. Onmainthis test fails at parsing.tests/cassettes/mcp/mcp-approval-{openai,gateway}-gpt-5.6-sol-nonstreaming.yaml, from a newmcp-approvalitems scenario run byrecord_mcp_cassettes.sh(MCP_RECORD_CASE=approval), one non-streaming turn per form against the Microsoft Learn MCP server. Replay tests inmcp_tool_test: OpenAI's answer for each form matchesrequires_approvalfor the tool the model called, both providers echo the policy the same way, and the gateway completes the two ungated forms with OpenAI's listing and call and rejects the other six with a 400.cargo fmt --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test -p agentic-server-core -p agentic-serverandpre-commit run --all-filespass on Rust 1.98.1. Two*_unreachable_upstreamtests fail onmaintoo on my machine.