feat(policy): add MCP-aware JSON-RPC L7 governance#1938
Merged
krishicks merged 1 commit intoJun 25, 2026
Merged
Conversation
Contributor
Author
|
@krishicks - Mostly for your review. |
a432508 to
8c9606b
Compare
Contributor
Author
|
I don't have permissions to add the |
johntmyers
reviewed
Jun 16, 2026
johntmyers
reviewed
Jun 16, 2026
johntmyers
reviewed
Jun 16, 2026
Contributor
Author
|
Cleaned up the conformance fixture workarounds to align with modelcontextprotocol/conformance#346. |
0e4d7af to
fb9c396
Compare
|
Label |
fd2621a to
0f54c83
Compare
da2a2fd to
1d8d4af
Compare
e3a525e to
91dac00
Compare
1d8d4af to
f6d11bc
Compare
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
eb82ed8 to
f1fb164
Compare
Contributor
Author
|
/ok to test |
5469fc6 to
e58f9ed
Compare
Contributor
Author
|
/ok to test |
Contributor
Author
|
/ok to test |
3 similar comments
Contributor
Author
|
/ok to test |
Contributor
Author
|
/ok to test |
Contributor
Author
|
/ok to test |
6 tasks
Add MCP-aware JSON-RPC inspection using tower-mcp-types, including strict tool-name enforcement and method/tool policy matching. Wire MCP options through proto, YAML, provider profiles, OPA/Rego policy evaluation, docs, and the MCP conformance harness. Signed-off-by: ddurst <267424412+ddurst-nvidia@users.noreply.github.com>
4a26fbb to
fa115e4
Compare
Contributor
Author
|
/ok to test |
krishicks
pushed a commit
that referenced
this pull request
Jun 26, 2026
Add MCP-aware JSON-RPC inspection using tower-mcp-types, including strict tool-name enforcement and method/tool policy matching. Wire MCP options through proto, YAML, provider profiles, OPA/Rego policy evaluation, docs, and the MCP conformance harness. Signed-off-by: ddurst <267424412+ddurst-nvidia@users.noreply.github.com> fix(e2e): use supervisor image in docker gateway runner Signed-off-by: Kris Hicks <khicks@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Builds on #1865 by keeping its shared JSON-RPC-family L7 enforcement foundation and adding an MCP-specific policy surface on top of it.
PR #1865 introduces generic JSON-RPC method/params enforcement. This variant preserves generic JSON-RPC as a first-class supported protocol for non-MCP services, while adding MCP-specific policy syntax, MCP request validation via
tower-mcp-types, MCP tool-name enforcement, and conformance-oriented e2e coverage.Related Issue
Addresses #1793.
Builds on #1865.
Changes
Relationship to #1865
PR #1865 adds the shared JSON-RPC-family L7 enforcement layer. This branch builds on that layer with an MCP-specific policy surface and MCP message validation via
tower-mcp-types, while preserving generic JSON-RPC as a first-class supported protocol for non-MCP services.How This Addresses #1793
Issue #1793 asks for method-level governance for MCP tool calls because MCP traffic is carried as JSON-RPC over a single allowed connection, making network-only policy all-or-nothing.
This branch addresses that by allowing policy to distinguish MCP requests inside the connection:
protocol: mcpselects MCP-aware JSON-RPC inspection.methodcan match MCP method names such asinitialize,tools/list, andtools/callwhen authors want explicit method rules.toolis a convenience matcher fortools/callparams.name.deny_rulescan block specific MCP calls even when broader allow rules match.MCP Policy Shape
mcp:mcp.max_body_bytesmcp.strict_tool_namesmcp.allow_all_known_mcp_methodsMcpOptionsprotobuf message so MCP policy can evolve without taking over generic L7 endpoint fields.protocol: mcpendpoints to declare a concretehostplusportorports;protocol: mcpalone is invalid and is not treated as MCP everywhere.mcp.strict_tool_namestotrue, enforcing the MCP-recommended tool-name pattern^[A-Za-z0-9_.-]{1,128}$before policy evaluation.toolglob matchers only whilemcp.strict_tool_namesremains enabled.mcp.allow_all_known_mcp_methodstotrue, so omittedrulesallow the MCP method profile and all tools before applyingdeny_rules.mcp.allow_all_known_mcp_methodsisfalse, explicit rules are required, and rules usingtoolorparams.namemust setmethod: tools/call.JSON-RPC / MCP Enforcement
JsonRpcInspectionModeso parsing can distinguish generic JSON-RPC from MCP-specific inspection.tower-mcp-typesto validate known MCP request and notification parameter shapes.Conformance Notes
The MCP conformance policy template now uses:
Expected-failure carve-outs are empty:
Note
The wrapper still carries a temporary workaround for modelcontextprotocol/conformance#345 while pinned to an upstream ref where the bundled TypeScript client fixtures drift from the runner scenarios. The wrapper patches the local checkout before building the client image so
elicitation-sep1034-client-defaultsandsse-retryexercise the intended MCP paths through OpenShell. Remove this workaround whenOPENSHELL_MCP_CONFORMANCE_REFpoints at an upstream release containing that fix.Follow-up
Typed MCP argument enforcement would be better handled as a wider L7 policy input change, for example by preserving scalar JSON type metadata alongside the existing flattened matcher keys. That would let a future MCP argument policy express
type: integerortype: booleanwithout weakening the existing JSON-RPC compatibility path.OpenShell should also eventually own explicit MCP version profiles rather than relying on dependency enums as the policy contract. That would let policy choose between the current
2025-11-25behavior and future MCP transport or method-profile changes.Testing
mise run pre-commitpassesLocal validation run for this branch includes:
mise run pre-commitcargo test -p openshell-policycargo test -p openshell-supervisor-network mcp_tool_deny_rule_blocks_tools_callcargo test -p openshell-supervisor-network l7_mcpcargo test --manifest-path e2e/rust/Cargo.toml --test forward_proxy_jsonrpc_l7 --features e2e-host-gateway --no-runOPENSHELL_DOCKER_SUPERVISOR_BIN=deploy/docker/.build/prebuilt-binaries/amd64/openshell-sandbox mise run e2e:mcpinitialize,tools_call,elicitation-sep1034-client-defaults,sse-retryChecklist