Add exact MCP server policy handler - #40
Conversation
|
Warning Review limit reached
Next review available in: 45 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (10)
Summary by CodeRabbit
WalkthroughAdds a pinned MCP Python SDK server adapter with fail-closed tool authorization, review approval, immutable request data, in-memory examples, integration tests, CI validation, public exports, and documentation. ChangesMCP server adapter
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant MCPServer
participant Policy
participant ToolGate
Client->>MCPServer: Call registered tool
MCPServer->>Policy: Validate tool and arguments
Policy->>ToolGate: Authorize request
ToolGate-->>Policy: Allow, deny, or review
Policy->>ToolGate: Execute approved call
ToolGate-->>MCPServer: Return handler result
MCPServer-->>Client: Return tool response
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/PRODUCTIZATION.md`:
- Around line 129-133: Update the MCP tools specification statement in
PRODUCTIZATION.md to replace “human-deniable invocation” with “human in the loop
with the ability to deny tool invocations,” preserving the surrounding meaning
and links.
In `@examples/mcp_server_policy_demo.py`:
- Around line 81-83: Update the result.isError assertion in the policy-protected
MCP call demo to include result.content in the failure message, preserving the
existing success path and assertion behavior.
In `@integration_tests/test_mcp_sdk.py`:
- Around line 124-156: Exercise the unused approve_review=False branch by adding
a real MCP transport test, such as
test_real_server_rejected_review_fails_closed, that calls the tool through
create_connected_server_and_client_session and asserts result.isError is true.
Also verify the handler was not called and exactly one review was recorded;
alternatively, remove the False branch from _server if rejection is
intentionally out of scope.
In `@README.md`:
- Around line 637-640: Update the MCP registry documentation to describe
name-set matching rather than full Tool-definition equality: in README.md lines
637-640, state that create_mcp_server_tool_policy exact-matches the complete
tool-name set; in docs/ADOPTION.md lines 28-30, state that the adapter
exact-matches the complete MCP tool-name set; in docs/API.md lines 469-471,
clarify that Tool objects are validated and copied while catalog matching uses
their names; and in docs/ARCHITECTURE.md lines 289-291, describe exact matching
of the registry name set.
In `@RELEASING.md`:
- Around line 68-76: Update the fourth fresh virtual environment instructions in
RELEASING.md to install the local package after the requirements-mcp.lock
installation and before the MCP test and example commands, using the specified
editable, no-build-isolation, no-dependencies pip invocation.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 7dbcc6bb-a618-4ea8-8f3c-5a2c2bd250dd
⛔ Files ignored due to path filters (1)
requirements-mcp.lockis excluded by!**/*.lock
📒 Files selected for processing (24)
.github/workflows/ci.ymlCHANGELOG.mdCONTRIBUTING.mdREADME.mdRELEASING.mdROADMAP.mdSECURITY.mddocs/ADOPTION.mddocs/API.mddocs/ARCHITECTURE.mddocs/MCP.mddocs/OPENAI_AGENTS.mddocs/PRODUCTIZATION.mddocs/PYDANTIC_AI.mddocs/TOOL_CALLS.mddocs/TOOL_DISPATCH.mdexamples/mcp_server_policy_demo.pyintegration_tests/test_mcp_sdk.pypyproject.tomlrequirements-mcp.txtsrc/samsarix_ethics/__init__.pysrc/samsarix_ethics/mcp.pytests/test_mcp.pytests/test_public_api.py
Summary
Security and compatibility
Verification