Add compute VM and VMSS DELETE commands#2065
Open
haagha wants to merge 8 commits intomicrosoft:mainfrom
Open
Conversation
added 5 commits
March 6, 2026 12:16
- Implemented `VmDeleteCommand` and `VmssDeleteCommand` to handle deletion of Azure Virtual Machines and Virtual Machine Scale Sets. - Added `--force` and `--force-deletion` options to bypass confirmation prompts and force deletion in certain states. - Updated `ComputeService` to include methods for deleting VMs and VMSS. - Enhanced `ComputeOptionDefinitions` to define new options for deletion commands. - Added unit tests for `VmDeleteCommand` and `VmssDeleteCommand` to ensure proper functionality and error handling. - Updated service registration in `ComputeSetup` to include new delete commands. - Created changelog entry for the new features.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds destructive delete support to the Compute tool area by introducing compute vm delete and compute vmss delete commands, wiring them into DI/command registration, and updating server discovery artifacts and documentation.
Changes:
- Add VM and VMSS delete commands with
--forcesafety guard and optional--force-deletionpass-through to the Azure API. - Extend
IComputeService/ComputeServicewith delete operations and updateComputeJsonContextfor new result payloads. - Add unit tests and live tests, plus updates to consolidated tools, docs, prompts, and changelog.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.Compute/tests/Azure.Mcp.Tools.Compute.UnitTests/Vmss/VmssDeleteCommandTests.cs | Adds unit coverage for VMSS delete command behavior (force guard, error handling, binding). |
| tools/Azure.Mcp.Tools.Compute/tests/Azure.Mcp.Tools.Compute.UnitTests/Vm/VmDeleteCommandTests.cs | Adds unit coverage for VM delete command behavior (force guard, error handling, binding). |
| tools/Azure.Mcp.Tools.Compute/tests/Azure.Mcp.Tools.Compute.LiveTests/ComputeCommandTests.cs | Adds recorded live tests for VM/VMSS delete scenarios and updates initialization comment. |
| tools/Azure.Mcp.Tools.Compute/tests/Azure.Mcp.Tools.Compute.LiveTests/assets.json | Updates recorded test asset tag to a new recording set. |
| tools/Azure.Mcp.Tools.Compute/src/Services/IComputeService.cs | Introduces delete method signatures for VM and VMSS. |
| tools/Azure.Mcp.Tools.Compute/src/Services/ComputeService.cs | Implements VM/VMSS deletion using ARM resources and 404 handling. |
| tools/Azure.Mcp.Tools.Compute/src/Options/Vmss/VmssDeleteOptions.cs | Adds options model for VMSS delete. |
| tools/Azure.Mcp.Tools.Compute/src/Options/Vm/VmDeleteOptions.cs | Adds options model for VM delete. |
| tools/Azure.Mcp.Tools.Compute/src/Options/ComputeOptionDefinitions.cs | Adds shared --force and --force-deletion option definitions. |
| tools/Azure.Mcp.Tools.Compute/src/ComputeSetup.cs | Registers new delete commands and adds them to the compute command groups. |
| tools/Azure.Mcp.Tools.Compute/src/Commands/Vmss/VmssDeleteCommand.cs | Implements VMSS delete command with force guard, service call, and error mapping. |
| tools/Azure.Mcp.Tools.Compute/src/Commands/Vm/VmDeleteCommand.cs | Implements VM delete command with force guard, service call, and error mapping. |
| tools/Azure.Mcp.Tools.Compute/src/Commands/ComputeJsonContext.cs | Adds source-gen serialization metadata for new delete result types. |
| servers/Azure.Mcp.Server/src/Resources/consolidated-tools.json | Adds consolidated tool mapping for compute delete operations. |
| servers/Azure.Mcp.Server/docs/e2eTestPrompts.md | Adds E2E prompt coverage entries for the new delete tools. |
| servers/Azure.Mcp.Server/docs/azmcp-commands.md | Documents new azmcp compute vm delete and azmcp compute vmss delete commands and parameters. |
| servers/Azure.Mcp.Server/changelog-entries/1772817302990.yaml | Adds changelog entry for the new delete commands. |
tools/Azure.Mcp.Tools.Compute/tests/Azure.Mcp.Tools.Compute.LiveTests/ComputeCommandTests.cs
Outdated
Show resolved
Hide resolved
tools/Azure.Mcp.Tools.Compute/tests/Azure.Mcp.Tools.Compute.LiveTests/ComputeCommandTests.cs
Outdated
Show resolved
Hide resolved
tools/Azure.Mcp.Tools.Compute/src/Options/ComputeOptionDefinitions.cs
Outdated
Show resolved
Hide resolved
# Conflicts: # servers/Azure.Mcp.Server/src/Resources/consolidated-tools.json # tools/Azure.Mcp.Tools.Compute/src/Options/ComputeOptionDefinitions.cs # tools/Azure.Mcp.Tools.Compute/tests/Azure.Mcp.Tools.Compute.LiveTests/assets.json
added 2 commits
March 16, 2026 14:52
… not-found tests - Update --force option description to 'Required to confirm and proceed with deletion' - Change --force to [--force] in azmcp-commands.md syntax blocks (VM and VMSS delete) - Fix VM/VMSS not-found live tests to use Client.CallToolAsync directly and assert IsError - Pass resourceGroupRequired=true to BaseComputeCommand for delete commands (main merge fix)
Member
|
@haagha I think we might be overdoing with 2 flags "--force" and "--force-deletion". Can you share example usages of all the 3 scenarios you mentioned above? How would it look for a user for the mcp tool v/s Azure API? |
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.
Summary
Addresses tools from #1452
This PR adds two new compute commands for deleting Azure Virtual Machines (VMs) and Virtual Machine Scale Sets (VMSS):
azmcp compute vm delete- Delete a virtual machineazmcp compute vmss delete- Delete a virtual machine scale setBoth commands implement a two-stage safety guard:
--force: Returns a warning message and does NOT delete the resource--force: Proceeds with deletion after confirmation--force-deletion: PassesforceDeletion=trueto the Azure API to force-delete even if the resource is in a running or failed stateThe commands use
Secret = truein ToolMetadata to trigger MCP client elicitation for destructive confirmation.Command Parameters
compute vm delete--subscription--resource-group,-g--vm-name--force--force-deletioncompute vmss delete--subscription--resource-group,-g--vmss-name--force--force-deletionChanges
Documentation
azmcp-commands.mdwith full command documentatione2eTestPrompts.mdconsolidated-tools.jsonwithdelete_azure_compute_resourcestool groupingTests
Changelog
ToolDescriptionEvaluator Results
53 prompts tested for compute tools:
Delete-specific results
VM Delete — all 4 prompts ranked #1 with scores 0.54–0.56:
VMSS Delete — all 4 prompts ranked #1 with scores 0.60–0.65:
Testing
Azure/azure-sdk-assetswith tagAzure.Mcp.Tools.Compute.LiveTests_bee60684d6dotnet buildsucceeds with 0 errors, 0 warningsdotnet formatpassesInvoking Livetests
Copilot submitted PRs are not trustworthy by default. Users with
writeaccess 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.