Fix tool filtering to work off mcp tool attribute name, not method name#12566
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the tool filtering mechanism in the MCP (Model Context Protocol) server to filter based on the McpServerToolAttribute.Name property rather than the method name. This ensures that tools are correctly matched against user-specified patterns regardless of the underlying method naming.
Key Changes:
- Moved tool filtering logic from type-level to method-level within
RegisterInstrumentedMcpTools - Removed the
GetFilteredToolTypesmethod that was filtering by type name - Added
ToolOptionto the host server command to support tool filtering at runtime
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| ServiceRegistrations.cs | Implements method-level filtering using McpServerToolAttribute.Name instead of type-based filtering |
| SharedOptions.cs | Removes the now-obsolete GetFilteredToolTypes method that filtered by type name |
| HostServerCommand.cs | Adds ToolOption to enable tool filtering for the MCP server command |
| CommandRunner.cs | Simplifies tool type retrieval by removing the call to GetFilteredToolTypes |
scbedd
reviewed
Oct 20, 2025
scbedd
approved these changes
Oct 20, 2025
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.
Fix tool filtering to work off the mcp tool attribute name, not the C# method name.
The
GetCommandmethod is going to change slightly after #12564 goes in, but the core logic change to tool filtering is the same so I figured I'd get this up for review.