feat: Add MCP wildcard permission helpers (P2)#8
Conversation
- McpToolName.wildcard(server) for server-level wildcards
- McpToolName.wildcardAll for global MCP wildcard
- McpToolNames.wildcard for instance-based wildcards
Example usage:
```scala
// Allow all tools from a server
.withAllowedTools(McpToolName.wildcard("weather-api"))
// Allow all MCP tools (use with caution)
.withAllowedTools(McpToolName.wildcardAll)
// Using McpToolNames instance
.withAllowedTools(WeatherTools.wildcard)
```
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Pull Request ReviewSummaryThis PR adds helpful wildcard permission patterns for MCP tools, making it easier to auto-approve tools from specific MCP servers or all MCP tools at once. The implementation is clean, well-documented, and includes comprehensive test coverage. ✅ Strengths1. Code Quality & Design
2. API Design
3. Test Coverage
4. Documentation
|
| Category | Rating | Notes |
|---|---|---|
| Code Quality | ⭐⭐⭐⭐⭐ | Clean, idiomatic Scala 3 |
| API Design | ⭐⭐⭐⭐ | Good ergonomics, minor improvements possible |
| Documentation | ⭐⭐⭐⭐ | Excellent inline docs, examples provided |
| Test Coverage | ⭐⭐⭐ | Unit tests good, needs integration tests |
| Security | Appropriate warnings, but needs review | |
| Completeness | Wildcard matching logic unclear |
Overall: Good work! Address the wildcard matching question and this will be ready to merge.
🤖 Generated with Claude Code (Sonnet 4.5)
- Add documentation clarifying wildcard matching is handled by TypeScript SDK - Fix comment inconsistency (mcp__*__* vs mcp__*) - Add integration tests showing wildcards work with AgentOptions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Pull Request ReviewSummaryThis PR adds wildcard helper methods for MCP tool permissions, making it easier to auto-approve all tools from a specific server or all MCP tools globally. The implementation is clean, well-documented, and includes comprehensive test coverage. ✅ StrengthsCode Quality
Test Coverage
Design
💡 Suggestions1. Pattern Format DocumentationThe implementation relies on glob-style pattern matching in the TypeScript SDK layer. Consider adding a comment about what patterns are supported: /** Create a wildcard pattern to allow all tools from a server.
*
* Wildcard matching uses glob-style patterns (* matches any characters).
* The pattern is evaluated by the Claude Code TypeScript SDK.
* ...Impact: Low - Documentation enhancement 2. Validation ConsiderationsThe def wildcard(serverName: String): ToolName =
require(serverName.nonEmpty && !serverName.contains("*"), "Invalid server name")
ToolName.Custom(s"mcp__${serverName}__*")However, given that this would be caught at runtime anyway when no tools match, the current approach is acceptable. Impact: Low - Would catch errors earlier but adds complexity 3. Test Coverage - Edge CasesConsider adding tests for edge cases:
Impact: Low - Current implementation handles these fine, but explicit tests would document expected behavior 4. Example in PR DescriptionThe PR description shows excellent usage examples. Consider adding these to the main ScalaDoc for abstract class McpToolNames(val serverName: String):
/** Get a wildcard pattern to allow all tools from this server.
*
* Example:
* {{{
* object WeatherTools extends McpToolNames("weather-api"):
* val getWeather = tool("get_weather")
*
* // Allow all weather tools without permission prompts
* AgentOptions.default.withAllowedTools(WeatherTools.wildcard)
* // or
* AgentOptions.default.withAllowedTools(McpToolName.wildcard("weather-api"))
* }}}Impact: Low - Documentation enhancement 🔍 Specific Code ReviewMcpToolName.scala (lines 30-61)✅ Correct implementation: The wildcard patterns follow the expected ✅ Good separation: McpToolNameSpec.scala (lines 117-217)✅ Thorough testing: Tests cover both the static methods and instance method, plus integration ✅ Pattern matching assertions: Tests correctly verify the
Example: // At top of file after other imports
import com.tjclp.scalagent.config.AgentOptions
// Then in tests, just use directly
test("wildcard patterns work with AgentOptions.withAllowedTools"):
val opts = AgentOptions.default.withAllowedTools(McpToolName.wildcard("weather-api"))
// ...Impact: Trivial - Style preference 🛡️ Security Considerations✅ Appropriate warning: The RecommendationConsider adding a note in the documentation about when to use wildcards vs explicit tool lists: /** Create a wildcard pattern to allow all tools from a server.
*
* Use this when you trust all tools from a server and want to avoid
* permission prompts. For production use, consider explicitly listing
* allowed tools for better security and clarity.
* ...🚀 Performance Considerations✅ No performance impact: Wildcard methods are simple string construction 📋 Test Plan Verification✅ PR claims "All 156 tests pass" - this is verifiable via CI Final VerdictApproval Status: ✅ APPROVED This is a high-quality PR that:
The suggestions above are minor enhancements that could be addressed in a follow-up PR if desired, but they do not block merging this PR. RecommendationMerge when ready - This PR is ready to merge as-is. The suggested improvements are optional nice-to-haves. 🤖 Review completedGreat work on the implementation and testing! 🎉 |
Summary
McpToolName.wildcard(serverName)for server-specific wildcards (e.g.,mcp__weather-api__*)McpToolName.wildcardAllfor global MCP wildcard (mcp__*)McpToolNames.wildcardinstance method for convenient per-server wildcardsThese helpers make it easier to auto-approve MCP tools via
allowedTools:Test plan
Closes TJC-564
🤖 Generated with Claude Code