Add the --tool option to start Azure MCP server with a list of specific tools#685
Add the --tool option to start Azure MCP server with a list of specific tools#685fanyang-mono merged 23 commits intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new --tool command-line option to the Azure MCP server that allows users to specify a specific set of tools to expose, providing fine-grained control over which tools are available at runtime.
Key changes:
- Added
--tooloption that accepts multiple tool names and filters available tools - Implemented case-insensitive tool filtering in both listing and execution
- Added comprehensive test coverage for the new functionality
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| ServiceStartCommandTests.cs | Added unit tests for the new --tool option parsing and binding |
| CommandFactoryToolLoaderTests.cs | Added comprehensive tests for tool filtering functionality including case-insensitive matching |
| CommandFactoryHelpers.cs | Extended test helper to include all available tool setups for comprehensive testing |
| ServiceStartOptions.cs | Added Tool property to store the filtered tool names |
| ServiceOptionDefinitions.cs | Defined the command-line option for --tool with proper configuration |
| ToolLoaderOptions.cs | Extended the record to include the Tool parameter for filtering |
| CommandFactoryToolLoader.cs | Implemented tool filtering logic in both list and call handlers |
| ServiceStartCommand.cs | Registered and bound the new --tool option |
| ServiceCollectionExtensions.cs | Passed the tool filter configuration to the tool loader options |
There was a problem hiding this comment.
Files that need to be updated:
- /servers/Azure.Mcp.Server/CHANGELOG.md
- /servers/Azure.Mcp/Server/TROUBLESHOOTING.md#can-i-select-what-tools-to-load-in-the-mcp-server
- /servers/Azure.Mcp.Server/TROUBLESHOOTING.md#tool-limitations
- /CONTRIBUTING.md#server-modes
- /CONTRIBUTING.md#server-discovery-and-namespace-filtering
In general, grep for namespace and you'll find MANY places to update to document this new server mode:
|
@joshfree I've updated the necessary docs. Please take a look. |
…nitions.cs Co-authored-by: Jonathan Cárdenas <JonathanCrd@users.noreply.github.com>
Co-authored-by: Jonathan Cárdenas <JonathanCrd@users.noreply.github.com>
|
There's some CI failures to look at |
wbreza
left a comment
There was a problem hiding this comment.
Right now the --tool params only work when --mode all is set. Without mode all the routing through namespaces is not working as expected.
The design feels awkward when --mode all is not set since as a user if I passed in an allow list of tools I actually don't get those tool names listed - i get the namespaces that they are in.
IMO - If --tool are individually specified I would expect the server to automatically switch into all mode but this could also lead to developer confusion.
I would expect that MCP hosts / consumers could automatically filter lists of tools to provide to sub agents for these types of scenarios.
…ic tools (microsoft#685) * Add the option to start Azure MCP server with a list of specific tools * Fix format * Fix tests with new syntax * Update CHANGELOG * Make namespace mode and registry based tool loader honor --tool swith as well * Update all docs * Update core/Azure.Mcp.Core/src/Areas/Server/Options/ServiceOptionDefinitions.cs Co-authored-by: Jonathan Cárdenas <JonathanCrd@users.noreply.github.com> * Update docs/azmcp-commands.md Co-authored-by: Jonathan Cárdenas <JonathanCrd@users.noreply.github.com> * Fix format * Fix format * Address review feedbacks * When --tool is used, It automatically switches to `all` mode. * Update doc to provide clear explanation on --tool behavior * Check for substring match instead of exact string match * Fix format * Update area name * Disallow --namespace and --tool options being used together * Clean up --------- Co-authored-by: Jonathan Cárdenas <JonathanCrd@users.noreply.github.com>
What does this PR do?
Add "--tool " switch for fine grained control over tool list. The
--namespaceand--tooloptions cannot be used together. Use multiple--toolparameters to include multiple tools. Using--toolautomatically switches toallmode.GitHub issue number?
#565
Pre-merge Checklist
servers/Azure.Mcp.Server/CHANGELOG.mdand/orservers/Fabric.Mcp.Server/CHANGELOG.mdfor product changes (features, bug fixes, UI/UX, updated dependencies)servers/Azure.Mcp.Server/README.mdand/orservers/Fabric.Mcp.Server/README.mddocumentation/docs/azmcp-commands.mdand/or/docs/fabric-commands.mdToolDescriptionEvaluatorand obtained a score of0.4or more and a top 3 ranking for all related test prompts/docs/e2eTestPrompts.mdcrypto mining, spam, data exfiltration, etc.)/azp run mcp - pullrequest - liveto run Live Test Pipeline