feat: add MCP tool call redaction for OpenCode & Gemini CLI#36
feat: add MCP tool call redaction for OpenCode & Gemini CLI#36byapparov wants to merge 3 commits into
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Bidirectional PII redaction for MCP tools: PreToolUse redacts outbound arguments before they reach the MCP server, PostToolUse redacts inbound results before the LLM sees them. Built-in tool redaction unchanged. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add bidirectional PII redaction for two new AI coding clients: - OpenCode plugin: redact PII in tool args (before) and tool outputs (after) for both built-in tools and MCP content blocks via in-place mutation - Gemini CLI hooks: add BeforeTool/AfterTool event dispatch in redact-hook with Gemini-specific response format (deny/reason instead of block) - Init command: add --gemini flag to write .gemini/settings.json with BeforeTool/AfterTool hook configuration - Refactor redact-hook.ts to extract shared helpers, reducing duplication between Claude Code and Gemini event handlers Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
PR Review: MCP Tool Call Redaction for OpenCode & Gemini CLISummaryThis PR adds bidirectional PII redaction support for MCP tool calls across OpenCode and Gemini CLI, extending the existing Claude Code hooks infrastructure. Overall implementation is solid with comprehensive test coverage (158 tests passing). 1. Redaction Logic ✅ Strong with Minor Edge CasesStrengths:
Edge Cases to Consider:
Recommendation: Add a test case for JSON-in-CLI-output to confirm current behavior is acceptable. 2. Streaming Integrity ✅ Well-ImplementedStrengths:
Potential Issues:
Recommendation: Stream handling is production-ready. Consider adding a chunk timeout in future iterations. 3. Security ✅ Strong with Minor ObservationsStrengths:
Observations:
Recommendation:
4. Reliability ✅ Solid with Good Error HandlingStrengths:
Potential Issues:
Recommendation: Current reliability is good for v1. Consider adding retry logic for production hardening. 5. Code Quality ✅ Excellent
Test ResultsRecommendations SummaryP1 (Address before merge):
P2 (Future improvements):
Verdict✅ APPROVE - This is a well-designed, thoroughly tested implementation. The redaction patterns are comprehensive, streaming is handled correctly, and security is solid. Minor recommendations are for future hardening, not blockers. Reviewed SHA: 34da6cb |
Summary
tool.execute.beforearg redaction +tool.execute.afteroutput redaction)BeforeTool/AfterToolevent handling inredact-hook.tswith Gemini-specific response format--geminiflag tohush init --hooksto generate.gemini/settings.jsonwith proper hook configredactToolInput()andredactBuiltinResponse()helpers.gemini/settings.jsonexample config and update.opencode/plugins/hush.tsdocsTest plan
echo '{"hook_event_name":"BeforeTool","tool_input":{"text":"admin@x.com"}}' | node dist/cli.js redact-hookecho '{"hook_event_name":"AfterTool","tool_name":"shell","tool_response":{"stdout":"email: a@b.com"}}' | node dist/cli.js redact-hook🤖 Generated with Claude Code