Strip GitHub write MCP tools from non-RCA chat sessions - #524
Conversation
Non-RCA sessions (interactive chat, ask, actions) were loading raw GitHub write MCP tools (create_or_update_file, push_files, create_branch, etc.) that bypass both ModeAccessController and the structured github_fix guardrails. This allowed the staging incident where a non-RCA session pushed a truncated file directly via create_or_update_file (PR Arvo-AI#513). ModeAccessController only gates "ask" mode, so non-RCA sessions running in "agent" or default mode had unrestricted access to destructive GitHub MCP tools. The fix adds a post-load filter in get_cloud_tools() that removes GitHub write MCP tools when is_rca_context is False. RCA sessions continue to receive all tools (including the github_fix flow). The _GITHUB_MCP_WRITE_TOOLS frozenset is defined alongside the existing _NON_RCA_SOURCES constant for discoverability. Closes Arvo-AI#522 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughA frozenset ChangesGitHub MCP Write Tool Gating
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
|
beng360
left a comment
There was a problem hiding this comment.
Correct approach. Two issues to address.
| "mcp_create_or_update_file", | ||
| "mcp_push_files", | ||
| "mcp_create_branch", | ||
| "mcp_create_pull_request", |
There was a problem hiding this comment.
The frozenset should also include mcp_create_or_update_file_with_pr — this tool variant exists in the GitHub MCP server and also does writes. Check get_github_tool_schemas() in mcp_schema_extractor.py for the full list of write tools exposed. Missing one here means the guard has a bypass.
| # write tools that bypass ModeAccessController and github_fix. | ||
| if not is_rca_context: | ||
| before_count = len(mcp_tools) | ||
| mcp_tools = [ |
There was a problem hiding this comment.
This filter runs before ModeAccessController.filter_tools() at line 2602, which is fine — but the log message should include the mode so we can distinguish ask-mode filtering (which also strips MCP tools) from this RCA-context filter in debugging. Something like "Stripped %d GitHub write MCP tools from non-RCA session (user=%s, mode=%s)".
|
Hi! Thanks for your contribution. Before we can merge this, we need you to sign our Contributor License Agreement (CLA) for legal purposes. This is a one-time requirement for external contributors — it ensures that contributions are properly licensed and that both parties are protected. I'll send the document separately. Once signed, we're good to go on this and any future PRs. |



Summary
ModeAccessController.filter_tools()only gates tools in"ask"mode. Non-RCA sessions running in"agent"or default mode were getting raw GitHub write MCP tools (create_or_update_file,push_files,create_branch, etc.) without the structuredgithub_fixguardrails that RCA sessions use. This was a contributing factor in the staging incident (PR #513).The fix adds a
_GITHUB_MCP_WRITE_TOOLSfrozenset (defined alongside the existing_NON_RCA_SOURCESconstant) and strips those tools inget_cloud_tools()whenis_rca_context is False. RCA sessions continue to receive all tools.Test plan
mcp_create_or_update_file,mcp_push_files, ormcp_create_branchin its tool list"Stripped N GitHub write MCP tools from non-RCA session"appears for non-RCA sessions with GitHub connectedmcp_get_file_contents,mcp_list_commits, etc.) are still available in non-RCA sessionsCloses #522
Summary by CodeRabbit