Skip to content

Add Azure.Mcp.Tools.SreAgent (scaffolding for issue #2541)#2611

Open
BandaruDheeraj wants to merge 29 commits into
mainfrom
bandarud/sre-agent-tools
Open

Add Azure.Mcp.Tools.SreAgent (scaffolding for issue #2541)#2611
BandaruDheeraj wants to merge 29 commits into
mainfrom
bandarud/sre-agent-tools

Conversation

@BandaruDheeraj
Copy link
Copy Markdown

@BandaruDheeraj BandaruDheeraj commented May 8, 2026

Summary

New tool group Azure.Mcp.Tools.SreAgent (resolves #2541) that ports the SRE Agent MCP server from the Node implementation in microsoft/sreagent-runtime to the .NET azmcp server.

The tool group exposes 57 commands across 11 sub-groups for managing and interacting with Azure SRE Agent (Microsoft.App/SREAgentPreview) resources and their data-plane API (https://*.azuresre.ai).

Scope

Sub-groups + commands

Sub-group Commands
agents list get create delete
agents tools list get create
skills list create delete
connectors list get create-kusto create-mcp delete test
hooks list get delete
hooks thread list activate deactivate
threads list get create send-message delete investigate investigate-yolo
scheduledtasks list get create delete pause resume
incidents active-list create plans-list plans-create setup-pagerduty setup-servicenow
workflows generate validate apply
docs get plus memories-list memories-search memories-add memories-delete memories-reindex
architecture plan
commonprompts list get create delete

Implementation

  • ARM enumeration of Microsoft.App/SREAgentPreview resources via Azure Resource Graph (BaseAzureResourceService.ExecuteResourceQueryAsync<T>).
  • Data-plane calls use a bearer token for https://azuresre.dev/.default (matches the audience the existing .NET CLI in the SRE Agent runtime repo uses).
  • SreAgentService injects IHttpClientFactory per the repo convention (unblocks recorded-test migration).
  • Envelope shapes, field names, and error semantics mirror the Node MCP server at HEAD ce366bf0a3 so existing SRE Agent dashboards/clients see the same JSON.
  • CommandMetadata populated for every command (Id, Title, Description, Destructive, Idempotent, OpenWorld, ReadOnly, Secret, LocalRequired).

Tests

114 unit tests in Azure.Mcp.Tools.SreAgent.UnitTests (6 existing + 108 new). Every ported command has a Constructor_InitializesCommandCorrectly and RegisterOptions_AddsExpectedOptions test backed by the shared CommandUnitTestsBase<TCommand, TService> harness. Live end-to-end testing against an SRE Agent resource has not been performed in this PR.

Changelog

Adds a Features Added entry under Azure.Mcp.Server describing the new SRE Agent tool group.

Files

  • tools/Azure.Mcp.Tools.SreAgent/src - service, commands, models, options, setup
  • tools/Azure.Mcp.Tools.SreAgent/tests - unit tests
  • servers/Azure.Mcp.Server/src/Areas/AreaSetupFactory.cs - registration
  • servers/Azure.Mcp.Server/CHANGELOG.md - feature entry

Issue

Closes #2541

Adds initial scaffolding for the Azure SRE Agent tool package per the standard Azure.Mcp.Tools.<Service> pattern. This is a draft introducing the area registration only; the full set of SRE Agent tools (agents, skills, connectors, threads, hooks, scheduled tasks, incidents, knowledge memory, documentation, workflows, architecture planning) will land as follow-up commits on this branch.

Adds:

- tools/Azure.Mcp.Tools.SreAgent/src/* (csproj, Setup, JsonContext, BaseCommand, Models, Options, Services skeleton, AgentsListCommand)

- Registers SreAgentSetup() in servers/Azure.Mcp.Server/src/Program.cs RegisterAreas

- Adds slnx folder + project entries in servers/Azure.Mcp.Server/Azure.Mcp.Server.slnx

Tracking issue: #2541

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Dheeraj Bandaru and others added 5 commits May 8, 2026 14:08
BaseAzureService.ValidateRequiredParameters expects (string name, string? value) tuples, not bare strings. Local build now green against SDK 10.0.203.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
SreAgentService now extends BaseAzureResourceService and queries Azure Resource Graph for Microsoft.App/SREAgentPreview resources. ListAgentsAsync returns real data including the per-agent data-plane endpoint (properties.endpoint, with properties.fqdn fallback for older preview API versions).

Adds CallDataPlaneAsync helper that mints a bearer token for the SRE Agent data-plane audience (https://azuresre.dev/.default — same audience the existing .NET CLI in the SRE Agent runtime repo uses) and forwards the request to https://*.azuresre.ai. This is the foundation that the remaining 29 commands across 11 tool groups (Threads, Connectors, Hooks, Skills, Incidents, ScheduledTasks, Docs, Workflows, Architecture, etc.) will call into.

Full Azure.Mcp.Server build succeeds with the new package included via the existing tools/Azure.*/src/*.csproj wildcard.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…mmands

Ports the SRE Agent Node MCP server tools agents.ts, create-agent-tool.ts, get-agent-tool.ts, skills.ts to C# commands. Each command resolves the per-agent data-plane endpoint via ARM (ListAgentsAsync) and calls the SRE Agent REST API via SreAgentService.CallDataPlaneAsync.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ds, ScheduledTasks, Incidents, Workflows, Docs, Architecture (~48 commands across 11 tool groups)

Block-merged via #region (sub-agent X) markers from:
- bandarud/sre-B-conn-hooks: Connectors + Hooks
- bandarud/sre-C-threads-sched: Threads + ScheduledTasks
- bandarud/sre-D-incidents-misc: Incidents + Workflows + Docs + Architecture

All built on top of the spine (SreAgentService.CallDataPlaneAsync).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…G entries

- New tests/Azure.Mcp.Tools.SreAgent.UnitTests project (xunit.v3 + NSubstitute)
- AgentsListCommandTests covers constructor, validation, error handling, empty results, and resource group/tenant pass-through (6 passing tests)
- Added SreAgent folders/projects to Microsoft.Mcp.slnx (alphabetically between Speech and Sql)
- Added Azure SRE Agent section to servers/Azure.Mcp.Server/README.md with example prompts spanning all 11 tool groups
- Added Azure SRE Agent entry to the supported services list
- Added changelog-entries/bandarud-sreagent-tool.yml describing the new tool group

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@BandaruDheeraj BandaruDheeraj marked this pull request as ready for review May 8, 2026 22:11
@BandaruDheeraj BandaruDheeraj requested review from a team as code owners May 8, 2026 22:11
@BandaruDheeraj
Copy link
Copy Markdown
Author

@g2vinay this is now ready for review.

Summary:

  • New tool group: Azure.Mcp.Tools.SreAgent (issue [ONBOARD] Azure SRE Agent Tools #2541)
  • ~48 commands across 11 sub-groups: agents, skills, connectors, hooks, threads, scheduledtasks, incidents, workflows, docs, architecture, memories
  • ARM enumeration of Microsoft.App/SREAgentPreview via Resource Graph + data-plane HTTP via CallDataPlaneAsync (token audience https://azuresre.dev/.default)
  • New UnitTests project (xunit.v3 + NSubstitute) — all green
  • Added to Microsoft.Mcp.slnx, servers/Azure.Mcp.Server/README.md, and changelog-entries/
  • Full Azure.Mcp.Server build green

Implementation was fanned out across four sub-agent branches (A: agents+skills, B: connectors+hooks, C: threads+scheduledtasks, D: incidents+workflows+docs+architecture) and integrated via #region (sub-agent X) block markers. Happy to address any feedback or split into smaller PRs if preferred.

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

This PR introduces a new Azure MCP tool package, Azure.Mcp.Tools.SreAgent, wiring it into the Azure MCP Server and adding initial command surface area (agents/sub-agents, tools/skills, connectors, hooks, threads, scheduled tasks, incidents, workflows, docs, and architecture planning).

Changes:

  • Added the Azure.Mcp.Tools.SreAgent tool project with commands, options, models, JSON source-gen context, and an ISreAgentService + implementation for ARM discovery and SRE Agent data-plane calls.
  • Registered the new sreagent area in Azure.Mcp.Server and updated solution (.slnx) entries accordingly.
  • Added server README examples and a changelog entry, plus a starter unit test project and tests for agents list.

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 126 out of 126 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
tools/Azure.Mcp.Tools.SreAgent/src/Azure.Mcp.Tools.SreAgent.csproj New tool project (AOT-compatible) and dependencies.
tools/Azure.Mcp.Tools.SreAgent/src/AssemblyInfo.cs InternalsVisibleTo for unit/live tests.
tools/Azure.Mcp.Tools.SreAgent/src/GlobalUsings.cs Adds global usings for the tool project.
tools/Azure.Mcp.Tools.SreAgent/src/SreAgentSetup.cs Registers DI services and builds the sreagent command tree.
tools/Azure.Mcp.Tools.SreAgent/src/Services/ISreAgentService.cs Defines the service contract for ARM + data-plane operations.
tools/Azure.Mcp.Tools.SreAgent/src/Services/SreAgentService.cs Implements ARM discovery + data-plane REST calls.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/BaseSreAgentCommand.cs Base subscription-scoped command wiring (adds RG option binding).
tools/Azure.Mcp.Tools.SreAgent/src/Commands/SreAgentDataPlaneCommand.cs Base for data-plane commands (binds --agent and resolves endpoint).
tools/Azure.Mcp.Tools.SreAgent/src/Commands/SreAgentCommandHelpers.cs Shared helpers for endpoint resolution and JSON parsing.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/SreAgentPortedCommandHelpers.cs Helper utilities for text results and JSON array extraction.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/SreAgentJsonContext.cs System.Text.Json source-generation context for tool models/results.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Agents/AgentsListCommand.cs Lists SRE Agent ARM resources in a subscription/RG.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Agents/AgentsGetCommand.cs Gets a sub-agent definition from an SRE Agent resource.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Agents/AgentsCreateCommand.cs Creates/updates a sub-agent on a targeted agent resource.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Agents/AgentsDeleteCommand.cs Deletes a sub-agent (requires confirm).
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Agents/AgentsToolsGetCommand.cs Gets a custom tool definition from a targeted agent resource.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Agents/AgentsToolsCreateCommand.cs Creates/updates a custom tool definition on an agent resource.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Skills/AgentToolsListCommand.cs Lists custom tools on a targeted agent resource.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Skills/SkillsListCommand.cs Lists custom skills on a targeted agent resource.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Skills/SkillsCreateCommand.cs Creates/updates a skill on a targeted agent resource.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Skills/SkillsDeleteCommand.cs Deletes a tool/skill (requires confirm).
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Connectors/ConnectorsListCommand.cs Lists connectors on a targeted agent resource.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Connectors/ConnectorsGetCommand.cs Gets a connector’s details.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Connectors/ConnectorsCreateKustoCommand.cs Creates/updates a Kusto connector.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Connectors/ConnectorsCreateMcpCommand.cs Creates/updates an MCP connector (stdio/http).
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Connectors/ConnectorsDeleteCommand.cs Deletes a connector.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Connectors/ConnectorsTestCommand.cs Tests a connector and returns exposed tools.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Hooks/HooksListCommand.cs Lists hooks on a targeted agent resource.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Hooks/HooksGetCommand.cs Gets hook details.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Hooks/HooksDeleteCommand.cs Deletes a hook.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Hooks/HooksThreadListCommand.cs Lists hook activation state for a thread.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Hooks/HooksThreadActivateCommand.cs Activates a thread hook.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Hooks/HooksThreadDeactivateCommand.cs Deactivates a thread hook.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Threads/ThreadsCommandBase.cs Shared thread polling/follow-up classification helpers.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Threads/ThreadsListCommand.cs Lists SRE Agent threads.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Threads/ThreadsGetCommand.cs Gets thread messages.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Threads/ThreadsCreateCommand.cs Creates a thread and waits for initial completion.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Threads/ThreadsSendMessageCommand.cs Sends a message and polls for completion.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Threads/ThreadsDeleteCommand.cs Deletes a thread (requires confirm).
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Threads/ThreadsInvestigateCommand.cs Starts an investigation loop with follow-up handling.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Threads/ThreadsInvestigateYoloCommand.cs YOLO variant that auto-approves pending approvals.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/ScheduledTasks/ScheduledTasksListCommand.cs Lists scheduled tasks.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/ScheduledTasks/ScheduledTasksGetCommand.cs Gets a scheduled task.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/ScheduledTasks/ScheduledTasksCreateCommand.cs Creates a scheduled task.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/ScheduledTasks/ScheduledTasksDeleteCommand.cs Deletes a scheduled task (requires confirm).
tools/Azure.Mcp.Tools.SreAgent/src/Commands/ScheduledTasks/ScheduledTasksPauseCommand.cs Pauses a scheduled task.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/ScheduledTasks/ScheduledTasksResumeCommand.cs Resumes a scheduled task.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Incidents/IncidentsPlansListCommand.cs Lists incident response plans (filters/handlers).
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Incidents/IncidentsPlansCreateCommand.cs Creates and enables an incident response plan.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Incidents/IncidentsActiveListCommand.cs Lists “incident-like” active threads.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Incidents/IncidentsCreateCommand.cs Creates an incident investigation thread.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Incidents/IncidentsSetupPagerdutyCommand.cs Creates PagerDuty connector from env var credentials.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Incidents/IncidentsSetupServicenowCommand.cs Creates ServiceNow connector from env var credentials.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Workflows/WorkflowsGenerateCommand.cs Generates agent/tool YAML scaffolding.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Workflows/WorkflowsValidateCommand.cs Validates YAML content for common issues.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Workflows/WorkflowsApplyCommand.cs Applies YAML to the data-plane API via minimal parsing.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Docs/DocsGetCommand.cs Returns SRE Agent reference docs by topic.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Docs/MemoriesListCommand.cs Lists knowledge base documents.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Docs/MemoriesSearchCommand.cs Searches knowledge base documents.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Docs/MemoriesAddCommand.cs Uploads markdown to knowledge base.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Docs/MemoriesDeleteCommand.cs Deletes a knowledge base document (requires confirm).
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Docs/MemoriesReindexCommand.cs Triggers knowledge base reindex.
tools/Azure.Mcp.Tools.SreAgent/src/Commands/Architecture/PlanCommand.cs Produces an architecture plan based on requirements.
tools/Azure.Mcp.Tools.SreAgent/src/Options/BaseSreAgentOptions.cs Base options including agent + subscription options.
tools/Azure.Mcp.Tools.SreAgent/src/Options/SreAgentOptionDefinitions.cs Option definitions for the command line surface.
tools/Azure.Mcp.Tools.SreAgent/src/Options/SreAgentPortedOptionDefinitions.cs Additional option definitions for “ported” command surface.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Agents/AgentsListOptions.cs Options for agents list.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Agents/AgentsGetOptions.cs Options for agents get.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Agents/AgentsCreateOptions.cs Options for agents create.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Agents/AgentsDeleteOptions.cs Options for agents delete.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Agents/AgentsToolsGetOptions.cs Options for tools get.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Agents/AgentsToolsCreateOptions.cs Options for tools create.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Skills/AgentToolsListOptions.cs Options for tools list.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Skills/SkillsListOptions.cs Options for skills list.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Skills/SkillsCreateOptions.cs Options for skills create.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Skills/SkillsDeleteOptions.cs Options for skills delete.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Connectors/ConnectorsListOptions.cs Options for connectors list.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Connectors/ConnectorsGetOptions.cs Options for connectors get.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Connectors/ConnectorsDeleteOptions.cs Options for connectors delete.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Connectors/ConnectorsTestOptions.cs Options for connectors test.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Connectors/ConnectorsCreateKustoOptions.cs Options for connectors create-kusto.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Connectors/ConnectorsCreateMcpOptions.cs Options for connectors create-mcp.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Hooks/HooksListOptions.cs Options for hooks list.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Hooks/HooksGetOptions.cs Options for hooks get.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Hooks/HooksDeleteOptions.cs Options for hooks delete.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Hooks/HooksThreadListOptions.cs Options for thread hook list.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Hooks/HooksThreadActivateOptions.cs Options for thread hook activate.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Hooks/HooksThreadDeactivateOptions.cs Options for thread hook deactivate.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Threads/ThreadsOptions.cs Options for thread operations and investigations.
tools/Azure.Mcp.Tools.SreAgent/src/Options/ScheduledTasks/ScheduledTasksOptions.cs Options for scheduled task operations.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Incidents/IncidentOptions.cs Options for incident operations and connector setup.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Docs/DocsOptions.cs Options for docs and knowledge base operations.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Workflows/WorkflowOptions.cs Options for workflows generate/validate/apply.
tools/Azure.Mcp.Tools.SreAgent/src/Options/Architecture/PlanOptions.cs Options for architecture planning.
tools/Azure.Mcp.Tools.SreAgent/src/Models/SreAgentResource.cs Lightweight ARM projection model for SRE Agent resources.
tools/Azure.Mcp.Tools.SreAgent/src/Models/SreAgentDeleteResult.cs Delete result model.
tools/Azure.Mcp.Tools.SreAgent/src/Models/SreSubAgent.cs Sub-agent model.
tools/Azure.Mcp.Tools.SreAgent/src/Models/SreSubAgentProperties.cs Sub-agent properties model (extension data supported).
tools/Azure.Mcp.Tools.SreAgent/src/Models/SreSubAgentCreateRequest.cs Sub-agent create request model.
tools/Azure.Mcp.Tools.SreAgent/src/Models/SreAgentTool.cs Custom tool model.
tools/Azure.Mcp.Tools.SreAgent/src/Models/SreAgentToolProperties.cs Custom tool properties model.
tools/Azure.Mcp.Tools.SreAgent/src/Models/SreAgentToolParameter.cs Tool parameter model.
tools/Azure.Mcp.Tools.SreAgent/src/Models/SreAgentToolCreateRequest.cs Tool create request model.
tools/Azure.Mcp.Tools.SreAgent/src/Models/SreSkill.cs Skill model.
tools/Azure.Mcp.Tools.SreAgent/src/Models/SreSkillProperties.cs Skill properties model (extension data supported).
tools/Azure.Mcp.Tools.SreAgent/src/Models/SreSkillCreateRequest.cs Skill create request model.
tools/Azure.Mcp.Tools.SreAgent/src/Models/AgentConnector.cs Connector model (incl. extended properties).
tools/Azure.Mcp.Tools.SreAgent/src/Models/AgentConnectorEnvelope.cs Connector envelope model.
tools/Azure.Mcp.Tools.SreAgent/src/Models/ConnectorTestResult.cs Connector test result model.
tools/Azure.Mcp.Tools.SreAgent/src/Models/ConnectorToolInfo.cs Connector tool info model.
tools/Azure.Mcp.Tools.SreAgent/src/Models/HookEnvelope.cs Hook envelope model.
tools/Azure.Mcp.Tools.SreAgent/src/Models/HookSpec.cs Hook spec/properties model.
tools/Azure.Mcp.Tools.SreAgent/src/Models/HookDefinition.cs Hook definition model.
tools/Azure.Mcp.Tools.SreAgent/src/Models/ThreadHookInfo.cs Thread hook info model.
tools/Azure.Mcp.Tools.SreAgent/src/Models/ThreadHooksResponse.cs Thread hooks response model.
tools/Azure.Mcp.Tools.SreAgent/src/Models/SreAgentThreadModels.cs Thread/message/approval/user-question models.
tools/Azure.Mcp.Tools.SreAgent/src/Models/SreAgentScheduledTaskModels.cs Scheduled task models.
tools/Azure.Mcp.Tools.SreAgent/src/Models/SreAgentPortedModels.cs Additional models for incident/docs/memory surfaces.
tools/Azure.Mcp.Tools.SreAgent/tests/Azure.Mcp.Tools.SreAgent.UnitTests/Azure.Mcp.Tools.SreAgent.UnitTests.csproj New unit test project for SreAgent commands.
tools/Azure.Mcp.Tools.SreAgent/tests/Azure.Mcp.Tools.SreAgent.UnitTests/AssemblyAttributes.cs Test assembly-wide attributes.
tools/Azure.Mcp.Tools.SreAgent/tests/Azure.Mcp.Tools.SreAgent.UnitTests/Agents/AgentsListCommandTests.cs Unit tests for agents list command behavior.
servers/Azure.Mcp.Server/src/Program.cs Registers SreAgentSetup in server area registration.
servers/Azure.Mcp.Server/README.md Adds SRE Agent example prompts and service list entry.
servers/Azure.Mcp.Server/changelog-entries/bandarud-sreagent-tool.yml Adds changelog entry for the new SRE Agent tool group.
servers/Azure.Mcp.Server/Azure.Mcp.Server.slnx Adds SreAgent project folder and project reference.
Microsoft.Mcp.slnx Adds SreAgent project + unit test project to root solution.


namespace Azure.Mcp.Tools.SreAgent.Options.Threads;

public class ThreadsListOptions : BaseSreAgentOptions;
public int TimeoutSeconds { get; set; } = 600;
}

public class ThreadsInvestigateYoloOptions : ThreadsInvestigateOptions;

namespace Azure.Mcp.Tools.SreAgent.Options.ScheduledTasks;

public class ScheduledTasksListOptions : BaseSreAgentOptions;

namespace Azure.Mcp.Tools.SreAgent.Options.Connectors;

public class ConnectorsListOptions : BaseSreAgentOptions;

namespace Azure.Mcp.Tools.SreAgent.Options.Hooks;

public class HooksListOptions : BaseSreAgentOptions;
Comment on lines +42 to +57
private static (string? Kind, string? Name, string? Owner, JsonArray Tags, JsonObject Spec) ParseMinimalYaml(string yaml)
{
string? kind = null; string? name = null; string? owner = null; var tags = new JsonArray(); var spec = new JsonObject(); string? section = null; string? currentKey = null; var block = new List<string>();
foreach (var rawLine in yaml.Replace("\r\n", "\n").Split('\n'))
{
var line = rawLine.TrimEnd(); var trimmed = line.Trim(); if (trimmed.Length == 0 || trimmed.StartsWith('#')) continue;
if (!char.IsWhiteSpace(line[0])) { FlushBlock(spec, ref currentKey, block); section = trimmed.TrimEnd(':'); if (trimmed.StartsWith("kind:", StringComparison.OrdinalIgnoreCase)) kind = Clean(trimmed[5..]); continue; }
if (section == "metadata")
{
if (trimmed.StartsWith("name:", StringComparison.OrdinalIgnoreCase)) name = Clean(trimmed[5..]); else if (trimmed.StartsWith("owner:", StringComparison.OrdinalIgnoreCase)) owner = Clean(trimmed[6..]); else if (trimmed.StartsWith("-")) tags.Add((JsonNode?)JsonValue.Create(Clean(trimmed[1..])));
}
else if (section == "spec")
{
if (trimmed.StartsWith("-")) { if (currentKey is not null) block.Add(Clean(trimmed[1..])); continue; }
var colon = trimmed.IndexOf(':'); if (colon > 0) { FlushBlock(spec, ref currentKey, block); var key = trimmed[..colon].Trim(); var value = trimmed[(colon + 1)..].Trim(); if (value is "|" or "|-" or ">" or ">-") currentKey = key; else spec[key] = Clean(value); } else if (currentKey is not null) block.Add(trimmed);
}
@@ -0,0 +1,4 @@
pr: 2611
changes:
- section: "New Features"
Comment on lines +1 to +4
pr: 2611
changes:
- section: "New Features"
description: "Added Azure SRE Agent (`Microsoft.App/SREAgentPreview`) tool group with ~48 commands across 11 sub-groups: agents, skills, connectors, hooks, threads, scheduledtasks, incidents, workflows, docs, architecture, and memories. Supports listing/creating/updating SRE Agent resources, managing sub-agents and tools, registering data connectors (Kusto/MCP), configuring safety hooks, running investigations, scheduling tasks, declaring incidents, generating workflows, querying memories, and producing remediation plans against the SRE Agent data plane."
Comment on lines +115 to +119
tools.AddCommand<AgentToolsListCommand>(serviceProvider);
tools.AddCommand<AgentsToolsGetCommand>(serviceProvider);
tools.AddCommand<AgentsToolsCreateCommand>(serviceProvider);
tools.AddCommand<SkillsDeleteCommand>(serviceProvider);

Comment on lines +152 to +162
// Incidents + Workflows + Docs + Architecture (sub-agent D)
var incidents = new CommandGroup("incidents", "Incident response planning, connector setup, and active incident operations.");
var workflows = new CommandGroup("workflows", "Generate, validate, and apply SRE Agent workflow YAML.");
var docs = new CommandGroup("docs", "SRE Agent documentation and knowledge memory operations.");
var architecture = new CommandGroup("architecture", "SRE Agent architecture planning commands.");
sreAgent.AddSubGroup(incidents);
sreAgent.AddSubGroup(workflows);
sreAgent.AddSubGroup(docs);
sreAgent.AddSubGroup(architecture);

return sreAgent;
Copy link
Copy Markdown
Contributor

@jongio jongio left a comment

Choose a reason for hiding this comment

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

A few items beyond the existing feedback:

HttpClient lifecycle - SreAgentService creates HTTP clients via TenantService.GetClient() (lines 101 and 714) instead of injecting IHttpClientFactory. The repo convention is to use IHttpClientFactory.CreateClient() for proper socket lifecycle management and recorded test support. This will block the recorded-test migration path.

Test coverage - Only AgentsListCommandTests exists. With ~48 commands across 11 subgroups, most commands have zero test coverage. Even basic Constructor_InitializesCommandCorrectly and BindOptions_BindsOptionsCorrectly tests per command would catch registration and option-binding bugs early.

Duplicate endpoint resolution - Both SreAgentDataPlaneCommand.ResolveEndpointAsync and SreAgentCommandHelpers.ResolveAgentEndpointAsync resolve an agent name to its data-plane endpoint URL. Pick one location and remove the other.

Formatting density - Several ported commands (e.g. IncidentsActiveListCommand, WorkflowsApplyCommand) cram entire method bodies onto single lines or collapse multi-statement blocks. This makes them very hard to review and maintain. Breaking these into standard multi-line formatting would help reviewers and future contributors.

{
request.Content = new StringContent(jsonBody, Encoding.UTF8, "application/json");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This creates an HttpClient directly instead of going through IHttpClientFactory. The repo convention (per recorded test docs) is to inject IHttpClientFactory into services and call CreateClient() so the test infrastructure can intercept and record/playback HTTP traffic. Same issue on line 714 with CallAgentDataPlaneAsync.

ISreAgentService sreAgentService,
TOptions options,
CancellationToken cancellationToken)
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ResolveEndpointAsync here duplicates SreAgentCommandHelpers.ResolveAgentEndpointAsync. Both call sreAgentService.GetAgentAsync and pull .Endpoint. Having two copies means a fix in one won't propagate. Consider removing one and calling the other.

Dheeraj Bandaru and others added 7 commits May 9, 2026 11:26
… agent-name)

Mirror of upstream Node MCP server fix in sreagent-runtime-extensibility-agents:

1. The SRE Agent skills data-plane endpoint expects the request body property to be 'skillContent', not 'content'. Sending 'content' causes the create call to fail. Renamed SreSkillProperties.Content -> SkillContent so the CamelCase JsonContext serializes it as 'skillContent' on the wire.

2. The create endpoint does not support the 'agentName' property. Dropped --agent-name option (and SkillAgentName / SkillAgentNameName definitions), the AgentName property on SreSkillProperties / SkillsCreateOptions, and all corresponding bindings in SkillsCreateCommand.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Server-side ExtendedAgentView exposes 'handoffDescription' as the sub-agent's description on the agent canvas. There is no plain 'description' field on sub-agents — sending one is silently dropped by the data plane.

Renamed SreSubAgentProperties.Description -> HandoffDescription so the CamelCase JsonContext serializes it as 'handoffDescription' on the wire. Updated AgentsCreateCommand to populate the renamed field. The --description CLI option is unchanged on the command surface.

Common Prompts tools (commonprompts list/get/create) are not yet ported to this PR; they should be added as a separate group when porting Sub-agent D.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ed pattern; add Common Prompts command group

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…entName from SreSkill

Parity with sreagent-runtime commit 6837855f. The Node SkillSummary type was simplified to read description from properties.* envelope only; the C# SreSkill mirror still carried unused top-level Description/AgentName that were never populated by the v2 envelope responses. No callers reference them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the schema-allowed 'Features Added' section value and add the standard IsTestProject/OutputType properties so the unit-test project is discovered and runnable.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The name-based GetValueOrDefault overload looks up by string and was paired with a nullable string[]? generic, while the option is declared as Option<string[]>. The lookup is type-based, so it was returning null and the --args values were silently dropped.

Switch to the option-typed overload to match the rest of the file and the underlying option type.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The hooks and scheduledtasks services were wired into DI but no command groups were registered, so all 12 commands were unreachable. Add 'azmcp sreagent hooks' (with a 'thread' sub-group for activation) and 'azmcp sreagent scheduledtasks' command groups and register their commands.

Also move SkillsDeleteCommand out of the agents/tools subgroup and into the skills subgroup where it belongs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Dheeraj Bandaru and others added 4 commits May 11, 2026 17:19
…ortal

Connector Create/List/Get/Delete now call Azure Resource Manager
(Microsoft.App/agents/{agent}/connectors, api-version 2025-05-01-preview)
instead of the per-resource data plane. The portal Connectors page reads
from the ARM store, so data-plane writes were invisible there.

- SreAgentService: add CallArmAsync helper and ResolveAgentResourceGroupAsync;
  rewrite 4 connector methods to ARM. PUT body uses { properties: {...} }
  (top-level name/type belong in the route). List parses the ARM { value: [] }
  envelope.
- ISreAgentService: connector ops now take (subscription, resourceGroup,
  agentName, ...) instead of (endpoint, ...).
- SreAgentCommandHelpers: add ResolveAgentResourceGroupAsync that falls back
  to a Resource Graph lookup when --resource-group is omitted.
- Update 5 connector commands and the 2 incidents setup commands to pass
  sub/RG/agent. TestConnectorAsync stays on the data plane because the
  testconnection action has no ARM equivalent.

Live-tested against post-ga-dbandaru-sample-demo: create-kusto, create-mcp
(http and stdio), list, get, delete all return provisioningState Succeeded
and match the shape of existing portal-visible connectors.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The MCP create command was sending DataSource=placeholder and
Identity=` (empty string), producing connectors that never connected.
ARM also rejects null DataSource (DataSource is required).

Use the endpoint URL for http MCP and the command for stdio MCP as the
DataSource value, and default Identity to system so the agent's MI is
attached the same way as portal-created connectors.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add 9 consolidated tool entries covering all 55 sreagent_* commands so
  ConsolidatedToolDiscoveryStrategy can map every registered command (fixes
  ConsolidatedModeTests.ConsolidatedMode_Should_List_Tools_Successfully which
  was failing in CI because azmcp server start --mode consolidated was
  throwing InvalidOperationException at unmatched commands before responding
  to the MCP initialize request).
- Re-sort SreAgent folder entries alphabetically in slnx files and add the
  SreAgent test project to Azure.Mcp.Server.slnx so Update-Solution.ps1
  -Verify passes.
- Apply dotnet format fixes: insert trailing newlines on test files and
  reorder using directives in SreAgentJsonContext.cs, SreAgentService.cs,
  and SreAgentSetup.cs.

Verified locally:
- Azure.Mcp.Server.UnitTests: 25/25 pass
- Azure.Mcp.Tools.SreAgent.UnitTests: 114/114 pass
- dotnet format --verify-no-changes: clean
- Test-ToolNameLength.ps1: 0 violations
- Test-ToolId.ps1: 0 violations
- Update-Solution.ps1 -Verify: clean
- Live tested against a real Microsoft.App/agents resource: all read-only
  commands return 200, and full memory lifecycle (add/search/delete) succeeds
  through the data-plane endpoint.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Addresses security review findings on PR #2611:

- High: redact bearer tokens, API keys, passwords, and Authorization
  headers from connector list/get/create responses (ToConnector +
  CreateOrUpdateConnectorAsync empty-body fallback)
- High: sanitize upstream error response bodies before including in
  HttpRequestException messages (ARM, data-plane, memory upload). Strips
  JSON-form secrets and raw 'Authorization: Bearer/Basic ...' headers
  before truncation
- Medium: enforce https scheme in UploadMemoryAsync
- Medium: extend ServiceNow allowlist to .servicenowservices.com

Adds 24 unit tests covering redaction key set (case-insensitive),
nested headers (Dictionary + JsonElement), and sanitization regex stack.
138/138 tests pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@BandaruDheeraj BandaruDheeraj changed the title [Draft] Add Azure.Mcp.Tools.SreAgent (scaffolding for issue #2541) Add Azure.Mcp.Tools.SreAgent (scaffolding for issue #2541) May 12, 2026
@BandaruDheeraj BandaruDheeraj requested a review from a team May 12, 2026 18:54
@BandaruDheeraj
Copy link
Copy Markdown
Author

Security review complete — ready for review

Ran a focused security review on this PR and addressed all High and Medium findings in commit a9875999.

Fixes applied

High severity

  1. Connector secret redactionToConnector (read path) and the CreateOrUpdateConnectorAsync fallback (write path) now redact a unified set of sensitive keys before returning the connector to the LLM/caller: bearerToken, apiKey, password, secret, clientSecret, accessToken, refreshToken, token, authorization. Case-insensitive match; also redacts nested headers.Authorization.
  2. Upstream error body sanitizationSanitizeForErrorMessage strips JSON-form secrets ("<key>":"<value>") and raw Authorization: Bearer/Basic/Token/ApiKey ... headers from upstream response bodies before they're surfaced in thrown exceptions / tool errors.

Medium severity
3. HTTPS enforcement on memory uploadUploadMemoryAsync now rejects non-https:// server URLs.
4. ServiceNow instance allowlist — extended ValidateServiceNowInstanceUrl to accept both .service-now.com and .servicenowservices.com (the latter is used by some managed/government tenants).

Validation

  • 138/138 unit tests passing (incl. new regression tests for the redaction + sanitization paths).
  • Live-validated against post-ga-dbandaru-sample-demo: verified agent_tools_create, agent_skills_create, and agents_create all work end-to-end against the agent runtime with the fixes in place; verified secret fields stay redacted in agent_connectors_get responses.

Node MCP parity

For completeness, the same four fixes have been mirrored into the Node MCP server (separate repo, separate PR) so both implementations stay aligned.

Ready for review — please take a look.

Copy link
Copy Markdown
Contributor

@g2vinay g2vinay left a comment

Choose a reason for hiding this comment

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

Left my comments below.

@github-project-automation github-project-automation Bot moved this from Untriaged to In Progress in Azure MCP Server May 13, 2026
Copy link
Copy Markdown
Contributor

@jongio jongio left a comment

Choose a reason for hiding this comment

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

Addresses my previous feedback cleanly. The 19 new commits fix everything I flagged:

  • IHttpClientFactory injected properly (_httpClientFactory.CreateClient())
  • Endpoint resolver deduplicated to SreAgentCommandHelpers (DataPlaneCommand delegates)
  • Per-command Constructor/BindOptions tests added across all subgroups
  • Dense single-line command bodies reformatted
  • All previously missing subgroup registrations (hooks, scheduledtasks, incidents, workflows, docs, architecture) now wired up
  • Secret redaction added with solid test coverage
  • New CommonPrompts command group added

CI is green across all platforms including native AOT builds. No new issues spotted in the incremental diff.

@@ -0,0 +1,4 @@
pr: 2611
changes:
- section: "Features Added"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This PR is missing Live Tests

BLK-01 · No Live Tests — Azure Service Commands Require Them

Per new-command.md and AGENTS.md, all commands that interact with Azure resources MUST include live tests recorded for playback using RecordedCommandTestsBase. No LiveTests project exists in this PR.

The author's Round 4 note acknowledges this is deferred. Per repo policy, this is a mandatory requirement — not optional.

Required:

  1. Create tools/Azure.Mcp.Tools.SreAgent/tests/Azure.Mcp.Tools.SreAgent.LiveTests/Azure.Mcp.Tools.SreAgent.LiveTests.csproj
  2. Implement recorded live tests using RecordedCommandTestsBase for commands that make network calls
  3. Add recordings per /docs/recorded-tests.md
  4. Add the LiveTests project to Microsoft.Mcp.slnx and Azure.Mcp.Server.slnx

@@ -0,0 +1,4 @@
pr: 2611
changes:
- section: "Features Added"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BLK-02 · No Live Test Infrastructure (Bicep + Post-Deployment Script)

Per new-command.md, Azure service toolsets MUST include:

  • tools/Azure.Mcp.Tools.SreAgent/tests/test-resources.bicep
  • tools/Azure.Mcp.Tools.SreAgent/tests/test-resources-post.ps1

Neither exists. The Bicep template must provision a Microsoft.App/agents resource with appropriate RBAC role assignments for the test application.

@@ -0,0 +1,4 @@
pr: 2611
changes:
- section: "Features Added"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BLK-03 · No assets.json for Recorded Tests

Per AGENTS.md and docs/recorded-tests.md, an assets.json is required alongside the live test project:

{
  "AssetsRepo": "Azure/azure-sdk-assets",
  "AssetsRepoPrefixPath": "",
  "TagPrefix": "Azure.Mcp.Tools.SreAgent.LiveTests",
  "Tag": ""
}

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Azure.Mcp.Tools.SreAgent.Options.CommonPrompts;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BLK-04 · Multiple Options Classes per File

Per AGENTS.md: "Always put new classes and interfaces in separate files."

The following files each contain multiple classes — each class must be moved to its own file:

File Classes (must be split)
Options/CommonPrompts/CommonPromptOptions.cs CommonPromptsListOptions, CommonPromptsGetOptions, CommonPromptsCreateOptions, CommonPromptsDeleteOptions
Options/ScheduledTasks/ScheduledTasksOptions.cs ScheduledTasksListOptions, ScheduledTasksGetOptions, ScheduledTasksCreateOptions, ScheduledTasksDeleteOptions, ScheduledTasksPauseOptions, ScheduledTasksResumeOptions
Options/Incidents/IncidentOptions.cs IncidentPlanCreateOptions, IncidentRemoteOptions, IncidentConnectorPagerDutyOptions, IncidentConnectorServiceNowOptions, IncidentCreateOptions
Options/Threads/ThreadsOptions.cs ThreadsListOptions, ThreadsGetOptions, ThreadsCreateOptions, ThreadsSendMessageOptions, ThreadsDeleteOptions, ThreadsInvestigateOptions, ThreadsInvestigateYoloOptions
Options/Docs/DocsOptions.cs DocsGetOptions, MemoryRemoteOptions, MemoriesSearchOptions, MemoriesAddOptions, MemoriesDeleteOptions
Options/Workflows/WorkflowOptions.cs WorkflowsGenerateOptions, WorkflowsValidateOptions, WorkflowsApplyOptions

@@ -0,0 +1,4 @@
pr: 2611
changes:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BLK-05 · azmcp-commands.md and e2eTestPrompts.md Not Updated

Per AGENTS.md:

"Update /servers/Azure.Mcp.Server/docs/azmcp-commands.md with new command details"
"Add test prompts to /servers/Azure.Mcp.Server/docs/e2eTestPrompts.md (maintain alphabetical order)"

README.md was updated with example prompts, but the authoritative command reference and test prompts files were not updated for any of the 57 new commands. These are used by AI agents for tool discovery.

@@ -0,0 +1,4 @@
pr: 2611
changes:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BLK-08 · CODEOWNERS Not Updated

Per AGENTS.md: "Add CODEOWNERS entry for new toolset." No CODEOWNERS entry was added.

using Microsoft.Mcp.Core.Commands;
namespace Azure.Mcp.Tools.SreAgent;

public class SreAgentSetup : IAreaSetup
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HIGH-01 · SreAgentSetup Is Not Sealed

Per AGENTS.md: "Make command classes sealed unless designed for inheritance."

// Current
public class SreAgentSetup : IAreaSetup

// Required
public sealed class SreAgentSetup : IAreaSetup

{
if (!o.Confirm)
{
SreAgentPortedCommandHelpers.SetTextResult(context.Response, $"Error: Refusing to delete common prompt '{o.Name}': destructive operation requires 'confirm: true'. Ask the user to confirm, then retry with confirm=true.");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HIGH-02 · "Ported" Delete Commands Return HTTP 200 for User Errors

CommonPromptsDeleteCommand (and potentially other ported commands) returns a text error with SetTextResult when --confirm is missing — this produces HTTP 200 with error text in the body.

// Wrong — HTTP 200 with error text
SreAgentPortedCommandHelpers.SetTextResult(context.Response,
    $"Error: Refusing to delete common prompt '{o.Name}': ...");
return context.Response;

The correct pattern (already used by AgentsDeleteCommand and ConnectorsDeleteCommand) is:

// Correct — maps to HTTP 400
throw new InvalidOperationException($"Refusing to delete ...: destructive operation requires --confirm true.");

All "ported" commands that use SetTextResult to report user errors must be updated to throw instead.


namespace Azure.Mcp.Tools.SreAgent.Options;

public static class SreAgentOptionDefinitions
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HIGH-04 · Duplicate Option Definitions Across Two Static Classes

SreAgentOptionDefinitions.cs and SreAgentPortedOptionDefinitions.cs both define: Agent, Name, Description, Confirm, AuthType, Database, Query, UrlTemplate, Parameters, Connector, Handoffs, Tools. This causes confusion about which definition to use and creates divergence risk. Consolidate into a single SreAgentOptionDefinitions.cs with static nested classes per sub-group if needed.

ArgumentException.ThrowIfNullOrEmpty(path);

if (!Uri.TryCreate(endpoint, UriKind.Absolute, out var endpointUri) ||
(endpointUri.Scheme != Uri.UriSchemeHttps))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HIGH-06 · SSRF Risk — agentEndpoint from ARM Not Validated Against Known Domain

CallDataPlaneAsync validates HTTPS but does not validate the endpoint host. The endpoint is read directly from properties.agentEndpoint in the ARM response. A compromised subscription could set this to an attacker-controlled HTTPS domain, causing the server to forward bearer tokens there.

Fix — validate before acquiring token:

private static void ValidateDataPlaneEndpoint(Uri endpointUri)
{
    if (!endpointUri.Host.EndsWith(".azuresre.ai", StringComparison.OrdinalIgnoreCase))
    {
        throw new ArgumentException(
            $"SRE Agent endpoint host '{endpointUri.Host}' is not a recognized *.azuresre.ai domain.",
            nameof(endpointUri));
    }
}

Call this in CallDataPlaneAsync before GetTokenAsync.

await CallDataPlaneAsync(endpoint, $"/api/v1/scheduledtasks/{Uri.EscapeDataString(taskId)}", HttpMethod.Delete, tenant: tenant, cancellationToken: cancellationToken);
}

public async Task PauseScheduledTaskAsync(string endpoint, string taskId, string? tenant = null, CancellationToken cancellationToken = default)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HIGH-07 · PauseScheduledTaskAsync / ResumeScheduledTaskAsync Pass Null Body to POST

await CallDataPlaneAsync(endpoint, $"/api/v1/scheduledtasks/{taskId}/pause", HttpMethod.Post,
    tenant: tenant, cancellationToken: cancellationToken);  // ← jsonBody omitted (null)

ActivateThreadHookAsync passes "{}" for the same type of action-POST. If the SRE Agent API requires a non-null body for POST operations these calls will fail with 400 or 415. Pass "{}" as jsonBody for consistency.


ReadOnly = true,
Secret = false,
LocalRequired = false)]
public sealed class AgentToolsListCommand(ILogger<AgentToolsListCommand> logger, ISreAgentService sreAgentService)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HIGH-08 · AgentToolsListCommand in Wrong Folder / Inconsistent Naming

AgentToolsListCommand lives in Commands/Skills/ but is registered under the agents/tools command group. Per the {Resource}{SubResource}{Operation}Command naming pattern it should be AgentsToolsListCommand, placed in Commands/Agents/ alongside AgentsToolsGetCommand and AgentsToolsCreateCommand.

options.RetryPolicy,
cancellationToken);

var result = await _sreAgentService.DeleteAgentToolAsync(endpoint, options.Name!, options.Tenant, cancellationToken);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BLK-06 · SkillsDeleteCommand Calls DeleteAgentToolAsync — Functional Bug

SkillsDeleteCommand calls _sreAgentService.DeleteAgentToolAsync(endpoint, options.Name!, ...). This deletes a tool, not a skill. There is no DeleteSkillAsync method anywhere in ISreAgentService or SreAgentService.

The SRE Agent API has separate endpoints:

  • /api/v2/extendedAgent/tools/{name} DELETE — tools
  • /api/v2/extendedAgent/skills/{name} DELETE — skills

This looks like a functional bug: deleting a skill silently deletes a tool instead. DeleteSkillAsync must be added to ISreAgentService and SreAgentService, and SkillsDeleteCommand must call it.
Double check and implement.

using Microsoft.Mcp.Tests.Client;
using Xunit;

namespace Azure.Mcp.Tools.SreAgent.UnitTests.Agents;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BLK-07 · Unit Tests Are Shallow — Mandatory Patterns Missing for 53+ Commands

Per new-command.md, the required test patterns per command are:

  • ExecuteAsync_ValidatesInputCorrectly — Theory with valid and invalid arg combinations
  • ExecuteAsync_DeserializationValidation
  • ExecuteAsync_HandlesServiceErrors — mocked service exception → correct HTTP status
  • BindOptions_BindsOptionsCorrectly — verifies specific option values are correctly bound

Only AgentsListCommandTests implements this. All other 53 test files contain only:

void Constructor_InitializesCommandCorrectly() { Assert.NotNull(command.Name); }
void RegisterOptions_AddsExpectedOptions() { Assert.NotNull(command.Options); }

Assert.NotNull(command.Options) always passes regardless of whether the correct options are registered — the base class always provides a non-null collection. These stubs provide no meaningful coverage.


Addresses all blocking and high-severity findings from g2vinay's
2026-05-13 review, except live-test items (BLK-01/02/03) which are
deferred pending tenant access.

Blocking (non-live-test):
- BLK-04: Split multi-class Options files (CommonPrompts, ScheduledTasks,
  Incidents, Threads, Docs, Workflows) into one class per file.
- BLK-05: Update servers/Azure.Mcp.Server/docs/azmcp-commands.md and
  e2eTestPrompts.md with entries for the new SreAgent commands.
- BLK-06: Add DeleteSkillAsync to ISreAgentService/SreAgentService and
  switch SkillsDeleteCommand to use it (previously deleted a tool).
- BLK-07: Beef up unit tests to include
  ExecuteAsync_ValidatesInputCorrectly, _DeserializationValidation,
  _HandlesServiceErrors, and BindOptions_BindsOptionsCorrectly across
  ported commands. 449/449 tests pass.
- BLK-08: Add CODEOWNERS entry for tools/Azure.Mcp.Tools.SreAgent/.

High severity:
- HIGH-01: Mark SreAgentSetup as sealed.
- HIGH-02: Ported delete commands throw InvalidOperationException for
  user errors (maps to HTTP 422) instead of returning HTTP 200 with
  error text via SetTextResult.
- HIGH-04: Remove SreAgentPortedOptionDefinitions; consolidate into
  SreAgentOptionDefinitions to eliminate duplicate definitions.
- HIGH-06: Add ValidateDataPlaneEndpoint to enforce *.azuresre.ai host
  suffix on agentEndpoint before token acquisition (SSRF mitigation).
- HIGH-07: PauseScheduledTaskAsync / ResumeScheduledTaskAsync now POST
  "{}" body for consistency with other action-POST data-plane calls.
- HIGH-08: Move AgentsToolsListCommand from Commands/Skills/ to
  Commands/Agents/ to match its placement under the agents/tools group.

Deferred (require tenant access for live recordings):
- BLK-01/02/03: LiveTests project, test-resources.bicep, and
  test-resources-post.ps1.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@BandaruDheeraj BandaruDheeraj requested a review from a team as a code owner May 13, 2026 21:49
@BandaruDheeraj
Copy link
Copy Markdown
Author

@g2vinay — addressed all blocking and high-severity findings from your review in 9f6d2193 except the three live-test items (BLK-01/02/03), which are deferred until I get access to a tenant where I can record the live tests. Build is clean (0 errors, 0 warnings) and 449/449 unit tests pass.

Blocking (non-live-test)

ID Concern Fix
BLK-04 Multiple Options classes per file Split CommonPromptOptions.cs, ScheduledTasksOptions.cs, IncidentOptions.cs, ThreadsOptions.cs, DocsOptions.cs, WorkflowOptions.cs into one class per file (~30 new files under src/Options/<group>/).
BLK-05 azmcp-commands.md / e2eTestPrompts.md not updated Added entries for all new SreAgent commands to servers/Azure.Mcp.Server/docs/azmcp-commands.md (+229 lines) and e2eTestPrompts.md (+38 lines), preserving alphabetical order.
BLK-06 SkillsDeleteCommand calls DeleteAgentToolAsync — deletes a tool, not a skill Added DeleteSkillAsync to ISreAgentService and SreAgentService (DELETE /api/v2/extendedAgent/skills/{name}). SkillsDeleteCommand now calls it.
BLK-07 Unit tests are shallow stubs Beefed up tests across the ported commands: ExecuteAsync_ValidatesInputCorrectly (Theory with valid/invalid args), ExecuteAsync_DeserializationValidation, ExecuteAsync_HandlesServiceErrors (mocked service exception → expected status), BindOptions_BindsOptionsCorrectly (verifies the typed option binding via SreAgentOptionDefinitions.X.Name). 449 tests passing.
BLK-08 CODEOWNERS not updated Added tools/Azure.Mcp.Tools.SreAgent/ entry under # PRLabel: %tools-SreAgent.

High severity

ID Concern Fix
HIGH-01 SreAgentSetup not sealed Changed to public sealed class SreAgentSetup : IAreaSetup.
HIGH-02 Ported delete commands return HTTP 200 with error text via SetTextResult Switched the user-error paths to throw new InvalidOperationException("Refusing to delete ...: destructive operation requires --confirm true.") — matches the existing AgentsDeleteCommand/ConnectorsDeleteCommand pattern and now correctly maps to HTTP 4xx via HandleException. Success-path SetTextResult calls retained.
HIGH-04 Duplicate option definitions across SreAgentOptionDefinitions.cs and SreAgentPortedOptionDefinitions.cs Deleted SreAgentPortedOptionDefinitions.cs; consolidated all definitions into SreAgentOptionDefinitions.cs. All call sites now bind via the typed OptionDefinitions.Foo.Name pattern.
HIGH-06 SSRF — agentEndpoint from ARM not validated against *.azuresre.ai Added ValidateDataPlaneEndpoint(Uri) in SreAgentService.cs; rejects any endpoint whose host does not end with .azuresre.ai (case-insensitive). Called before GetTokenAsync in CallDataPlaneAsync and again in UploadMemoryAsync.
HIGH-07 PauseScheduledTaskAsync / ResumeScheduledTaskAsync pass null body to POST Both now pass "{}" as jsonBody for consistency with ActivateThreadHookAsync and other action-POST data-plane calls.
HIGH-08 AgentToolsListCommand in Commands/Skills/ with inconsistent name Renamed to AgentsToolsListCommand and moved to Commands/Agents/ alongside AgentsToolsGetCommand / AgentsToolsCreateCommand. Old file deleted; test file moved to match.

Deferred

  • BLK-01, BLK-02, BLK-03 (LiveTests project, test-resources.bicep, test-resources-post.ps1, assets.json) — staying out of this commit until I have access to a tenant where I can deploy a Microsoft.App/agents resource and record live tests. Will address in a follow-up PR or commit on this branch once I get access.

Ready for re-review. 🙏

Dheeraj Bandaru and others added 3 commits May 13, 2026 19:07
Adds the offline-authorable parts of the live-test bundle so the
solution files don't reference a missing project:
- Azure.Mcp.Tools.SreAgent.LiveTests.csproj (matches Acr LiveTests
  pattern: IsTestProject, OutputType=Exe, refs Azure.Mcp.Server +
  Azure.Mcp.Tests, NSubstitute + xunit.v3).
- assets.json with TagPrefix Azure.Mcp.Tools.SreAgent.LiveTests
  (empty Tag — will be populated on first recording).
- SreAgentCommandTests.cs skeleton with seven safe list/get cases
  (agents_list, agents_get, threads_list, connectors_list,
  scheduledtasks_list, incidents_active_list, commonprompts_list)
  using RecordedCommandTestsBase. More cases will be added once a
  live Microsoft.App/agents resource is provisioned.

Still deferred (BLK-02 + recordings):
- tests/test-resources.bicep
- tests/test-resources-post.ps1
- assets.json Tag (populated by first record run)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds tests/test-resources.bicep provisioning a Microsoft.App/agents resource with a SystemAssigned identity, plus a Reader role assignment for the test SP. Adds test-resources-post.ps1 that calls New-TestSettings so the standard New-TestResources.ps1 flow can deploy the agent for recording live tests. Recipe-driven configuration (connectors etc.) will be layered on after the first deployment against a real subscription; this gives us a checked-in starting point.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ata-plane RBAC (BLK-02)

Replaces the minimal scaffold with a full live-test environment:

- LAW workspace + App Insights (connector data sources + agent telemetry sink)

- Microsoft.App/agents@2025-05-01-preview with SystemAssigned identity, knowledgeGraph/action/log configuration, V2 loop enabled

- Three built-in connectors (AppInsights, LogAnalytics, AzureMonitor) using the typed shape from microsoft/sre-agent sreagent-templates/bicep/agent-extensions.bicep so connectors_list returns non-empty results

- safety-rules commonPrompt (base64 envelope) so commonprompts_list returns non-empty results

- Reader + SRE Agent Administrator role assignments on the agent for the test SP (control-plane + data-plane access to *.azuresre.ai)

- Outputs for agent name, RG, and agentEndpoint

scheduledTasks / incidentFilters / hooks are intentionally not declared here — agent-extensions.bicep documents they hit a flaky code path through Bicep; the corresponding list tests assert only NotNull so empty arrays are fine. They can be layered on via apply-extras after the first deploy if needed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

[ONBOARD] Azure SRE Agent Tools

4 participants