Add "Insights" Tool#2696
Conversation
|
Thank you for your contribution @micha31r! We will review the pull request and get back to you soon. |
8411b72 to
743a63c
Compare
743a63c to
4dd431b
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new Azure Insights MCP tool (azmcp insights get) that queries Azure Resource Graph, aggregates dominant property patterns, filters out noise/sensitive data, and uses MCP sampling to generate infra-planning insights. It also extends CommandContext to expose the active McpServer, enabling sampling-aware commands during tool execution.
Changes:
- Introduced
Azure.Mcp.Tools.Insightstool area withinsights getcommand, sampling integration, and ARG aggregation/filtering pipeline. - Added unit tests for aggregation/filtering and sampling behavior, and wired the tool into Azure MCP Server (registration, docs, metadata, CODEOWNERS, changelog entry).
- Updated core tool loaders and
CommandContextto pass/hold the currentMcpServerinstance.
Invoking Livetests
Copilot submitted PRs are not trustworthy by default. Users with write access 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.
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.Insights/tests/Azure.Mcp.Tools.Insights.UnitTests/Services/SamplingServiceTests.cs | Adds unit tests for sampling service argument validation. |
| tools/Azure.Mcp.Tools.Insights/tests/Azure.Mcp.Tools.Insights.UnitTests/Services/PropertyAggregatorTests.cs | Adds unit tests for ARG row aggregation behavior. |
| tools/Azure.Mcp.Tools.Insights/tests/Azure.Mcp.Tools.Insights.UnitTests/Services/AggregationFilterTests.cs | Adds unit tests for filtering/denylists and coverage thresholds. |
| tools/Azure.Mcp.Tools.Insights/tests/Azure.Mcp.Tools.Insights.UnitTests/InsightsGetCommandTests.cs | Adds command-level unit tests validating scope selection and sampling behavior. |
| tools/Azure.Mcp.Tools.Insights/tests/Azure.Mcp.Tools.Insights.UnitTests/Azure.Mcp.Tools.Insights.UnitTests.csproj | Introduces unit test project for the Insights tool. |
| tools/Azure.Mcp.Tools.Insights/src/Services/SamplingService.cs | Implements MCP sampling wrapper to request/collect text responses. |
| tools/Azure.Mcp.Tools.Insights/src/Services/PropertyAggregator.cs | Implements per-resource-type property aggregation and top-value fraction emission. |
| tools/Azure.Mcp.Tools.Insights/src/Services/Models/SubscriptionAggregation.cs | Adds aggregation model for scope-level metadata and per-type results. |
| tools/Azure.Mcp.Tools.Insights/src/Services/Models/ResourceTypeAggregation.cs | Adds aggregation model for per-resource-type counts and property maps. |
| tools/Azure.Mcp.Tools.Insights/src/Services/ISamplingService.cs | Defines sampling service contract. |
| tools/Azure.Mcp.Tools.Insights/src/Services/InsightsService.cs | Implements ARG querying (paged) + aggregation + filtering for tenant/subscription scopes. |
| tools/Azure.Mcp.Tools.Insights/src/Services/IInsightsService.cs | Defines Insights aggregation service contract. |
| tools/Azure.Mcp.Tools.Insights/src/Services/AggregationFilter.cs | Implements filtering of noisy types/keys/values and low-signal leaves. |
| tools/Azure.Mcp.Tools.Insights/src/Options/InsightsOptionDefinitions.cs | Adds --query option definition for intent-tailored insights. |
| tools/Azure.Mcp.Tools.Insights/src/Options/InsightsGetOptions.cs | Adds command options model for insights get. |
| tools/Azure.Mcp.Tools.Insights/src/InsightsSetup.cs | Registers Insights services/command with the tool area. |
| tools/Azure.Mcp.Tools.Insights/src/GlobalUsings.cs | Adds tool-level global usings (System.CommandLine / System.Text.Json). |
| tools/Azure.Mcp.Tools.Insights/src/Commands/InsightsJsonContext.cs | Adds STJ source-gen context for command response serialization. |
| tools/Azure.Mcp.Tools.Insights/src/Commands/InsightsGetCommand.cs | Implements azmcp insights get command, payload building, and response parsing. |
| tools/Azure.Mcp.Tools.Insights/src/Azure.Mcp.Tools.Insights.csproj | Introduces Insights tool project and dependencies (ARG, MCP, command line). |
| tools/Azure.Mcp.Tools.Insights/src/AssemblyInfo.cs | Adds InternalsVisibleTo declarations for test projects. |
| servers/Azure.Mcp.Server/src/Resources/consolidated-tools.json | Adds consolidated tool mapping for the new Insights tool. |
| servers/Azure.Mcp.Server/src/Program.cs | Registers the Insights tool area in the Azure MCP server. |
| servers/Azure.Mcp.Server/README.md | Documents example prompts and adds Insights to service list. |
| servers/Azure.Mcp.Server/docs/e2eTestPrompts.md | Adds e2e prompts for insights_get. |
| servers/Azure.Mcp.Server/docs/azmcp-commands.md | Adds CLI command documentation for azmcp insights get. |
| servers/Azure.Mcp.Server/changelog-entries/1779342467515.yaml | Adds changelog entry for the new Insights command. |
| Microsoft.Mcp.slnx | Adds the new Insights projects to the solution. |
| core/Microsoft.Mcp.Core/src/Models/Command/CommandContext.cs | Adds McpServer to command execution context via constructor overload. |
| core/Microsoft.Mcp.Core/src/Areas/Server/Commands/ToolLoading/NamespaceToolLoader.cs | Passes request.Server into CommandContext for namespace tool invocation. |
| core/Microsoft.Mcp.Core/src/Areas/Server/Commands/ToolLoading/CommandFactoryToolLoader.cs | Passes request.Server into CommandContext for command-factory tool invocation. |
| .github/CODEOWNERS | Adds code ownership entries for the new Insights tool folder. |
| <InternalsVisibleTo Include="Azure.Mcp.Tools.Insights.UnitTests" /> | ||
| </ItemGroup> | ||
| <ItemGroup> |
What does this PR do?
Azure.Mcp.Tools.Insightstool.CommandContextconstructor to expose themcpServerobject - required for MCP sampling feature.This tool generates insights that can be used for infra-planning tasks. For example, we have the
azure-enterprise-infra-plannerskill which will use the insights generated to align new infra plans with user's existing Azure environment, with the goal of reducing manual editing and increase plan acceptance.Insights generation flow:
GitHub issue number?
Issue 2694
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