Skip to content

Filter MCPServerStdio server tools #851

Open
@esandoval30

Description

@esandoval30

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

  1. Enhanced security by limiting tool access
  2. Simplified tool interfaces for specific use cases
  3. 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

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions