Skip to content

Conversation

@souvikghosh04
Copy link
Contributor

@souvikghosh04 souvikghosh04 commented Jan 22, 2026

Why make this change?

With custom tools, stored procedure entities could get listed in describe_entities even when they are configured as custom-tool-only (with dml-tools: false). This creates duplication since they already appear in tools/list. We need to filter stored procedures with dml-tools: false from describe_entities to avoid this duplication.

What is this change?

  • Added filtering logic to exclude stored procedure entities when dml-tools is explicitly set to false
  • The filtering ensures stored procedures are removed from describe_entities only when they are custom-tool-only (not available for DML operations)
  • Stored procedures with dml-tools: true (or null/default) continue to appear in describe_entities even if they have custom-tool: true, allowing dual exposure when needed

How was this tested?

  • Unit Tests
  • Manual Tests

Sample Request(s)

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities"
  },
  "id": 1
}

@souvikghosh04 souvikghosh04 requested a review from Copilot January 22, 2026 08:14
@souvikghosh04 souvikghosh04 self-assigned this Jan 22, 2026
@souvikghosh04 souvikghosh04 added mssql an issue thats specific to mssql mcp-server labels Jan 22, 2026
@souvikghosh04 souvikghosh04 added this to the Jan 2026 milestone Jan 22, 2026
@souvikghosh04 souvikghosh04 linked an issue Jan 22, 2026 that may be closed by this pull request
@souvikghosh04 souvikghosh04 moved this from Todo to In Progress in Data API builder Jan 22, 2026
Copy link
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

This PR prevents stored-procedure entities that are already exposed as dedicated custom MCP tools from being duplicated in the describe_entities response.

Changes:

  • Added filtering in DescribeEntitiesTool to skip stored procedures with entity.Mcp.CustomToolEnabled == true.
  • Added new MSTest coverage validating stored procedure filtering and ensuring tables/views remain unaffected.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Azure.DataApiBuilder.Mcp/BuiltInTools/DescribeEntitiesTool.cs Filters out custom-tool-enabled stored procedures from describe_entities results.
src/Service.Tests/Mcp/DescribeEntitiesFilteringTests.cs Adds tests verifying filtering behavior across stored procedures, tables/views, and nameOnly mode.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@souvikghosh04
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@JerryNixon
Copy link
Contributor

JerryNixon commented Jan 22, 2026

Desired logic

DML TOOLS = TRUE DML TOOLS = FALSE
CUSTOM TOOL = TRUE ✔ describe_entities
✔ tools/list
✘ describe_entities
✔ tools/list
CUSTOM TOOL = FALSE ✔ describe_entities
✘ tools/list
✘ describe_entities
✘ tools/list

@souvikghosh04 souvikghosh04 changed the title [MCP] Prevent duplicating tool list between custom tools and describe [MCP] Prevent duplicating entities between custom tools and describe_entities Jan 23, 2026
@RubenCerna2079 RubenCerna2079 self-assigned this Jan 28, 2026
}
// All entities were filtered because they're custom-tool-only - only return this specific error
// if ALL configured entities were filtered (not just some). This prevents misleading errors
// when entities fail to build for other reasons (e.g., exceptions in Build*EntityInfo).
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
// when entities fail to build for other reasons (e.g., exceptions in Build*EntityInfo).
// when entities fail to build for other reasons (e.g., exceptions in Build*EntityInfo functions).

// All entities were filtered because they're custom-tool-only - only return this specific error
// if ALL configured entities were filtered (not just some). This prevents misleading errors
// when entities fail to build for other reasons (e.g., exceptions in Build*EntityInfo).
else if (filteredCustomToolCount > 0 &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't we also want a situation where only some of the entities were filtered?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just saw its purpose is to show the user when all their tools are custom-tools, although it might be a good idea to also give the user the information that their SPs that are custom-tools are in a different place.

// - custom-tool: true, dml-tools: false → Filtered (appears only in tools/list)
// - custom-tool: false, dml-tools: false → Filtered (entity fully disabled for MCP)
// When dml-tools is true (or default), the entity appears in describe_entities.
if (entity.Source.Type == EntitySourceType.StoredProcedure &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

For other types of entities (that are not stored procedures), when dmltool enabled is false, do we still need them to be shown in describe_entities?

Or is the dmltoolenabled flag only specific to entities that are stored procs?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If the dmltoolenabled/Mcp section under entity is non-null only when it is a stored procedure entity, we should not need to check for the type of entity to be stored procedure.

public async Task DescribeEntities_TablesAndViewsUnaffectedByFiltering()
{
// Arrange
RuntimeConfig config = CreateConfigWithMixedEntityTypes();
Copy link
Collaborator

Choose a reason for hiding this comment

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

what if some of the tables/views also have dml_tools : false? Shouldnt we filter those out too?

Copy link
Collaborator

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

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

Waiting on what needs to be done for non stored proc entities

@github-project-automation github-project-automation bot moved this from In Progress to Review In Progress in Data API builder Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mcp-server mssql an issue thats specific to mssql

Projects

Status: Review In Progress

Development

Successfully merging this pull request may close these issues.

MCP-CustomTool: describe_entities filtering

5 participants