azurebackup-add-tool
Skill3.7k starsChanged 3 months agoMITView on GitHub
Add a new tool/command to the Azure Backup MCP toolset. Covers the full lifecycle: command implementation, option definitions, service layer, input validation, unit tests, live tests, recorded test playback, CI validation, spell check, changelog entry, tool description evaluation, and PR checklist. USE WHEN: add new backup command, create backup tool, implement backup operation, new azurebackup command, add MCP tool for backup, new vault operation, new policy command, new governance command.
- Reads credentials
- Commits and pushes
In this repository8 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- add-azure-mcp-toolsSkill
- agentic-workflowsSkill
- harden-tool-url-inputsSkill
- mcp-code-reviewerSkill
- resilience-management-operationsSkill
- azurebackup-telemetry-reportSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
29 rules. About 0 are common, 11 are distinctive, and 18 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
18
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 31
Follow /.github/skills/add-azure-mcp-tools/SKILL.md as the authoritative guide.
- Very specific: line 46
Use OptionDefinitions.Common.* for shared options (subscription, resourceGroup)
- Very specific: line 47
Use AzureBackupOptionDefinitions.Vault and AzureBackupOptionDefinitions.VaultType for vault options
- Very specific: line 48
Add new options to AzureBackupOptionDefinitions if reusable across commands
- Very specific: line 49
Use .AsRequired() / .AsOptional() extension methods
- Distinctive: line 55
Add the interface method first
- Very specific: line 65
Use [CommandMetadata(...)] attribute (not property overrides)
- Very specific: line 69
Add telemetry tags via AzureBackupTelemetryTags.AddVaultTags(context.Activity, ...)
- Very specific: line 70
Call HandleException(context, ex) in catch blocks
- Very specific: line 76
Add services.AddSingleton<MyNewCommand>() in ConfigureServices
- Very specific: line 78
Create a new CommandGroup if needed for a new group
- Very specific: line 84
Add [JsonSerializable(typeof(MyNewCommand.MyResultType))] for AOT safety
- Distinctive: line 88
Before writing tests, validate all inputs are handled correctly:
- Distinctive: line 132
Verify all tests pass before proceeding.
- Very specific: line 162
Use [Fact] for all live tests (not [RecordedTest] — that attribute is not used in Azure Backup)
- Very specific: line 163
Use [LiveTestOnly] alongside [Fact] for long-running E2E tests that cannot reliably replay
- Very specific: line 164
Use test resource values from DeploymentOutputs (set in test-resources-post.ps1)
- Distinctive: line 168
If the new command requires new Azure resources:
- Distinctive: line 218
All recorded tests must pass in Playback mode.
- Distinctive: line 222
Run these checks in order.
- Distinctive: line 238
If it fails, fix with:
- Very specific: line 263
If new Azure Backup-specific technical terms are flagged, add them to tools/Azure.Mcp.Tools.AzureBackup/cspell.yaml.
- Very specific: line 279
If this fails for a new Azure SDK dependency, the toolset may need to be excluded from native builds (see docs/aot-compatibility.md).
- Distinctive: line 284
Run the ToolDescriptionEvaluator to verify the new tool's description is discoverable by AI agents.
- Very specific: line 296
If the score is low, improve the command's Description in the [CommandMetadata] attribute:
- Distinctive: line 308
Add the new command in alphabetical order within the azurebackup section.
- Distinctive: line 320
Add 2-3 natural language prompts that should trigger the new tool, in alphabetical order.
- Very specific: line 324
Follow docs/changelog-entries.md instructions.
- Distinctive: line 331
Before creating the PR, verify:
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Add a New Tool to Azure Backup MCP
Purpose
Step-by-step workflow for adding a new command to the Azure Backup MCP toolset, ensuring it passes all validation gates before PR submission.
When to Use
- Adding a new
azmcp azurebackup <group> <operation>command - Extending an existing command group (vault, policy, protecteditem, etc.)
- Adding a new command group (security, compliance, etc.)
Prerequisites
.NET 10 SDKinstalled (seeglobal.json)- Azure authentication configured (
az login/Connect-AzAccount) - Repository cloned with
upstreamremote pointing tomicrosoft/mcp - Branch created from
upstream/main
Procedure
Phase 1: Implementation
Follow /.github/skills/add-azure-mcp-tools/SKILL.md as the authoritative guide.
The Azure Backup toolset lives in tools/Azure.Mcp.Tools.AzureBackup/.
1a. Create Option Definitions
File: src/Options/{Group}/{Resource}{Operation}Options.cs
// Inherit from the appropriate base options class
public class MyNewOptions : BaseAzureBackupOptions
{
public string? MyParam { get; set; }
}- Use
OptionDefinitions.Common.*for shared options (subscription, resourceGroup) - Use
AzureBackupOptionDefinitions.VaultandAzureBackupOptionDefinitions.VaultTypefor vault options - Add new options to
AzureBackupOptionDefinitionsif reusable across commands - Use
.AsRequired()/.AsOptional()extension methods
1b. Add Service Method
File: src/Services/IAzureBackupService.cs and src/Services/AzureBackupService.cs
- Add the interface method first
- Route to
rsvOpsordppOpsbased on vault type usingResolveVaultTypeAsync - For RSV-only operations, add to
IRsvBackupOperations/RsvBackupOperations - For DPP-only operations, add to
IDppBackupOperations/DppBackupOperations
1c. Implement the Command
File: src/Commands/{Group}/{Resource}{Operation}Command.cs
Required patterns:
- Use
[CommandMetadata(...)]attribute (not property overrides) - Sealed class with primary constructor
- Inject
ILogger<T>andIAzureBackupService - Override
RegisterOptions,BindOptions,ExecuteAsync - Add telemetry tags via
AzureBackupTelemetryTags.AddVaultTags(context.Activity, ...) - Call
HandleException(context, ex)in catch blocks
1d. Register the Command
File: src/AzureBackupSetup.cs
- Add
services.AddSingleton<MyNewCommand>()inConfigureServices - Add
group.AddCommand<MyNewCommand>(serviceProvider)inRegisterCommands - Create a new
CommandGroupif needed for a new group
1e. Register JSON Serialization Context
File: src/Commands/AzureBackupJsonContext.cs
- Add
[JsonSerializable(typeof(MyNewCommand.MyResultType))]for AOT safety
Phase 2: Input Validation
Before writing tests, validate all inputs are handled correctly:
Checklist:
- Required parameters throw
ArgumentExceptionwith clear message when missing - Subscription format validated (GUID only) via
ValidateSubscriptionFormat - Vault type normalized correctly (rsv/dpp case-insensitive)
- Enum/string parameters validated against allowed values with helpful error listing
- Null/empty strings handled with
ArgumentException.ThrowIfNullOrWhiteSpace - ARM resource IDs parsed safely with try-catch on
new ResourceIdentifier(...) - Error messages are actionable (tell user what to provide, not just what failed)
Phase 3: Unit Tests
File: tests/Azure.Mcp.Tools.AzureBackup.Tests/{Group}/{Resource}{Operation}CommandTests.cs
Required Test Methods
public sealed class MyNewCommandTests : CommandUnitTestsBase<MyNewCommand, IAzureBackupService>
{
[Fact] public void Constructor_InitializesCommandCorrectly()
[Fact] public void BindOptions_BindsOptionsCorrectly()
[Fact] public async Task ExecuteAsync_ValidInput_ReturnsExpectedResult()
[Fact] public async Task ExecuteAsync_HandlesServiceErrors()
[Fact] public async Task ExecuteAsync_DeserializationValidation()
// Add per-parameter validation tests:
[Theory]
[InlineData(null)]
[InlineData("")]
public async Task ExecuteAsync_InvalidVault_ThrowsArgumentException(string? vault)
// Add edge case tests specific to the command
}Run Unit Tests
dotnet test tools\Azure.Mcp.Tools.AzureBackup\tests\Azure.Mcp.Tools.AzureBackup.Tests `
/p:NuGetAudit=false `
--filter "Category!=Live&FullyQualifiedName~MyNewCommandTests"Verify all tests pass before proceeding.
Phase 4: Live Tests
File: tests/Azure.Mcp.Tools.AzureBackup.Tests/AzureBackupCommandTests.cs
4a. Add Test Methods
Azure Backup live tests use [Fact] on a RecordedCommandTestsBase subclass with CallToolAsync.
There is no [RecordedTest] attribute in this toolset.
[Fact]
public async Task MyNewCommand_RsvVault()
{
var result = await CallToolAsync(
"azurebackup", "mygroup", "myop",
new Dictionary<string, object>
{
["subscription"] = SubscriptionId,
["resourceGroup"] = ResourceGroupName,
["vault"] = DeploymentOutputs["AZUREBACKUP_RSV_VAULT_NAME"],
// add other params
});
Assert.NotNull(result);
// assert on result content
}- Use
[Fact]for all live tests (not[RecordedTest]— that attribute is not used in Azure Backup) - Use
[LiveTestOnly]alongside[Fact]for long-running E2E tests that cannot reliably replay - Use test resource values from
DeploymentOutputs(set intest-resources-post.ps1)
4b. Update Test Infrastructure (if needed)
If the new command requires new Azure resources:
- Edit
tests/test-resources.bicepto add the resource - Edit
tests/test-resources-post.ps1to output new deployment values - Deploy:
./eng/scripts/Deploy-TestResources.ps1 -Paths AzureBackup
4c. Record Live Tests
# Set to Record mode
$settings = @{
TestMode = "Record"
SubscriptionId = "<your-sub>"
TenantId = "<your-tenant>"
ResourceGroupName = "<your-rg>"
ResourceBaseName = "<your-base>"
} | ConvertTo-Json
$settings | Set-Content "tools\Azure.Mcp.Tools.AzureBackup\tests\Azure.Mcp.Tools.AzureBackup.Tests\.testsettings.json"
# Kill any stale proxy/server processes
Stop-Process -Name "Azure.Sdk.Tools.TestProxy","azmcp" -Force -ErrorAction SilentlyContinue
# Run tests in Record mode
dotnet test tools\Azure.Mcp.Tools.AzureBackup\tests\Azure.Mcp.Tools.AzureBackup.Tests `
/p:NuGetAudit=false --filter "FullyQualifiedName~MyNewCommand"4d. Push Recordings
# Push recorded sessions to azure-sdk-assets
.proxy\Azure.Sdk.Tools.TestProxy push `
-a tools\Azure.Mcp.Tools.AzureBackup\tests\Azure.Mcp.Tools.AzureBackup.Tests\assets.jsonThis updates the Tag field in assets.json. Commit the updated assets.json.
4e. Verify Playback
# Switch to Playback mode
$settings = @{ TestMode = "Playback"; SubscriptionId = "..."; TenantId = "..."; ResourceGroupName = "..."; ResourceBaseName = "..." } | ConvertTo-Json
$settings | Set-Content "tools\Azure.Mcp.Tools.AzureBackup\tests\Azure.Mcp.Tools.AzureBackup.Tests\.testsettings.json"
Stop-Process -Name "Azure.Sdk.Tools.TestProxy","azmcp" -Force -ErrorAction SilentlyContinue
dotnet test tools\Azure.Mcp.Tools.AzureBackup\tests\Azure.Mcp.Tools.AzureBackup.Tests `
/p:NuGetAudit=false --filter "FullyQualifiedName~MyNewCommand"All recorded tests must pass in Playback mode.
Phase 5: CI Validation Gates
Run these checks in order. All must pass before creating a PR.
5a. Build
dotnet build tools\Azure.Mcp.Tools.AzureBackup\src\Azure.Mcp.Tools.AzureBackup.csproj /p:NuGetAudit=false5b. Format Check
dotnet format Microsoft.Mcp.slnx --verify-no-changes `
--include "tools/Azure.Mcp.Tools.AzureBackup/**" `
--exclude-diagnostics IL2026 IL3050If it fails, fix with:
dotnet format Microsoft.Mcp.slnx `
--include "tools/Azure.Mcp.Tools.AzureBackup/**" `
--exclude-diagnostics IL2026 IL30505c. Full Unit Tests
dotnet test tools\Azure.Mcp.Tools.AzureBackup\tests\Azure.Mcp.Tools.AzureBackup.Tests /p:NuGetAudit=false5d. Full Live Tests (Playback)
dotnet test tools\Azure.Mcp.Tools.AzureBackup\tests\Azure.Mcp.Tools.AzureBackup.Tests /p:NuGetAudit=false5e. Spell Check
.\eng\common\spelling\Invoke-Cspell.ps1If new Azure Backup-specific technical terms are flagged, add them to tools/Azure.Mcp.Tools.AzureBackup/cspell.yaml. Add cross-cutting terms used by multiple projects to .vscode/cspell.json.
5f. Full Build Verification
./eng/scripts/Build-Local.ps1 -VerifyNpx5g. AOT/Native Build Verification
Azure Backup is marked IsAotCompatible=true, so also validate native compilation:
./eng/scripts/Build-Local.ps1 -BuildNativeIf this fails for a new Azure SDK dependency, the toolset may need to be excluded
from native builds (see docs/aot-compatibility.md).
Phase 6: Tool Description Evaluation
Run the ToolDescriptionEvaluator to verify the new tool's description is discoverable by AI agents.
$env:AOAI_ENDPOINT = "<your-aoai-endpoint>"
$env:TEXT_EMBEDDING_API_KEY = "<your-key>"
dotnet run --project eng/tools/ToolDescriptionEvaluator/src/ToolDescriptionEvaluator.csproj `
-- --tool-name "azurebackup_<group>_<operation>"Target: Top 3 ranking with confidence score >= 0.4.
If the score is low, improve the command's Description in the [CommandMetadata] attribute:
- Include key verbs users would say ("configure", "enable", "list", "show")
- Mention specific resource types ("vault", "policy", "protected item")
- Describe what the output looks like
- Re-run until the score meets the threshold
Phase 7: Documentation
7a. Update Command Reference
File: servers/Azure.Mcp.Server/docs/azmcp-commands.md
Add the new command in alphabetical order within the azurebackup section.
Then regenerate the commands metadata:
./eng/scripts/Update-AzCommandsMetadata.ps1This is required for CI validation.
7b. Add Test Prompts
File: servers/Azure.Mcp.Server/docs/e2eTestPrompts.md
Add 2-3 natural language prompts that should trigger the new tool, in alphabetical order.
7c. Create Changelog Entry
Follow docs/changelog-entries.md instructions. Use the -ChangelogPath parameter pointing to
servers/Azure.Mcp.Server/CHANGELOG.md.
Phase 8: PR Submission
Final Checklist
Before creating the PR, verify:
- Build passes:
dotnet buildsucceeds with 0 errors - Format clean:
dotnet format --verify-no-changespasses - All unit tests pass (including existing ones — no regressions)
- All live tests pass in Playback mode
- Recordings pushed and
assets.jsonupdated - Spell check passes:
Invoke-Cspell.ps1clean - ToolDescriptionEvaluator: Score >= 0.4, top 3 ranking
- Command registered in
AzureBackupSetup.cs - JSON context registered for AOT safety
- Telemetry tags added via
AzureBackupTelemetryTags - Documentation updated (commands.md, e2eTestPrompts.md, changelog, README.md, eng/vscode/README.md)
- Commands metadata regenerated via
Update-AzCommandsMetadata.ps1 - AOT/native build passes (
Build-Local.ps1 -BuildNative) - One tool per PR (don't bundle unrelated changes)
Create the PR
git add tools/Azure.Mcp.Tools.AzureBackup/ servers/Azure.Mcp.Server/ README.md eng/vscode/README.md
git commit -m "feat(azurebackup): Add <group> <operation> command
<description of what the command does>"
git push origin <branch-name>Reference: File Locations
tools/Azure.Mcp.Tools.AzureBackup/
├── src/
│ ├── AzureBackupSetup.cs # Register here
│ ├── Commands/
│ │ ├── AzureBackupJsonContext.cs # AOT registration
│ │ └── {Group}/{Resource}{Operation}Command.cs # Command impl
│ ├── Options/
│ │ ├── AzureBackupOptionDefinitions.cs # Shared options
│ │ └── {Group}/{Resource}{Operation}Options.cs # Command options
│ ├── Services/
│ │ ├── IAzureBackupService.cs # Interface
│ │ ├── AzureBackupService.cs # Routing
│ │ ├── RsvBackupOperations.cs # RSV impl
│ │ └── DppBackupOperations.cs # DPP impl
│ └── Models/
│ └── AzureBackupTelemetryTags.cs # Telemetry
└── tests/
├── Azure.Mcp.Tools.AzureBackup.Tests/
│ ├── {Group}/{Resource}{Operation}CommandTests.cs
│ ├── AzureBackupCommandTests.cs # Add tests here
│ └── assets.json # Recording tag
├── test-resources.bicep # Azure infra
└── test-resources-post.ps1 # Post-deployReference: Good Examples
Study these existing implementations as templates:
- Simple get/list:
Commands/Vault/VaultGetCommand.cs - Create with validation:
Commands/Policy/PolicyCreateCommand.cs - Governance toggle:
Commands/Governance/GovernanceSoftDeleteCommand.cs - Security command:
Commands/Security/SecurityConfigureMuaCommand.cs - Unit tests:
tests/Azure.Mcp.Tools.AzureBackup.Tests/Policy/PolicyCreateCommandTests.cs
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

