Cherry pick PR to allow create_record tool for views and supporting tests.#3251
Open
anushakolan wants to merge 2 commits intorelease/1.7from
Open
Cherry pick PR to allow create_record tool for views and supporting tests.#3251anushakolan wants to merge 2 commits intorelease/1.7from
anushakolan wants to merge 2 commits intorelease/1.7from
Conversation
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull request overview
Backports MCP entity-level configuration support into release/1.7, adds CLI/schema support for the new entities.<name>.mcp settings, and fixes MCP DML tooling behavior so create_record supports view-backed entities (plus associated tests).
Changes:
- Add entity-level MCP config model + JSON (de)serialization support and expose it through CLI add/update flags.
- Enforce entity-level enablement checks in MCP tools (DML + custom tools), and allow
create_recordfor view entities. - Add/extend unit tests and JSON schema updates covering entity-level MCP config and tool behavior.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Service.Tests/ModuleInitializer.cs | Updates snapshot verification settings to ignore new MCP user-provided flags. |
| src/Service.Tests/Mcp/EntityLevelDmlToolConfigurationTests.cs | Adds MCP tool execution tests for entity-level enablement and view/table support. |
| src/Service.Tests/Configuration/EntityMcpConfigurationTests.cs | Adds config deserialization/validation tests for entity-level mcp formats. |
| src/Config/RuntimeConfigLoader.cs | Registers the new entity-level MCP converter for config JSON parsing/serialization. |
| src/Config/ObjectModel/EntityMcpOptions.cs | Introduces the entity-level MCP options model and user-provided flags. |
| src/Config/ObjectModel/Entity.cs | Adds Entity.Mcp to the object model and wires converter usage. |
| src/Config/Converters/EntityMcpOptionsConverterFactory.cs | Implements boolean/object JSON forms for entities.<name>.mcp. |
| src/Cli/Utils.cs | Adds CLI parsing/validation helper for MCP entity options. |
| src/Cli/ConfigGenerator.cs | Plumbs MCP options through dab add/dab update entity generation. |
| src/Cli/Commands/UpdateOptions.cs | Adds MCP CLI parameters to update options plumbing. |
| src/Cli/Commands/EntityOptions.cs | Adds --mcp.dml-tools and --mcp.custom-tool options. |
| src/Cli/Commands/AddOptions.cs | Adds MCP CLI parameters to add options plumbing. |
| src/Cli.Tests/UpdateEntityTests.cs | Adds CLI update tests covering MCP entity option behavior/validation. |
| src/Cli.Tests/ModuleInitializer.cs | Updates snapshot verification settings to ignore new MCP user-provided flags. |
| src/Cli.Tests/AddEntityTests.cs | Adds CLI add tests covering MCP entity option behavior/validation. |
| src/Azure.DataApiBuilder.Mcp/Utils/McpErrorHelpers.cs | Extends ToolDisabled helper to optionally use a custom message. |
| src/Azure.DataApiBuilder.Mcp/Core/DynamicCustomTool.cs | Adds runtime entity-level enablement validation for custom tools (hot-reload scenario). |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/UpdateRecordTool.cs | Adds entity-level DML enablement checks + validates table/view targets. |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/ReadRecordsTool.cs | Adds entity-level DML enablement checks + validates table/view targets. |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/ExecuteEntityTool.cs | Adds entity-level DML enablement check and hardens null entity map handling. |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/DeleteRecordTool.cs | Adds entity-level DML enablement checks. |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/CreateRecordTool.cs | Allows view targets (skips table-only validation) + adds entity-level DML checks. |
| schemas/dab.draft.schema.json | Documents/defines entity-level mcp schema and adds stored-proc constraint for custom tools. |
schemas/dab.draft.schema.json
Outdated
Comment on lines
+1175
to
+1186
| "if": { | ||
| "properties": { | ||
| "mcp": { | ||
| "properties": { | ||
| "custom-tool": { | ||
| "const": true | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "required": ["mcp"] | ||
| }, |
Comment on lines
+88
to
+121
| public override void Write(Utf8JsonWriter writer, EntityMcpOptions value, JsonSerializerOptions options) | ||
| { | ||
| if (value == null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| // Check if we should write as boolean shorthand | ||
| // Write as boolean if: only dml-tools is set (or custom-tool is default false) | ||
| bool writeAsBoolean = !value.UserProvidedCustomToolEnabled && value.UserProvidedDmlToolsEnabled; | ||
|
|
||
| if (writeAsBoolean) | ||
| { | ||
| // Write as boolean shorthand | ||
| writer.WriteBooleanValue(value.DmlToolEnabled); | ||
| } | ||
| else if (value.UserProvidedCustomToolEnabled || value.UserProvidedDmlToolsEnabled) | ||
| { | ||
| // Write as object | ||
| writer.WriteStartObject(); | ||
|
|
||
| if (value.UserProvidedCustomToolEnabled) | ||
| { | ||
| writer.WriteBoolean("custom-tool", value.CustomToolEnabled); | ||
| } | ||
|
|
||
| if (value.UserProvidedDmlToolsEnabled) | ||
| { | ||
| writer.WriteBoolean("dml-tools", value.DmlToolEnabled); | ||
| } | ||
|
|
||
| writer.WriteEndObject(); | ||
| } | ||
| } |
src/Cli/ConfigGenerator.cs
Outdated
Comment on lines
+1670
to
+1671
| // Keep existing MCP options if no updates provided | ||
| updatedMcpOptions = entity.Mcp; |
| // Assert | ||
| Assert.IsTrue(result.IsError == true, "Expected error when entity has DmlToolEnabled=false"); | ||
|
|
||
| JsonElement content = await RunToolAsync(tool, arguments, serviceProvider); |
| CancellationToken cancellationToken = default) | ||
| { | ||
| ILogger<DynamicCustomTool>? logger = serviceProvider.GetService<ILogger<DynamicCustomTool>>(); | ||
| string toolName = GetToolMetadata().Name; |
Aniruddh25
approved these changes
Mar 16, 2026
Collaborator
|
PR title should be accurate. |
souvikghosh04
approved these changes
Mar 18, 2026
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
… same. (#3196) Closes #3194 - MCP `create_record` tool incorrectly blocks views with error `"The create_record tool is only available for tables."` 1. Views are the required workaround for unsupported SQL data types (e.g., vector columns). Users could create views that omit unsupported columns and perform DML operations against those views. 2. This bug prevents INSERT operations via MCP on view entities, breaking a critical workflow for vector database scenarios. 1. Modified `CreateRecordTool.cs` to allow both tables and views to pass source type validation 2. Changed `else` block (which caught views) to`else if (EntitySourceType.StoredProcedure)` so only stored procedures are blocked 3. Views now fall through to the mutation engine, which already supports INSERT on updateable views 4. Updated error message to `"The create_record tool is only available for tables and views."` 5. Added 8 unit tests validating all DML tools (CreateRecord, ReadRecords, UpdateRecord, DeleteRecord) work with both Table and View source types - [ ] Integration Tests - [X] Unit Tests 1. `DmlTool_AllowsTablesAndViews` - 8 DataRow test cases verifying no `InvalidCreateTarget` error for views 2. Existing REST integration tests `InsertOneInViewTest` already validate view INSERT via same mutation engine Manually tested via MCP Inspector, to verify `create_record` calls succeeds on a view. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Aniruddh Munde <anmunde@microsoft.com> (cherry picked from commit e5bf26f)
9edb825 to
e08ced3
Compare
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
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.
Why make this change?
This backport fixes MCP behavior where create_record incorrectly rejected view-backed entities with the error that the tool is only available for tables.
Views are a required workaround for unsupported SQL data types in some scenarios (e.g., vector columns), so this fix restores expected INSERT behavior for those entities.
What is this change?
Cherry-picked PR:
How was this tested?
create_recordagainst view-backed entities.Sample Request(s)
N/A