Align MCP create_record/update_record with shared authorization helper#3730
Open
souvikghosh04 wants to merge 5 commits into
Open
Align MCP create_record/update_record with shared authorization helper#3730souvikghosh04 wants to merge 5 commits into
souvikghosh04 wants to merge 5 commits into
Conversation
…r pattern Extends McpAuthorizationHelper with a small reusable check used by the read-side MCP tools, and calls it from CreateRecordTool/UpdateRecordTool for consistency with the rest of the tool set. Adds accompanying test coverage.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens MCP DML tool authorization by adding an explicit column-level authorization check for create_record and update_record, aligning these tools with existing authorization patterns used elsewhere (and preventing fields.exclude/fields.include bypasses).
Changes:
- Added a reusable column-level authorization helper (
McpAuthorizationHelper.AreColumnsAuthorizedForOperation). - Updated
CreateRecordToolandUpdateRecordToolto enforce column-level authorization immediately after role resolution. - Added a dedicated test role/config entry plus regression tests to validate excluded-column enforcement for both create and update.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Azure.DataApiBuilder.Mcp/Utils/McpAuthorizationHelper.cs | Adds a shared helper to enforce column-level authorization for mutations. |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/CreateRecordTool.cs | Enforces column-level authorization for create payload columns. |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/UpdateRecordTool.cs | Enforces column-level authorization for update payload columns. |
| src/Service.Tests/Mcp/McpToolTestBase.cs | Enables mutation test service providers to simulate different client roles. |
| src/Service.Tests/Mcp/CreateRecordToolMsSqlIntegrationTests.cs | Adds regression + sanity tests for excluded-column behavior on create. |
| src/Service.Tests/Mcp/UpdateRecordToolMsSqlIntegrationTests.cs | Adds regression + sanity tests for excluded-column behavior on update. |
| src/Service.Tests/dab-config.MsSql.json | Adds a test role with mutation-time excluded fields for the new regression tests. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
souvikghosh04
marked this pull request as ready for review
July 21, 2026 09:16
souvikghosh04
requested review from
Alekhya-Polavarapu,
Aniruddh25,
JerryNixon,
RubenCerna2079,
aaronburtle,
anushakolan,
rusamant,
sourabh1007,
stuartpa and
vadeveka
as code owners
July 21, 2026 09:16
… test The Book entity's only non-key column (publisher_id) is NOT NULL with no default, so a role excluded from writing it can never satisfy Book's required-field validation on create -- unrelated to authorization. Switched the success-path sanity check to the WebsiteUser entity, whose only non-key column (username) is nullable, so omitting the excluded column is valid.
souvikghosh04
force-pushed
the
mcp/dml-tool-authz-consistency
branch
from
July 21, 2026 15:29
c84ec2c to
fb815cd
Compare
The MCP create_record/update_record column-exclusion integration tests passed locally but failed in CI. CI regenerates src/Service.Tests/dab-config.MsSql.json from config-generators/mssql-commands.txt; the role existed only in the checked-in JSON, so the regenerated CI config lacked it and inheritance from the 'authenticated' role (no field exclusions) allowed writes to excluded columns. Add the role to mssql-commands.txt for Book (exclude publisher_id) and WebsiteUser (exclude username) on create/update. Add AuthorizationResolver unit tests covering multi-action-per-role column exclusion and config parsing.
souvikghosh04
force-pushed
the
mcp/dml-tool-authz-consistency
branch
from
July 22, 2026 05:19
fb815cd to
20d95f7
Compare
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.
Summary
Minor internal consistency update for the built-in MCP DML tools (create_record, update_record).
Both tools now route through a small shared authorization helper (McpAuthorizationHelper) before invoking the mutation engine, matching the pattern already used elsewhere in the MCP tool set. No changes to public tool schemas, request/response shapes, or supported scenarios.
Changes
Testing
Notes
Opened as draft while final validation completes.