Skip to content

Add "Insights" Tool#2696

Closed
micha31r wants to merge 9 commits into
microsoft:mainfrom
micha31r:user/mren/insights
Closed

Add "Insights" Tool#2696
micha31r wants to merge 9 commits into
microsoft:mainfrom
micha31r:user/mren/insights

Conversation

@micha31r
Copy link
Copy Markdown

@micha31r micha31r commented May 21, 2026

What does this PR do?

  • Adds a new Azure.Mcp.Tools.Insights tool.
  • Overloads CommandContext constructor to expose the mcpServer object - 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-planner skill 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:

  1. Fetch ARG data from Azure Resource Graph.
  2. Compute property aggregations (how often each value appears).
  3. Strip irrelevant fields and secrets (non-exhaustive).
  4. Use MCP sampling feature to generate insights.

GitHub issue number?

Issue 2694

Pre-merge Checklist

  • Required for All PRs
    • Read contribution guidelines
    • PR title clearly describes the change
    • Commit history is clean with descriptive messages (cleanup guide)
    • Added comprehensive tests for new/modified functionality
    • Created a changelog entry if the change falls among the following: new feature, bug fix, UI/UX update, breaking change, or updated dependencies. Follow the changelog entry guide
  • For MCP tool changes:
    • One tool per PR: This PR adds or modifies only one MCP tool for faster review cycles
    • Updated servers/Azure.Mcp.Server/README.md and/or servers/Fabric.Mcp.Server/README.md documentation
    • Validate README.md changes running the script ./eng/scripts/Process-PackageReadMe.ps1. See Package README
    • For new or modified tool descriptions, ran ToolDescriptionEvaluator and obtained a score of 0.4 or more and a top 3 ranking for all related test prompts
    • For tools with new names, including new tools or renamed tools, update consolidated-tools.json
    • For renamed tools, follow the Tool Rename Checklist and tag the PR with the breaking-change label
    • For new tools associated with Azure services or publicly available tools/APIs/products, add URL to documentation in the PR description
  • Extra steps for Azure MCP Server tool changes:
    • Updated command list in servers/Azure.Mcp.Server/docs/azmcp-commands.md
    • Ran ./eng/scripts/Update-AzCommandsMetadata.ps1 to update tool metadata in azmcp-commands.md (required for CI)
    • Updated test prompts in servers/Azure.Mcp.Server/docs/e2eTestPrompts.md
    • 👉 For Community (non-Microsoft team member) PRs:
      • Security review: Reviewed code for security vulnerabilities, malicious code, or suspicious activities before running tests (crypto mining, spam, data exfiltration, etc.)
      • Manual tests run: added comment /azp run mcp - pullrequest - live to run Live Test Pipeline

@github-actions
Copy link
Copy Markdown
Contributor

Thank you for your contribution @micha31r! We will review the pull request and get back to you soon.

@micha31r micha31r force-pushed the user/mren/insights branch 3 times, most recently from 8411b72 to 743a63c Compare May 21, 2026 14:11
@micha31r micha31r force-pushed the user/mren/insights branch 2 times, most recently from 743a63c to 4dd431b Compare May 21, 2026 14:13
@micha31r micha31r marked this pull request as ready for review May 21, 2026 14:14
@micha31r micha31r requested review from a team as code owners May 21, 2026 14:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Insights tool area with insights get command, 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 CommandContext to pass/hold the current McpServer instance.

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.

Comment thread tools/Azure.Mcp.Tools.Insights/src/Services/AggregationFilter.cs
Comment thread tools/Azure.Mcp.Tools.Insights/src/Services/AggregationFilter.cs
Comment on lines +6 to +8
<InternalsVisibleTo Include="Azure.Mcp.Tools.Insights.UnitTests" />
</ItemGroup>
<ItemGroup>
Comment thread servers/Azure.Mcp.Server/changelog-entries/1779342467515.yaml
@micha31r micha31r closed this May 22, 2026
@github-project-automation github-project-automation Bot moved this from Untriaged to Done in Azure MCP Server May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants