AgentSkillsCN

azure-mcp

搭建并使用 Azure MCP 服务器,通过结构化工具直接接入 Azure 服务。

SKILL.md
--- frontmatter
name: azure-mcp
description: Set up and use the Azure MCP server for direct access to Azure services through structured tools

Azure MCP Server

Overview

The Azure MCP server provides direct access to Azure services through structured tools, enabling richer data access than CLI commands alone.

Configuration

Add to your MCP configuration (.mcp.json or settings):

json
{
  "mcpServers": {
    "azure": {
      "command": "npx",
      "args": ["-y", "@azure/mcp@latest", "server", "start"],
      "env": {}
    }
  }
}

Authentication

The Azure MCP server uses Azure CLI credentials by default.

Login First

bash
# Interactive login
az login

# Device code flow (headless/remote)
az login --use-device-code

# Set subscription
az account set --subscription "Subscription Name"

Service Principal (CI/CD)

Set environment variables:

  • AZURE_TENANT_ID
  • AZURE_CLIENT_ID
  • AZURE_CLIENT_SECRET

Enabling the MCP Server

In Claude Code

  1. Run /mcp to view MCP servers
  2. Enable the Azure MCP server
  3. Or run /azure:setup for guided configuration

Verify Connection

After enabling, verify tools are available:

  • Check /azure:status
  • Try azure__subscription_list to list subscriptions

Benefits Over CLI

FeatureMCP ServerCLI
Structured dataJSON responsesText parsing needed
PaginationAutomaticManual continuation
Schema infoBuilt-inSeparate queries
AuthenticationManagedManual

Troubleshooting

Server Not Starting

  1. Ensure Node.js 18+ is installed
  2. Check npx is available
  3. Verify network access to npm registry

Authentication Errors

  1. Run az login to refresh credentials
  2. Check subscription is set: az account show
  3. Verify permissions on target resources

Tool Not Available

  1. Enable the Azure MCP server first
  2. Check server is connected in /mcp
  3. Some tools require specific permissions

Fallback to CLI

When MCP is unavailable, use Azure CLI directly:

bash
# List subscriptions
az account list --output table

# List resources
az resource list -g RESOURCE_GROUP --output table

See cli/cheatsheet.md for common CLI commands.


Tool Reference

The Azure MCP server exposes two types of tools:

  • Standalone tools: Called directly (e.g., azure__subscription_list)
  • Hierarchical tools: Called with a command parameter (e.g., azure__deploy with command deploy_plan_get)

Core Operations

ToolDescription
azure__subscription_listList all subscriptions
azure__group_listList resource groups in subscription

Storage

ToolCommandDescription
azure__storagestorage_account_listList storage accounts
azure__storagestorage_container_listList containers in account
azure__storagestorage_blob_listList blobs in container
azure__storagestorage_blob_getDownload blob content
azure__storagestorage_blob_putUpload blob content

SQL Database

ToolCommandDescription
azure__sqlsql_server_listList SQL servers
azure__sqlsql_database_listList databases on server
azure__sqlsql_firewall_listList firewall rules

Cosmos DB

ToolCommandDescription
azure__cosmoscosmos_account_listList Cosmos DB accounts
azure__cosmoscosmos_database_listList databases in account
azure__cosmoscosmos_container_listList containers

Redis

ToolCommandDescription
azure__redisredis_cache_listList Redis caches

Key Vault

ToolCommandDescription
azure__keyvaultkeyvault_listList Key Vaults
azure__keyvaultkeyvault_secret_listList secrets in vault
azure__keyvaultkeyvault_secret_getGet secret value
azure__keyvaultkeyvault_key_listList keys
azure__keyvaultkeyvault_certificate_listList certificates

RBAC

ToolCommandDescription
azure__rolerole_assignment_listList role assignments
azure__rolerole_definition_listList role definitions

App Service

ToolCommandDescription
azure__appserviceappservice_webapp_listList web apps
azure__appserviceappservice_webapp_getGet app details
azure__appserviceappservice_plan_listList App Service plans

Functions

ToolCommandDescription
azure__functionappfunctionapp_listList function apps

AKS

ToolCommandDescription
azure__aksaks_cluster_listList AKS clusters
azure__aksaks_nodepool_listList node pools

Container Apps

ToolCommandDescription
azure__appservicecontainerapp_listList container apps

AI Search

ToolCommandDescription
azure__searchsearch_index_listList search indexes
azure__searchsearch_index_getGet index details
azure__searchsearch_queryQuery search index

Speech

ToolCommandDescription
azure__speechspeech_transcribeSpeech to text
azure__speechspeech_synthesizeText to speech

Foundry

ToolCommandDescription
azure__foundryfoundry_model_listList AI models
azure__foundryfoundry_deployment_listList deployments
azure__foundryfoundry_agent_listList AI agents

Monitoring

ToolCommandDescription
azure__monitormonitor_metrics_queryQuery metrics
azure__monitormonitor_logs_queryQuery logs with KQL
azure__applicationinsightsapplicationinsights_component_listList App Insights
azure__resourcehealth(various)Check resource health and availability
azure__applens(conversational)AI-powered diagnostics for troubleshooting Azure resource issues

Deployment & Infrastructure

ToolCommandDescription
azure__deploydeploy_plan_getGenerate a deployment plan for Azure infrastructure
azure__deploydeploy_iac_rules_getGet IaC (Bicep/Terraform) guidelines
azure__deploydeploy_app_logs_getFetch logs from deployed apps
azure__deploydeploy_pipeline_guidance_getGet CI/CD pipeline guidance
azure__deploydeploy_architecture_diagram_generateGenerate architecture diagrams
azure__bicepschema(schema queries)Get Bicep resource type schemas
azure__quotaquota_region_availability_listCheck regional quota and availability

Best Practices

ToolCommandDescription
azure__get_azure_bestpractices(various)Get Azure best practices for code generation and deployment

Documentation

ToolDescription
azure__documentationSearch official Microsoft/Azure documentation

CLI Helpers

ToolDescription
azure__extension_cli_installGet CLI installation instructions
azure__extension_cli_generateGenerate Azure CLI commands
azure__extension_azqrRun Azure Quick Review for compliance/security reports

CLI Install Tool

code
Parameters:
  - cli-type: "az" | "azd" | "func"

CLI Generate Tool

code
Parameters:
  - intent: Description of what you want to do
  - cli-type: "az"