Azure基础架构MCP服务器
模型上下文协议(MCP)服务器,用于直接从AI助手(如Cursor中的Claude、VS Code、Claude Desktop或任何兼容MCP的客户端)管理Azure基础设施。
你能做什么
- 管理订阅 --列出Azure订阅并在它们之间切换
- 检查帐户 --查看订阅详细信息,获取访问令牌,清除缓存凭据
- 组织资源 --列出和管理资源组、标签、锁
- 控制虚拟机 --启动、停止、重新启动、取消分配虚拟机和扩展VMSS
- 管理存储 --列出并检查存储帐户
- 应用程序配置 --管理应用程序配置存储和键值
- 应用服务 --列出和管理应用服务计划和web应用程序
- 部署Web应用程序 --使用Docker/Podman为容器创建和管理Web应用程序
- 集装箱登记处 --列出、创建和管理ACR实例、映像、任务和网络规则
- 虚拟网络 --创建和管理虚拟主机、子网和对等网络
- 身份和访问 --管理Azure AD用户、组、应用程序和RBAC权限
- 治理 --使用管理组、资源锁和标记
- 审计 --查看活动日志并跟踪更改
- Docker运行时 --列出、检查日志并重新启动本地Docker容器
- 监控 --系统指标、服务健康状况和基础设施状态
快速开始
1.先决条件
- Python 3.10+
- Azure CLI已安装并登录(
az login) - 紫外线 包管理器(推荐)--或纯pip
2.安装
选项A——从PyPI安装(推荐):
pip install azops-mcp
# or
uv pip install azops-mcp选项B——使用uvx运行(零安装):
uvx azops-mcpuvx 将包下载到缓存的隔离环境中并运行服务器——不会永久安装任何东西。
选项C——来源:
git clone https://github.com/artemkozlenkov/azops-mcp.git
cd azops-mcp
./quickstart.sh3.配置您的AI客户端
克劳德桌面 --添加到 ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)或 %APPDATA%\Claude\claude_desktop_config.json (Windows):
重要提示: 克劳德桌面 不 继承你的shellPATH。您必须使用 完全绝对路径 到uvx(或任何其他命令)。找到它which uvx.
使用 uvx (推荐--无需安装):
{
"mcpServers": {
"azops-mcp": {
"command": "/Users/YOUR_USERNAME/.local/bin/uvx",
"args": ["azops-mcp"]
}
}
}使用一个 pip已安装 包裹:
{
"mcpServers": {
"azops-mcp": {
"command": "/Users/YOUR_USERNAME/.local/bin/azops-mcp"
}
}
}使用一个 本地克隆 (开发):
{
"mcpServers": {
"azops-mcp": {
"command": "/Users/YOUR_USERNAME/.local/bin/uv",
"args": ["--directory", "/full/path/to/azops-mcp", "run", "python", "-m", "azops_mcp"]
}
}
}Troubleshooting: "Failed to spawn process: No such file or directory"
此错误发生在 ~/Library/Logs/Claude/mcp-server-azops-mcp.log 意味着Claude Desktop找不到二进制文件。Claude Desktop仅搜索系统路径(/usr/local/bin, /opt/homebrew/bin, /usr/bin, /bin)确实如此 不 搜索 ~/.local/bin 或者来自shell配置文件的路径。
修复: 替换 "command": "uvx" 完整的路径从 which uvx (例如。 /Users/yourname/.local/bin/uvx).
光标 --添加到 ~/.cursor/mcp.json:
{
"mcpServers": {
"azops-mcp": {
"command": "uvx",
"args": ["azops-mcp"]
}
}
}帆板运动 --添加到 ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"azops-mcp": {
"command": "uvx",
"args": ["azops-mcp"]
}
}
}VS代码(GitHub副本) --添加到 .vscode/mcp.json 在您的工作空间中:
{
"servers": {
"azops-mcp": {
"command": "uvx",
"args": ["azops-mcp"]
}
}
}泽德 --添加到Zed设置文件中:
{
"context_servers": {
"azops-mcp": {
"command": {
"path": "uvx",
"args": ["azops-mcp"]
}
}
}
}继续(VS代码/JetBrains) --添加到 ~/.continue/config.yaml:
mcpServers:
- name: azops-mcp
command: uvx
args:
- azops-mcp注: Cursor、Windsurf、VS Code和Zed继承了你的shellPATH,所以uvx通常按原样工作。如果不是,请使用来自的完整路径which uvx。请参阅 完整文档 了解详情。
要传递环境变量(例如Azure凭据),请添加 "env" 按键:
{
"mcpServers": {
"azops-mcp": {
"command": "uvx",
"args": ["azops-mcp"],
"env": {
"AZURE_SUBSCRIPTION_ID": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
}
}
}保存配置后重新启动AI客户端。
4.开始使用
User: List my Azure subscriptions
User: Show resource groups in subscription xxx-xxx-xxx
User: Start the VM "web-server" in resource group "production"
User: What VMs are running in my dev resource group?认证
| 优先级 | 方法 | 何时 |
|---|---|---|
| 1 | 服务主体 | AZURE_CLIENT_ID + SECRET + TENANT_ID 全部设置完毕 .env |
| 2 | Azure命令行界面 | 之后 az login (建议开发) |
| 3 | 管理身份 | 在Azure中运行时 |
看 身份验证文档 完整的演练。
可用工具(90+)
| 类别 | 工具 |
|---|---|
| 健康 | health_check |
| 订阅和身份验证 | list_subscriptions, set_subscription, auth_status, account_show, account_clear, account_get_access_token, list_locations, list_tenants |
| 管理团队 | list_management_groups, get_management_group |
| RBAC | list_role_definitions, create_role_assignment, delete_role_assignment, list_role_assignments_for_principal |
| 治理 | list_resource_locks, list_tags, get_activity_log |
| 资源组 | list_resource_groups, list_resources |
| 虚拟机和VMSS | list_vms, get_vm_status, start_vm, stop_vm, restart_vm, deallocate_vm, scale_vmss |
| 存储 | list_storage_accounts, get_storage_status |
| 应用程序配置 | appconfig_list, appconfig_show, appconfig_kv_list, appconfig_kv_show, appconfig_kv_set, appconfig_kv_delete |
| 应用服务 | appservice_plan_list, appservice_plan_show, webapp_list, webapp_show, webapp_start, webapp_stop, webapp_restart |
| 容器Web应用程序 | webapp_create_for_container, webapp_grant_cr_access, webapp_configure_vnet_integration, webapp_assign_identity, webapp_view_logs, webapp_set_container_registry_credentials, webapp_delete |
| 集装箱登记处 | acr_list_registries, acr_show_registry, acr_create_registry, acr_delete_registry, acr_update_registry, acr_get_credentials, acr_get_login_server, acr_list_repositories, acr_list_tags, acr_show_task, acr_list_tasks, acr_create_task, acr_delete_task, acr_run_task, acr_list_builds, acr_show_quotas, acr_show_usage, acr_list_network_rules, acr_update_network_rules, acr_reset_client |
| 虚拟网络 | vnet_list, vnet_show, vnet_create, vnet_delete, vnet_subnet_list, vnet_subnet_show, vnet_subnet_create, vnet_subnet_delete, vnet_peering_list |
Azure AD(登录 ID) aad_list_users, aad_show_user, aad_create_user, aad_delete_user, aad_list_applications, aad_create_application, aad_list_groups, aad_verify_tenant, aad_reset_client | |
| Docker运行时 | list_containers, get_container_logs, restart_container |
| 监测 | get_system_metrics, check_service_health, get_infrastructure_status |
码头工人
将MCP服务器作为容器运行:
# Build the image
docker compose build
# Run the MCP server interactively (stdio transport)
docker compose run --rm mcp-server看 获取完整说明。
项目结构
azops-mcp/
├── src/azops_mcp/
│ ├── __main__.py # Module entry point
│ ├── server.py # MCP server — 93 tool definitions
│ ├── config.py # Configuration management
│ ├── tools/ # Azure SDK integrations (by category)
│ │ ├── _clients.py # Shared auth & Azure SDK client factories
│ │ ├── subscription.py # Subscriptions, auth, tenants, locations
│ │ ├── resource_groups.py # Resource groups, tags, locks, activity log
│ │ ├── compute.py # VMs, VMSS, resource listing
│ │ ├── networking.py # VNets, subnets, peerings
│ │ ├── authorization.py # RBAC roles & assignments
│ │ ├── management_groups.py # Management group hierarchy
│ │ ├── app_configuration.py # App Configuration stores & key-values
│ │ ├── app_service.py # App Service plans & web apps
│ │ ├── container_registry.py # Azure Container Registry (ACR)
│ │ ├── active_directory.py # Azure AD / Entra ID
│ │ ├── webapp_deployment.py # Web App for Containers deployment
│ │ ├── docker.py # Local Docker container runtime
│ │ └── monitoring.py # System metrics & health
│ └── utils/
│ └── helpers.py # HTTP client, error formatting
├── tests/ # Unit tests (per integration)
│ ├── test_subscription.py
│ ├── test_resource_groups.py
│ ├── test_compute.py
│ ├── test_networking.py
│ ├── test_authorization.py
│ ├── test_container_registry.py
│ ├── test_active_directory.py
│ ├── test_webapp_deployment.py
│ ├── test_docker.py
│ ├── test_monitoring.py
│ ├── test_health.py
│ └── test_config.py
├── docs/ # GitHub Pages documentation
├── Dockerfile # MCP server container image
├── docker-compose.yml # Docker Compose for the MCP server
├── pyproject.toml # Dependencies & metadata
├── quickstart.sh # Setup script
└── .env.example # Configuration template配置
| 变量 | 默认值 | 描述 |
|---|---|---|
AZURE_SUBSCRIPTION_ID | -- | 默认订阅 |
AZURE_DEFAULT_LOCATION | eastus | 新资源的默认区域 |
LOG_LEVEL | INFO | DEBUG, INFO, WARNING, ERROR |
RATE_LIMIT_ENABLED | true | 启用速率限制 |
RATE_LIMIT_REQUESTS_PER_MINUTE | 60 | 最大请求数/分钟 |
看 .env.example 查看完整列表。
发展
# Install with dev dependencies
uv pip install -e ".[dev]"
# Run tests
pytest
# Code quality
black src/ tests/
ruff check src/ tests/
mypy src/
# Run server manually
uv run python -m azops_mcp文档
完整文档可在 azops.softawebit.com.
许可证
麻省理工学院
