[Cherry-pick] Filter disabled tools from tools/list discovery (#3591)#3613
Merged
Conversation
## Summary - Closes #3398 Internally, all tools respects the enabled/disabled config flag. However, discovery was still made. Disabled tools were still returned in `tools/list` MCP responses. This fix filters them out at the listing level. ## Changes - Added `IsEnabled(RuntimeConfig)` to `IMcpTool` interface - Implemented per-tool config checks in all 7 built-in tools + `DynamicCustomTool` (always enabled) - Added `GetEnabledTools(RuntimeConfig)` to `McpToolRegistry` - Updated HTTP and stdio `tools/list` handlers to use `GetEnabledTools` with fail-fast (no silent fallback to unfiltered list) - Added unit tests for filtering logic and per-tool `IsEnabled` behavior ### Behavior **Before:** `tools/list` returned all registered tools regardless of `dml-tools` config flags. Setting `"delete-record": false` or `"create-record": false` had zero effect — disabled tools still appeared in the tool list and were callable. **After:** `tools/list` only returns tools where `IsEnabled(RuntimeConfig)` is true. Disabled DML tools no longer appear in the response. Both HTTP (Streamable) and stdio transports are covered.
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Cherry-picks the main-branch change that prevents disabled MCP tools from being returned by tools/list discovery by adding per-tool enablement checks driven by runtime configuration.
Changes:
- Introduces
IMcpTool.IsEnabled(RuntimeConfig)and implements it across built-in/custom/test tools. - Updates tool discovery endpoints to return only tools enabled by the current
RuntimeConfig. - Adds/updates unit tests to validate enabled/disabled tool filtering and flag behavior.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Service.Tests/UnitTests/McpTelemetryTests.cs | Updates test mock tool to satisfy new IMcpTool.IsEnabled API. |
| src/Service.Tests/Mcp/McpToolRegistryTests.cs | Adds coverage for enabled-tool filtering and DML flag behavior; updates mock tool. |
| src/Service.Tests/Mcp/McpQueryTimeoutTests.cs | Updates test tools to satisfy new IMcpTool.IsEnabled API. |
| src/Azure.DataApiBuilder.Mcp/Model/IMcpTool.cs | Adds IsEnabled(RuntimeConfig) to the public tool interface. |
| src/Azure.DataApiBuilder.Mcp/Core/McpToolRegistry.cs | Replaces listing API with config-aware enabled-tool filtering. |
| src/Azure.DataApiBuilder.Mcp/Core/McpStdioServer.cs | Filters stdio tools/list output using runtime config. |
| src/Azure.DataApiBuilder.Mcp/Core/McpServerConfiguration.cs | Filters HTTP tools/list output using runtime config. |
| src/Azure.DataApiBuilder.Mcp/Core/DynamicCustomTool.cs | Marks dynamic custom tools as always enabled. |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/UpdateRecordTool.cs | Enables/disables tool based on McpDmlTools.UpdateRecord. |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/ReadRecordsTool.cs | Enables/disables tool based on McpDmlTools.ReadRecords. |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/ExecuteEntityTool.cs | Enables/disables tool based on McpDmlTools.ExecuteEntity. |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/DescribeEntitiesTool.cs | Enables/disables tool based on McpDmlTools.DescribeEntities. |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/DeleteRecordTool.cs | Enables/disables tool based on McpDmlTools.DeleteRecord. |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/CreateRecordTool.cs | Enables/disables tool based on McpDmlTools.CreateRecord. |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/AggregateRecordsTool.cs | Enables/disables tool based on McpDmlTools.AggregateRecords. |
Aniruddh25
approved these changes
May 20, 2026
aaronburtle
approved these changes
May 20, 2026
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.
Cherry-pick of commit 69b12fc from main to release/2.0.
Original PR: #3591