Skip to content

Filter MCPServerStdio server tools #851

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

Open
esandoval30 opened this issue Jun 12, 2025 · 2 comments
Open

Filter MCPServerStdio server tools #851

esandoval30 opened this issue Jun 12, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@esandoval30
Copy link

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

@esandoval30 esandoval30 added the enhancement New feature or request label Jun 12, 2025
@devtalker
Copy link

I have same issue, see 830

@DanieleMorotti
Copy link
Contributor

Hi, considering that this feature has been requested multiple times, I've implemented a PR (#854 ) enabling the filtering of visible tools from an MCP server.
@rm-openai, if you have time, I'd appreciate your feedback. Let me know if you'd like to include this implementation, otherwise I'll close the PR. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants