-
Notifications
You must be signed in to change notification settings - Fork 301
[MCP] Prevent duplicating entities between custom tools and describe_entities #3076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0a4c986
e701a87
c793712
b9fd106
e2cc3e8
a2f95a5
4376db7
4f6fff5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -146,6 +146,10 @@ public Task<CallToolResult> ExecuteAsync( | |||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| List<Dictionary<string, object?>> entityList = new(); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // Track how many entities were filtered out because DML tools are disabled (dml-tools: false). | ||||||||||||||||||||||||||||||||||||
| // This helps provide a more specific error message when all entities are filtered. | ||||||||||||||||||||||||||||||||||||
| int filteredDmlDisabledCount = 0; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if (runtimeConfig.Entities != null) | ||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||
| foreach (KeyValuePair<string, Entity> entityEntry in runtimeConfig.Entities) | ||||||||||||||||||||||||||||||||||||
|
|
@@ -155,6 +159,16 @@ public Task<CallToolResult> ExecuteAsync( | |||||||||||||||||||||||||||||||||||
| string entityName = entityEntry.Key; | ||||||||||||||||||||||||||||||||||||
| Entity entity = entityEntry.Value; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // Filter out entities when dml-tools is explicitly disabled (false). | ||||||||||||||||||||||||||||||||||||
| // This applies to all entity types (tables, views, stored procedures). | ||||||||||||||||||||||||||||||||||||
| // When dml-tools is false, the entity is not exposed via DML tools | ||||||||||||||||||||||||||||||||||||
| // (read_records, create_record, etc.) and should not appear in describe_entities. | ||||||||||||||||||||||||||||||||||||
| if (entity.Mcp?.DmlToolEnabled == false) | ||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||
| filteredDmlDisabledCount++; | ||||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if (!ShouldIncludeEntity(entityName, entityFilter)) | ||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+166
to
173
|
||||||||||||||||||||||||||||||||||||
| if (entity.Mcp?.DmlToolEnabled == false) | |
| { | |
| filteredDmlDisabledCount++; | |
| continue; | |
| } | |
| if (!ShouldIncludeEntity(entityName, entityFilter)) | |
| { | |
| if (!ShouldIncludeEntity(entityName, entityFilter)) | |
| { | |
| continue; | |
| } | |
| if (entity.Mcp?.DmlToolEnabled == false) | |
| { | |
| filteredDmlDisabledCount++; |
Copilot
AI
Jan 31, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The log template repeats the {FilteredCount} placeholder name twice and requires passing the same argument twice. Consider removing the duplicate placeholder (or renaming one of them) to avoid duplicate structured-log keys and to simplify the call site.
| "Returned {ReturnedCount} entities, filtered {FilteredCount}.", | |
| "Returned {ReturnedCount} entities, filtered {FilteredCountTotal}.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new filtering block excludes any entity with
entity.Mcp?.DmlToolEnabled == false, regardless of entity type orCustomToolEnabled. This is broader than the PR description (stored-procedure, custom-tool-only de-duplication). If the intent is only to avoid duplication with custom tools, restrict the condition to stored procedures whereCustomToolEnabled == trueandDmlToolEnabled == false; otherwise, please update the PR description/tests to reflect the expanded behavior.