-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add wildcard tool filtering support with * patterns #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implements glob-style wildcard filtering for tool names in both proxy mode and list-tools command. Tool patterns like 'get_*' now match any tool starting with 'get_' such as 'get_logs', 'get_metrics', etc. - Add matchesToolPattern function with proper regex escaping for safe wildcard matching - Update filtering logic in proxy-server.ts and cli.ts to use pattern matching - Maintain full backward compatibility with exact tool name matching - Add comprehensive test suite covering wildcard functionality - Enhance help text with wildcard usage examples - Update existing tests for additional test fixture tool 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Extract matchesToolPattern function to shared utils module - Add reusable test utilities and message builders - Refactor integration tests to use shared test helpers - Update ESLint config with formatting and unused vars rule 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds wildcard pattern matching support for tool filtering using *
patterns while maintaining full backward compatibility with exact tool name matching.
- Add
matchesToolPattern()
function with proper regex escaping for wildcard pattern support - Extend
--enabled-tools
and--disabled-tools
to support glob-like patterns in both proxy and list-tools modes - Add comprehensive test coverage for wildcard filtering scenarios and edge cases
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/utils.ts | New utility function for wildcard pattern matching with regex escaping |
src/proxy-server.ts | Updated tool filtering logic to use wildcard pattern matching |
src/cli.ts | Enhanced list-tools mode and help text with wildcard pattern support |
tests/wildcard-filtering.test.ts | Comprehensive test suite for wildcard filtering functionality |
tests/test-utils.ts | New utility functions for test process management and JSON-RPC communication |
tests/test-messages.ts | Centralized JSON-RPC message creation functions for tests |
tests/fixtures/mcp-server.ts | Added subtract tool for more comprehensive testing |
tests/list-tools.test.ts | Updated expectations to account for additional test tool |
tests/integration.test.ts | Refactored to use shared test utilities and updated for new test tool |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
if (args.length === 0) { | ||
process.stderr.write('Usage: mcp-controller [--enabled-tools <tool1,tool2,...>] [--disabled-tools <tool1,tool2,...>] <command> [args...]\n'); | ||
process.stderr.write(' mcp-controller list-tools [--enabled-tools <tool1,tool2,...>] [--disabled-tools <tool1,tool2,...>] <command> [args...]\n'); | ||
process.stderr.write('Tool patterns support wildcards: use * to match any characters (e.g., get_* matches get_logs, get_metrics)\n'); |
Copilot
AI
Aug 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation is inconsistent with the surrounding lines. This line should be indented to match the other process.stderr.write statements above and below it.
Copilot uses AI. Check for mistakes.
process.stderr.write(' mcp-controller list-tools [--enabled-tools <tool1,tool2,...>] [--disabled-tools <tool1,tool2,...>] <command> [args...]\n'); | ||
process.stderr.write('Tool patterns support wildcards: use * to match any characters (e.g., get_* matches get_logs, get_metrics)\n'); | ||
process.stderr.write('Example: mcp-controller --enabled-tools add,subtract bun run server.ts\n'); | ||
process.stderr.write('Example: mcp-controller --enabled-tools "get_*,list_*" bun run server.ts\n'); |
Copilot
AI
Aug 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation is inconsistent with the surrounding lines. This line should be indented to match the other process.stderr.write statements above and below it.
process.stderr.write('Example: mcp-controller --enabled-tools "get_*,list_*" bun run server.ts\n'); | |
process.stderr.write('Example: mcp-controller --enabled-tools "get_*,list_*" bun run server.ts\n'); |
Copilot uses AI. Check for mistakes.
Summary
*
character--enabled-tools
and--disabled-tools
to support glob-like patternsChanges
Core Functionality
Modified
src/cli.ts
: AddedmatchesToolPattern()
function with proper regex escaping to handle wildcard patterns*
to regex.*
with proper escaping of special charactersModified
src/proxy-server.ts
: Extended proxy server tool filtering to support wildcard patternsmatchesToolPattern()
function for consistent behaviorTest Coverage
Added
tests/wildcard-filtering.test.ts
: Comprehensive test suite covering:*-args
andget-*
*
pattern functionalityModified
tests/fixtures/mcp-server.ts
: Addedsubtract
tool to provide more tools for comprehensive wildcard testingUpdated existing tests: Modified
tests/integration.test.ts
andtests/list-tools.test.ts
to account for additional test fixture toolsUsage Examples
Implementation Details
Pattern Matching Logic
*
use exact string comparison for performance*
^pattern$
to ensure full string matchingBackward Compatibility
*
character usageTest Plan
get_*
,*_args
, and*
work correctly🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]