Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds shared query-safety helpers in Microsoft.Mcp.Core and wires them into multiple tools to reduce injection risk by parameterizing SQL string literals and escaping/sanitizing KQL inputs.
Changes:
- Introduces
SqlQueryParameterizer(SQL string-literal parameterization) andKqlSanitizer(KQL escaping/sanitization) inMicrosoft.Mcp.Core.Helpers. - Updates MySQL/Postgres/Cosmos query execution paths to bind extracted parameters instead of embedding string literals directly.
- Updates Kusto/Monitor/Deploy KQL construction/execution to validate and/or escape identifiers and string values; adds unit tests and a changelog entry.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.Postgres/tests/Azure.Mcp.Tools.Postgres.UnitTests/Services/PostgresServiceParameterizationTests.cs | Adds unit tests covering SQL string-literal parameterization behavior (Postgres dialect). |
| tools/Azure.Mcp.Tools.Postgres/src/Services/PostgresService.cs | Applies parameterization before creating/executing NpgsqlCommand. |
| tools/Azure.Mcp.Tools.MySql/tests/Azure.Mcp.Tools.MySql.UnitTests/Services/MySqlServiceParameterizationTests.cs | Adds unit tests covering SQL string-literal parameterization behavior (MySQL dialect). |
| tools/Azure.Mcp.Tools.MySql/src/Services/MySqlService.cs | Applies parameterization before executing MySqlCommand. |
| tools/Azure.Mcp.Tools.Monitor/tests/Azure.Mcp.Tools.Monitor.UnitTests/MonitorServiceKqlEscapingTests.cs | Adds unit tests for KQL identifier escaping helper usage. |
| tools/Azure.Mcp.Tools.Monitor/src/Services/MonitorService.cs | Escapes the table placeholder in predefined KQL queries. |
| tools/Azure.Mcp.Tools.Kusto/tests/Azure.Mcp.Tools.Kusto.UnitTests/SanitizeKqlStringLiteralsTests.cs | Adds unit tests for KQL string literal sanitization. |
| tools/Azure.Mcp.Tools.Kusto/tests/Azure.Mcp.Tools.Kusto.UnitTests/KqlQueryValidatorTests.cs | Adds unit tests for KQL query safety validation rules. |
| tools/Azure.Mcp.Tools.Kusto/src/Validation/KqlQueryValidator.cs | Introduces KQL query validation to block comments, management commands, stacked statements, and common tautologies. |
| tools/Azure.Mcp.Tools.Kusto/src/Services/KustoService.cs | Adds KQL validation + string-literal sanitization before query execution; refactors identifier escaping to shared helper. |
| tools/Azure.Mcp.Tools.Deploy/tests/Azure.Mcp.Tools.Deploy.UnitTests/Services/AzdAppLogRetrieverKqlEscapingTests.cs | Adds unit tests for KQL string value escaping used in Deploy log queries. |
| tools/Azure.Mcp.Tools.Deploy/src/Services/Util/AzdAppLogRetriever.cs | Escapes user-provided values interpolated into KQL log queries. |
| tools/Azure.Mcp.Tools.Deploy/src/AssemblyInfo.cs | Updates InternalsVisibleTo list to include Deploy unit tests. |
| tools/Azure.Mcp.Tools.Cosmos/tests/Azure.Mcp.Tools.Cosmos.UnitTests/CosmosServiceParameterizationTests.cs | Adds unit tests covering SQL string-literal parameterization behavior for Cosmos SQL queries. |
| tools/Azure.Mcp.Tools.Cosmos/src/Services/CosmosService.cs | Applies parameterization and binds parameters via QueryDefinition.WithParameter. |
| servers/Azure.Mcp.Server/changelog-entries/1775582739966.yaml | Adds a changelog entry describing the new parameterization/sanitization behavior. |
| core/Microsoft.Mcp.Core/src/Helpers/SqlQueryParameterizer.cs | Adds a shared SQL single-quoted literal parser/parameterizer with dialect support. |
| core/Microsoft.Mcp.Core/src/Helpers/KqlSanitizer.cs | Adds shared helpers for escaping KQL identifiers/values and sanitizing string literals. |
alzimmermsft
reviewed
Apr 7, 2026
alzimmermsft
reviewed
Apr 7, 2026
vukelich
reviewed
Apr 7, 2026
Member
vukelich
left a comment
There was a problem hiding this comment.
Couple early comments. Still more to read.
g2vinay
reviewed
Apr 7, 2026
g2vinay
reviewed
Apr 7, 2026
g2vinay
reviewed
Apr 7, 2026
.../Microsoft.Mcp.Core/tests/Microsoft.Mcp.Core.UnitTests/Helpers/SqlQueryParameterizerTests.cs
Show resolved
Hide resolved
g2vinay
approved these changes
Apr 7, 2026
KarishmaGhiya
approved these changes
Apr 7, 2026
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.
What does this PR do?
[Provide a clear, concise description of the changes]Added query parameterization
[Add additional context, screenshots, or information that helps reviewers]GitHub issue number?
[Link to the GitHub issue this PR addresses]Pre-merge Checklist
servers/Azure.Mcp.Server/README.mdand/orservers/Fabric.Mcp.Server/README.mddocumentationREADME.mdchanges running the script./eng/scripts/Process-PackageReadMe.ps1. See Package READMEToolDescriptionEvaluatorand obtained a score of0.4or more and a top 3 ranking for all related test promptsconsolidated-tools.jsonbreaking-changelabelservers/Azure.Mcp.Server/docs/azmcp-commands.md./eng/scripts/Update-AzCommandsMetadata.ps1to update tool metadata inazmcp-commands.md(required for CI)servers/Azure.Mcp.Server/docs/e2eTestPrompts.mdcrypto mining, spam, data exfiltration, etc.)/azp run mcp - pullrequest - liveto run Live Test Pipeline