Skip to content

Add compute VM and VMSS DELETE commands#2065

Open
haagha wants to merge 8 commits intomicrosoft:mainfrom
haagha:haagha/delete
Open

Add compute VM and VMSS DELETE commands#2065
haagha wants to merge 8 commits intomicrosoft:mainfrom
haagha:haagha/delete

Conversation

@haagha
Copy link
Contributor

@haagha haagha commented Mar 16, 2026

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 machine
  • azmcp compute vmss delete - Delete a virtual machine scale set

Both commands implement a two-stage safety guard:

  1. Without --force: Returns a warning message and does NOT delete the resource
  2. With --force: Proceeds with deletion after confirmation
  3. With --force-deletion: Passes forceDeletion=true to the Azure API to force-delete even if the resource is in a running or failed state

The commands use Secret = true in ToolMetadata to trigger MCP client elicitation for destructive confirmation.

Command Parameters

compute vm delete

Parameter Required Description
--subscription Yes Azure subscription ID or name
--resource-group, -g Yes Resource group name
--vm-name Yes Name of the virtual machine to delete
--force No Bypass confirmation prompt and proceed with deletion
--force-deletion No Force delete the VM even if running or failed (Azure API forceDeletion)

compute vmss delete

Parameter Required Description
--subscription Yes Azure subscription ID or name
--resource-group, -g Yes Resource group name
--vmss-name Yes Name of the VMSS to delete
--force No Bypass confirmation prompt and proceed with deletion
--force-deletion No Force delete the VMSS even if running or failed (Azure API forceDeletion)

Changes

Documentation

  • Updated azmcp-commands.md with full command documentation
  • Added 8 test prompts to e2eTestPrompts.md
  • Updated consolidated-tools.json with delete_azure_compute_resources tool grouping
  • Added changelog entry

Tests

  • Unit Tests: 28 tests covering all commands (VM delete: 14, VMSS delete: 14)
  • Live Tests: 6 recorded tests (VM delete: 3, VMSS delete: 3)
    • Delete without force → warning returned
    • Delete with force → creates and deletes resource
    • Delete nonexistent resource → error handling

Changelog

  • Added changelog entry for the new commands

ToolDescriptionEvaluator Results

53 prompts tested for compute tools:

Metric Result
Top Choice Success 94.3% ✅
Acceptable Confidence (≥0.4) 100.0% (53/53) ✅

Delete-specific results

VM Delete — all 4 prompts ranked #1 with scores 0.54–0.56:

Prompt Rank Score
Delete VM... #1 0.558
Remove virtual machine... #1 0.544
Destroy VM... #1 0.565
Force delete VM... #1 0.554

VMSS Delete — all 4 prompts ranked #1 with scores 0.60–0.65:

Prompt Rank Score
Delete scale set... #1 0.650
Remove VMSS... #1 0.597
Destroy virtual machine scale set... #1 0.601
Force delete VMSS... #1 0.627

Testing

  • ✅ All 28 unit tests pass
  • ✅ All 6 live tests recorded and pass in playback mode
  • ✅ Recordings pushed to Azure/azure-sdk-assets with tag Azure.Mcp.Tools.Compute.LiveTests_bee60684d6
  • ✅ ToolDescriptionEvaluator: 100% acceptable confidence, all delete prompts ranked Update README.md #1
  • ✅ Spelling check passes
  • dotnet build succeeds with 0 errors, 0 warnings
  • dotnet format passes

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.

Haider Agha 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.
Copy link
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 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 --force safety guard and optional --force-deletion pass-through to the Azure API.
  • Extend IComputeService/ComputeService with delete operations and update ComputeJsonContext for 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.

# 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
@haagha haagha changed the title Add compute VM and VMSS delete commands with --force confirmation guard Add compute VM and VMSS DELETE commands Mar 16, 2026
Haider Agha 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)
@KarishmaGhiya
Copy link
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?

@KarishmaGhiya KarishmaGhiya moved this from Untriaged to In Progress in Azure MCP Server Mar 17, 2026
@KarishmaGhiya KarishmaGhiya added this to the 2026-03 milestone Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants