feat: Add filtering(include/exclude params) for listing tools#1504
Closed
jamesev15 wants to merge 1 commit intomodelcontextprotocol:mainfrom
Closed
feat: Add filtering(include/exclude params) for listing tools#1504jamesev15 wants to merge 1 commit intomodelcontextprotocol:mainfrom
jamesev15 wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
Contributor
|
Thank you for submitting the PR, I appreciate the effort to try and get some new functionality in! Unfortunately, as this changes the underlying MCP specification itself it would first require an SEP to be submitted and accepted into the protocol specification before we can make any changes to the SDK. There is an existing SEP with a proposal for tool filtering being discussed which you're welcome to add your opinions on if you'd like here: modelcontextprotocol/modelcontextprotocol#1300 As the changes in this PR would require a whole new SEP to be submitted/accepted before it could be merged, and are already quite different to the current leading SEP (linked above) I'm gong to close the PR for now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation and Context
Add
includeandexcludeparameters to thelist_toolsrequest to enable programmatic filtering of tools on the server side. This enhancement addresses a key limitation where MCP clients must retrieve all available tools from a server and then filter them client side, leading to unnecessary data transfer and larger context windows for LLMs.While MCP compliant UIs like Claude Desktop or Continue(VS Code) provide manual tool selection, programmatic use cases (such as LangChain integrations) would benefit from server side filtering capabilities. This is particularly important for LLM applications where reducing the number of tools in the context helps minimize token usage and improves model performance by avoiding overwhelming the LLM with non used tools.
For example, when using MCP servers with LangChain:
How Has This Been Tested?
ToolManagerincludeandexcludeparameter scenariosincludeandexcludeparameterslist_toolsimplementationsBreaking Changes
None. This is a backward compatible addition. Existing clients that don't use the new parameters will continue to work unchanged, receiving all available tools as before.
Types of changes
Checklist
Additional context
The implementation follows the existing MCP patterns:
PaginatedRequestParamsas the base forListToolsRequestto include the new filtering parametersincludeandexcludeto prevent ambiguous requests