Add MCP bridge tool allowlists#2139
Conversation
📝 WalkthroughWalkthroughTool-level access control was added to MCP servers via configuration-driven allowlists and denylists. ChangesTool Access Control Implementation
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly Related Issues
Suggested Labels
Suggested Reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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.
🧹 Nitpick comments (1)
src/openhuman/mcp_client/registry.rs (1)
135-141: 💤 Low valueConsider adding a debug log when blocking disallowed tools.
Per coding guidelines, error paths benefit from diagnostic logging. A
tracing::debug!here would help operators trace tool-blocking decisions without needing to surface the error through call stacks.🔧 Suggested enhancement
let tool = tool.trim(); if !server.is_tool_allowed(tool) { + tracing::debug!( + server = %server.name, + tool = %tool, + "[mcp_client] blocking disallowed tool call" + ); anyhow::bail!( "MCP tool `{tool}` is not allowed for server `{}`", server.name ); }As per coding guidelines: "Use
log/tracingatdebugortracelevel on ... error paths."🤖 Prompt for 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. In `@src/openhuman/mcp_client/registry.rs` around lines 135 - 141, Add a debug-level tracing log when a tool is rejected so operators can trace blocking decisions: inside the block where you call server.is_tool_allowed(tool) and before calling anyhow::bail!, emit a tracing::debug! (or tracing::trace! per verbosity) that includes the tool and server.name (and optionally caller context if available) to record why the path is taken without changing the error behavior in the is_tool_allowed / bail branch.
🤖 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.
Nitpick comments:
In `@src/openhuman/mcp_client/registry.rs`:
- Around line 135-141: Add a debug-level tracing log when a tool is rejected so
operators can trace blocking decisions: inside the block where you call
server.is_tool_allowed(tool) and before calling anyhow::bail!, emit a
tracing::debug! (or tracing::trace! per verbosity) that includes the tool and
server.name (and optionally caller context if available) to record why the path
is taken without changing the error behavior in the is_tool_allowed / bail
branch.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2e47c4a6-9d11-4402-8377-9d36f229abe3
📒 Files selected for processing (4)
src/openhuman/config/schema/tools.rssrc/openhuman/mcp_client/registry.rssrc/openhuman/tools/impl/network/mcp.rssrc/openhuman/tools/ops_tests.rs
Summary
allowed_tools/disallowed_toolsconfig for the generic MCP bridge.mcp_list_toolsoutput through the configured allowlist.mcp_call_toolrequests before remote transport dispatch.mcp_list_serversdiagnostics.Validation
cargo fmt --manifest-path Cargo.tomlcargo test --manifest-path Cargo.toml mcpRefs #2134
Summary by CodeRabbit
Release Notes