Fix whitespace handling in MCP read_records select lists - #3786
Open
aaronburtle wants to merge 1 commit into
Open
Fix whitespace handling in MCP read_records select lists#3786aaronburtle wants to merge 1 commit into
aaronburtle wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes MCP read_records parsing of the select argument by tolerating whitespace around comma-separated field names, aligning the tool’s behavior with its “Comma-separated field names” contract and preventing false “invalid field” errors.
Changes:
- Trim whitespace around each field name after splitting the comma-separated
selectvalue inReadRecordsTool. - Add an MsSql MCP integration test that exercises
select: "id, title"(space after comma).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/ReadRecordsTool.cs | Trims split select entries before updating return fields for request validation/execution. |
| src/Service.Tests/Mcp/ReadRecordsToolMsSqlIntegrationTests.cs | Adds a regression integration test ensuring whitespace after the select comma succeeds. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| { | ||
| // Update the context to specify which fields will be returned from the entity. | ||
| IEnumerable<string> fieldsReturnedForFind = select.Split(",").ToList(); | ||
| IEnumerable<string> fieldsReturnedForFind = select.Split(',').Select(field => field.Trim()).ToList(); |
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?
Closes #3771
What is this change?
selectvalue.How was this tested?
ReadRecords_WithWhitespaceAfterSelectComma_ReturnsSelectedFields.Sample Request(s)
Example MCP
read_recordsarguments:The request now succeeds and returns the selected
idandtitlefields.CLI, REST, and GraphQL samples are not applicable because this change affects the MCP
read_recordstool only.