Add tool filtering support with --ignore-tool flag #137
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR implements a comprehensive tool filtering mechanism that allows users to selectively ignore specific tools from remote MCP servers using the
--ignore-tool
command line flag.Changes Made
🚀 New Features
Tool Filtering with
--ignore-tool
flag--ignore-tool
flags to specify tools that should be filtered out*
for flexible matching:delete*
- ignores all tools starting with "delete"*account
- ignores all tools ending with "account"exactTool
- ignores only the tool named exactly "exactTool"Bidirectional Filtering
tools/list
responsestools/call
requests for ignored tools and returns appropriate error responsesPattern Matching Engine
patternToRegex()
function to convert glob patterns to regular expressionsshouldIncludeTool()
function for efficient pattern matching🔧 Implementation Details
Command Line Parsing (
src/lib/utils.ts
)parseCommandLineArgs()
to parse multiple--ignore-tool
flagsignoredTools
array in the configuration objectMessage Transformation (
src/lib/utils.ts
)createMessageTransformer()
utility for intercepting and transforming MCP messagestools/list
responsesProxy Integration (
src/proxy.ts
)runProxy()
function to accept and pass throughignoredTools
parameterMCP Proxy Enhancement (
src/lib/utils.ts
)mcpProxy()
function to support tool filtering📚 Documentation Updates
Updated
README.md
with comprehensive usage examples:--ignore-tool
flags🧪 Comprehensive Test Suite
Added extensive test coverage in
src/lib/utils.test.ts
:Command Line Parsing Tests (18 scenarios)
Tool Filtering Tests (6 scenarios)
create*
,*account
)MCP Proxy Tests (8 scenarios)
tools/list
responsesUsage Examples
Basic Usage
Multiple Patterns
MCP Client Configuration
Manual Testing Checklist
✅ VS Code Integration
✅ Command Line Interface
--ignore-tool
flag parsing--ignore-tool
flags parsingdelete*
,*account
,exact
)Test Execution
Run the unit tests to validate all functionality:
Expected results:
Breaking Changes
None. This is a backward-compatible addition that doesn't affect existing functionality when no
--ignore-tool
flags are provided.Security Considerations