Open
Description
Add Tool Filtering Capability to MCPServerStdio
Problem Statement
Currently, MCPServerStdio doesn't provide a mechanism to filter which tools are exposed from a given MCP Server. This means all tools from the server are always available, which may not be desirable in cases where we want to limit tool access for security or simplicity reasons.
Current Implementation
The current MCPServerStdio initialization only allows for basic configuration:
MCPServerStdio(
params: MCPServerStdioParams,
cache_tools_list: bool = False,
name: str | None = None,
client_session_timeout_seconds: float | None = 5,
)
Desired Feature
Add the ability to filter tools similar to Google ADK's implementation:
MCPServerStdio(
params: MCPServerStdioParams,
cache_tools_list: bool = False,
name: str | None = None,
client_session_timeout_seconds: float | None = 5,
tool_filter: list[str] | None = None # New parameter
)
Use Case Example
# Only expose specific tools from the MCP server
server = MCPServerStdio(
params={
"command": "uvx",
"args": ["[email protected]"],
"env": {...}
},
tool_filter=['get-neo4j-schema', 'read-neo4j-cypher'] # Only expose these tools
)
Benefits
- Enhanced security by limiting tool access
- Simplified tool interfaces for specific use cases
- Better control over agent capabilities
Implementation Considerations
- The
tool_filter
parameter should be optional - When not provided, maintain current behavior of exposing all tools
- Add validation to ensure filtered tools exist on the server
- Consider adding warning logs when requested tools don't exist