python-sdk icon indicating copy to clipboard operation
python-sdk copied to clipboard

Support Tag-Based Tool Filtering in MCP Server

Open skamalj opened this issue 8 months ago • 1 comments

Is your feature request related to a problem? Please describe. When the MCP server registers a large number of tools, the context size grows significantly, which negatively impacts tool selection efficiency and can lead to token limits being hit. This also makes it harder for clients to navigate and select relevant tools.

Describe the solution you'd like Introduce a decorator-based tagging mechanism that allows tools/functions to be annotated with tags. The list_tools() function can then be made configurable to return tools filtered by these tags. This enables dynamic and contextual tool selection without bloating the context unnecessarily.

Describe alternatives you've considered Currently, the workaround is to spin up multiple MCP servers with different sets of tools. However, this breaks the unified client experience — clients end up choosing servers instead of tools, which adds unnecessary operational complexity and undermines the flexibility of a centralized tool registry.

Additional context Actively working on a prototype implementation for this feature.

skamalj avatar Apr 15 '25 14:04 skamalj

we have exactly same requirement

int0x03 avatar May 26 '25 01:05 int0x03

See the Namespaces SEP: https://github.com/modelcontextprotocol/modelcontextprotocol/issues/993

cliffhall avatar Jul 21 '25 16:07 cliffhall

now fastMCP support tags, you can use the Middleware to support tag filter. this is a perfect demo: https://github.com/int0x03/scripts/blob/main/python/mcp/mcp_filter_by_tag.py

int0x03 avatar Aug 16 '25 00:08 int0x03

WIP SEP here: https://github.com/modelcontextprotocol/modelcontextprotocol/issues/1300

felixweinberger avatar Oct 03 '25 17:10 felixweinberger

Closed to consolidate discussion on protocol SEPs

felixweinberger avatar Oct 06 '25 17:10 felixweinberger