kusto_query: migrate query path/parsing to v2 and add --show-stats#1787
Open
gholliday wants to merge 2 commits intomicrosoft:mainfrom
Open
kusto_query: migrate query path/parsing to v2 and add --show-stats#1787gholliday wants to merge 2 commits intomicrosoft:mainfrom
gholliday wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Migrate query requests to /v2/rest/query with required headers and decompression, parse v2 frames including DataSetCompletion errors, and add --show-stats structured statistics output with unit tests, docs, and changelog entry. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thank you for your contribution @gholliday! We will review the pull request and get back to you soon. |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the kusto_query tool to execute queries via Kusto’s /v2/rest/query frame-based response format and adds an optional --show-stats flag to return structured execution statistics alongside results.
Changes:
- Migrates Kusto query execution to
/v2/rest/queryand adds v2 frame parsing (PrimaryResult + DataSetCompletion error handling). - Adds
--show-statsoption and plumbs statistics extraction fromQueryCompletionInformationframes through to the command response. - Adds/updates unit tests and updates command documentation and changelog entry.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.Kusto/src/Services/KustoService.cs | Adds v2 frame parsing, statistics extraction, and new QueryItemsWithStatisticsAsync APIs. |
| tools/Azure.Mcp.Tools.Kusto/src/Services/KustoClient.cs | Switches query endpoint to /v2/rest/query, uses named HttpClient, and adds readonly/compression/connection headers. |
| tools/Azure.Mcp.Tools.Kusto/src/Services/IKustoService.cs | Extends interface with new tuple-returning QueryItemsWithStatisticsAsync overloads. |
| tools/Azure.Mcp.Tools.Kusto/src/Commands/QueryCommand.cs | Adds --show-stats option and includes optional statistics in the response model. |
| tools/Azure.Mcp.Tools.Kusto/src/Options/QueryOptions.cs | Adds ShowStats option binding model property. |
| tools/Azure.Mcp.Tools.Kusto/src/Options/KustoOptionDefinitions.cs | Defines --show-stats option. |
| tools/Azure.Mcp.Tools.Kusto/src/KustoSetup.cs | Registers a named HttpClient configured for gzip/deflate decompression. |
| tools/Azure.Mcp.Tools.Kusto/tests/Azure.Mcp.Tools.Kusto.UnitTests/QueryCommandTests.cs | Updates tests to use new service API and adds coverage for --show-stats. |
| tools/Azure.Mcp.Tools.Kusto/tests/Azure.Mcp.Tools.Kusto.UnitTests/KustoServiceTests.cs | Adds new tests for v2 frame parsing, error handling, and statistics extraction. |
| tools/Azure.Mcp.Tools.Kusto/tests/Azure.Mcp.Tools.Kusto.UnitTests/KustoClientTests.cs | Adds assertions for v2 endpoint usage and expected request headers. |
| servers/Azure.Mcp.Server/docs/e2eTestPrompts.md | Adds an e2e prompt that exercises statistics output. |
| servers/Azure.Mcp.Server/docs/azmcp-commands.md | Documents optional [--show-stats] on kusto query. |
| servers/Azure.Mcp.Server/changelog-entries/copilot-kusto-query-v2-show-stats.yaml | Changelog entry for v2 migration and the new stats option. |
17 tasks
Remove duplicate QueryItems validation, replace brittle columns JSON string construction with writer-based object creation, and avoid reparsing rows by cloning JsonElement directly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
I can't get the tests working, and it appears that they are a pre-existing issue. I've contributed this to microsoft/fabric-rti-mcp#123 instead, so feel free to close this one. |
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?
This PR updates the existing
kusto_querytool to use Kusto query v2 response handling and adds an optional--show-statsparameter so users can retrieve execution statistics (CPU, memory, cache, extents, network, and cross-cluster breakdown) alongside query results.It also updates tests and docs for the new behavior, keeps
/v1/rest/mgmtunchanged, and adds a changelog entry.GitHub issue number?
Closes #1786
Pre-merge Checklist
servers/Azure.Mcp.Server/changelog-entries/kusto_queryservers/Azure.Mcp.Server/README.mddocumentationeng/scripts/Process-PackageReadMe.ps1(not applicable - README not changed)/servers/Azure.Mcp.Server/docs/azmcp-commands.md./eng/scripts/Update-AzCommandsMetadata.ps1to update tool metadata in azmcp-commands.mdToolDescriptionEvaluatorwith score >= 0.4 and top-3 ranking for related promptsconsolidated-tools.json(not applicable - no new tool name)/servers/Azure.Mcp.Server/docs/e2eTestPrompts.mdValidation run
dotnet build .\mcp.sln./eng/scripts/Test-Code.ps1 -Paths Kustoinitialize+tools/list+kusto_query) againsthttps://help.kusto.windows.netwith and withoutshow-statsInvoking Livetests
Copilot submitted PRs are not trustworthy by default. Users with
writeaccess to the repo need to validate the contents of this PR before leaving a comment with the text/azp run mcp - pullrequest - live. This will trigger the necessary livetest workflows to complete required validation.