Skip to content

Migrate Extension tools to new tool design#3085

Open
alzimmermsft wants to merge 2 commits into
microsoft:mainfrom
alzimmermsft:MigrateExtensionToolsToNewDesign
Open

Migrate Extension tools to new tool design#3085
alzimmermsft wants to merge 2 commits into
microsoft:mainfrom
alzimmermsft:MigrateExtensionToolsToNewDesign

Conversation

@alzimmermsft

Copy link
Copy Markdown
Contributor

What does this PR do?

Migrates Extension tools to new design where Register and Bind options are based on Option attributes.

GitHub issue number?

[Link to the GitHub issue this PR addresses]

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

@alzimmermsft alzimmermsft self-assigned this Jul 17, 2026
Copilot AI review requested due to automatic review settings July 17, 2026 18:14
@alzimmermsft
alzimmermsft requested review from a team and jongio as code owners July 17, 2026 18:14
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions github-actions Bot added the tools-Azd Azure Developer CLI related label Jul 17, 2026

Copilot AI left a comment

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.

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

  • cliType is declared as nullable (options.CliType?.ToLowerInvariant()), but CliGenerateResult expects a non-null string for CliType. With warnings treated as errors, this will fail the build due to nullable flow analysis (and the null-conditional is unnecessary since CliType is 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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools-Azd Azure Developer CLI related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants