Migrate Extension tools to new tool design#3085
Open
alzimmermsft wants to merge 2 commits into
Open
Conversation
alzimmermsft
requested review from
RickWinter,
chidozieononiwu,
conniey,
joshfree,
msalaman and
saikoumudi
July 17, 2026 18:14
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the Azure.Mcp.Tools.Extension toolset from legacy RegisterOptions/BindOptions + OptionDefinitions patterns to the newer attribute-driven options binding model (via [Option] attributes), aligning these tools with the current command infrastructure in the repo.
Changes:
- Replaced legacy option registration/binding with attribute-based option POCOs and updated commands to
AuthenticatedCommand<TOptions, TResult>/SubscriptionCommand<TOptions, TResult>. - Simplified request/response models to records and updated JSON source-gen context usage accordingly.
- Updated unit tests and DI setup to reflect the new command base classes and dependencies (e.g., subscription resolver).
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.Extension/tests/Azure.Mcp.Tools.Extension.Tests/ExtensionSetupTests.cs | Registers ISubscriptionResolver for updated command DI requirements. |
| tools/Azure.Mcp.Tools.Extension/tests/Azure.Mcp.Tools.Extension.Tests/CliGenerateCommandTests.cs | Removes unused System.Net.Http import after command refactor. |
| tools/Azure.Mcp.Tools.Extension/tests/Azure.Mcp.Tools.Extension.Tests/AzqrCommandTests.cs | Updates test base class and reflects static cache field rename. |
| tools/Azure.Mcp.Tools.Extension/src/Services/ICliInstallService.cs | Minor interface cleanup (removes redundant public). |
| tools/Azure.Mcp.Tools.Extension/src/Services/ICliGenerateService.cs | Minor interface cleanup and formatting. |
| tools/Azure.Mcp.Tools.Extension/src/Services/CliGenerateService.cs | Switches to JsonContent.Create and record-based request creation. |
| tools/Azure.Mcp.Tools.Extension/src/Options/ExtensionOptionDefinitions.cs | Removes legacy OptionDefinitions-based option declarations. |
| tools/Azure.Mcp.Tools.Extension/src/Options/CliInstallOptions.cs | Converts to attribute-based options with required properties. |
| tools/Azure.Mcp.Tools.Extension/src/Options/CliGenerateOptions.cs | Converts to attribute-based options with required properties. |
| tools/Azure.Mcp.Tools.Extension/src/Options/AzqrOptions.cs | Converts to attribute-based subscription options via ISubscriptionOption. |
| tools/Azure.Mcp.Tools.Extension/src/Models/CliInstallResult.cs | Simplifies result model to a positional record (camelCase via source-gen options). |
| tools/Azure.Mcp.Tools.Extension/src/Models/CliGenerateResult.cs | Simplifies result model to a positional record (camelCase via source-gen options). |
| tools/Azure.Mcp.Tools.Extension/src/Models/CliGenerateRequest.cs | Converts request/history models to records while preserving required JSON naming. |
| tools/Azure.Mcp.Tools.Extension/src/GlobalUsings.cs | Removes global usings that were primarily supporting the legacy design. |
| tools/Azure.Mcp.Tools.Extension/src/Commands/ExtensionJsonContext.cs | Converts JSON context to file-scoped partial type and adds required System.Text.Json using. |
| tools/Azure.Mcp.Tools.Extension/src/Commands/CliInstallCommand.cs | Migrates command to AuthenticatedCommand<TOptions, TResult> and attribute-bound options. |
| tools/Azure.Mcp.Tools.Extension/src/Commands/CliGenerateCommand.cs | Migrates command to AuthenticatedCommand<TOptions, TResult> and attribute-bound options. |
| tools/Azure.Mcp.Tools.Extension/src/Commands/AzqrReportResult.cs | Simplifies report result model to a positional record. |
| tools/Azure.Mcp.Tools.Extension/src/Commands/AzqrCommand.cs | Migrates to SubscriptionCommand<TOptions, TResult> and renames static cached path field. |
| tools/Azure.Mcp.Tools.Extension/src/Azure.Mcp.Tools.Extension.csproj | Updates core ProjectReference pathing and removes direct System.CommandLine dependency. |
| servers/Azure.Mcp.Server/changelog-entries/1784312053074.yaml | Adds a breaking-change changelog entry for removed/changed parameters. |
Comments suppressed due to low confidence (1)
tools/Azure.Mcp.Tools.Extension/src/Commands/CliGenerateCommand.cs:58
cliTypeis declared as nullable (options.CliType?.ToLowerInvariant()), butCliGenerateResultexpects a non-nullstringforCliType. With warnings treated as errors, this will fail the build due to nullable flow analysis (and the null-conditional is unnecessary sinceCliTypeis a required option).
var cliType = options.CliType?.ToLowerInvariant();
// Only log the cli type when we know for sure it doesn't have private data.
context.Activity?.AddTag("cliType", cliType);
if (cliType == Constants.AzureCliType)
{
using HttpResponseMessage responseMessage = await _cliGenerateService.GenerateAzureCLICommandAsync(
options.Intent,
cancellationToken);
responseMessage.EnsureSuccessStatusCode();
var responseBody = await responseMessage.Content.ReadAsStringAsync(cancellationToken);
context.Response.Results = ResponseResult.Create(new(responseBody, cliType), ExtensionJsonContext.Default.CliGenerateResult);
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?
Migrates Extension tools to new design where Register and Bind options are based on
Optionattributes.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