Migrate Policy tools to new tool design#3068
Open
alzimmermsft wants to merge 1 commit into
Open
Conversation
alzimmermsft
requested review from
JasonYeMSFT,
anannya03,
conniey,
hallipr,
sandeep-sen and
xirzec
July 16, 2026 16:47
|
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 Azure Policy tool(s) to the newer command/options design that relies on [Option] attributes (OptionBinder) instead of per-command RegisterOptions/BindOptions logic, and removes the Policy toolset’s direct dependency on System.CommandLine artifacts.
Changes:
- Updated
PolicyAssignmentListCommandto the newSubscriptionCommand<TOptions, TResult>pattern and moved option declarations intoPolicyAssignmentListOptionsvia[Option]attributes. - Removed legacy Policy option definition scaffolding (
PolicyOptionDefinitions) and the toolset’sSystem.CommandLinepackage reference/global usings. - Adjusted unit tests to use
SubscriptionCommandUnitTestsBase.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.Policy/tests/Azure.Mcp.Tools.Policy.Tests/Assignment/PolicyAssignmentListCommandTests.cs | Switches to subscription-aware test base to support the new command constructor/options binding flow. |
| tools/Azure.Mcp.Tools.Policy/src/Services/PolicyService.cs | Adds explicit System.Text.Json import after removing Policy toolset global usings. |
| tools/Azure.Mcp.Tools.Policy/src/Options/PolicyOptionDefinitions.cs | Removes legacy System.CommandLine-based option definitions. |
| tools/Azure.Mcp.Tools.Policy/src/Options/Assignment/PolicyAssignmentListOptions.cs | Converts options to [Option] attributes and implements ISubscriptionOption. |
| tools/Azure.Mcp.Tools.Policy/src/GlobalUsings.cs | Removes Policy toolset global usings (previously included System.CommandLine and JSON usings). |
| tools/Azure.Mcp.Tools.Policy/src/Commands/Assignment/PolicyAssignmentListCommand.cs | Migrates to SubscriptionCommand<TOptions, TResult> and removes manual option registration/binding. |
| tools/Azure.Mcp.Tools.Policy/src/Azure.Mcp.Tools.Policy.csproj | Removes System.CommandLine dependency and updates Core project reference path. |
| servers/Azure.Mcp.Server/changelog-entries/1784220389040.yaml | Adds a changelog entry indicating a breaking change for Policy tools. |
Comment on lines
4
to
12
| using Azure.Mcp.Core.Commands.Subscription; | ||
| using Azure.Mcp.Core.Services.Azure.Subscription; | ||
| using Azure.Mcp.Tools.Policy.Models; | ||
| using Azure.Mcp.Tools.Policy.Options; | ||
| using Azure.Mcp.Tools.Policy.Options.Assignment; | ||
| using Azure.Mcp.Tools.Policy.Services; | ||
| using Microsoft.Extensions.Logging; | ||
| using Microsoft.Mcp.Core.Commands; | ||
| using Microsoft.Mcp.Core.Extensions; | ||
| using Microsoft.Mcp.Core.Models.Command; | ||
| using Microsoft.Mcp.Core.Models.Option; | ||
|
|
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 Policy 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