Skip to content

[Cherry-pick] Filter disabled tools from tools/list discovery (#3591)#3613

Merged
souvikghosh04 merged 3 commits into
release/2.0from
cherry-pick/69b12fc6-to-release-2.0
May 20, 2026
Merged

[Cherry-pick] Filter disabled tools from tools/list discovery (#3591)#3613
souvikghosh04 merged 3 commits into
release/2.0from
cherry-pick/69b12fc6-to-release-2.0

Conversation

@souvikghosh04
Copy link
Copy Markdown
Contributor

Cherry-pick of commit 69b12fc from main to release/2.0.

Original PR: #3591

## 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.
@souvikghosh04 souvikghosh04 marked this pull request as ready for review May 20, 2026 07:34
Copilot AI review requested due to automatic review settings May 20, 2026 07:34
@souvikghosh04 souvikghosh04 self-assigned this May 20, 2026
@souvikghosh04 souvikghosh04 moved this from Todo to Review In Progress in Data API builder May 20, 2026
@souvikghosh04 souvikghosh04 added this to the May 2026 milestone May 20, 2026
@souvikghosh04 souvikghosh04 added the 🍒Cherrypick Cherry-picking another commit/PR label May 20, 2026
@souvikghosh04 souvikghosh04 enabled auto-merge (squash) May 20, 2026 07:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/Azure.DataApiBuilder.Mcp/Model/IMcpTool.cs
Comment thread src/Azure.DataApiBuilder.Mcp/Core/McpToolRegistry.cs
Comment thread src/Service.Tests/Mcp/McpToolRegistryTests.cs
@souvikghosh04 souvikghosh04 disabled auto-merge May 20, 2026 21:14
@souvikghosh04 souvikghosh04 merged commit e9da9b3 into release/2.0 May 20, 2026
12 checks passed
@souvikghosh04 souvikghosh04 deleted the cherry-pick/69b12fc6-to-release-2.0 branch May 20, 2026 21:32
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Data API builder May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.0 🍒Cherrypick Cherry-picking another commit/PR

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants