Azure MCP Server

Official

local-only server

The server can only run on the client’s local machine because it depends on local resources.

适用于 Claude Desktop 的 Azure MCP(模型上下文协议)

模型上下文协议 (MCP) 实现,使 Claude Desktop 能够与 Azure 服务交互。此集成允许 Claude 直接通过自然语言对话查询和管理 Azure 资源。

特征

  • Azure 资源管理:与 Azure 资源管理客户端接口
  • 订阅管理:列出和管理 Azure 订阅
  • 租户管理:列出并选择 Azure 租户
  • 自动身份验证:利用 DefaultAzureCredential 实现灵活的身份验证方法
  • 错误处理:强大的错误处理功能,可重试瞬时故障
  • 清洁响应格式:与 Claude Desktop 兼容的正确格式的响应

先决条件

  • Node.js(v18 或更高版本)
  • Claude 桌面应用程序
  • 具有适当权限的 Azure 帐户
  • Azure CLI(可选,用于基于 CLI 的身份验证)

安装

手动安装

  1. 克隆存储库:
git clone https://github.com/Streen9/azure-mcp.git cd azure-mcp
  1. 安装依赖项:
npm install
  1. 配置Claude桌面:
    • 打开claude_desktop_config.json
    • 添加以下 MCP 配置:
{ "mcpServers": { "sequential-thinking": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-sequential-thinking" ] }, "azure": { "command": "tsx", "args": [ "C:/Users/[YourUsername]/path/to/azure-mcp/src/launcher.ts" ] } } }

验证

服务器通过DefaultAzureCredential支持多种身份验证方法:

  • 环境变量
  • 托管标识
  • Azure CLI
  • Visual Studio 代码
  • 交互式浏览器

服务器将自动按顺序尝试这些方法,直到成功为止。

用法

  1. 如果 Claude Desktop 正在运行,请关闭它(检查任务管理器)
  2. 启动 Claude Desktop
  3. 在聊天中,您现在可以询问与 Azure 相关的问题,例如:
    • “您能获得所有可用的 Azure 帐户和订阅吗?”
    • “列出我的订阅中的所有资源组”
    • “显示特定资源组中的所有虚拟机”

对话示例

You: Can you get all the available Azure accounts and subscriptions? Claude: I'll help you list all available Azure tenants and subscriptions. [Claude will then use the Azure MCP to fetch and display the information]

发展

项目结构

azure-mcp/ ├── src/ │ ├── launcher.ts # Server entry point │ ├── AzureServer.ts # Main MCP server implementation │ └── LoggerService.ts # Logging utility ├── package.json └── README.md

关键组件

  • AzureMCPServer :实现 MCP 协议的主服务器类
  • HandleCallTool :处理传入的工具请求
  • ExecuteWithRetry :实现弹性操作的重试逻辑

故障排除

  1. 身份验证问题
    • 确保您已通过 Azure CLI ( az login ) 登录
    • 如果使用服务主体,请检查环境变量
    • 验证 Azure 帐户是否具有必要的权限
  2. 连接问题
    • 验证 Claude Desktop 配置
    • 检查配置文件中的路径是否符合您的安装
    • 确保没有其他实例正在运行
  3. 常见错误
    • NO_TENANT :使用“select-tenant”工具选择租户
    • NO_CLIENTS :确保正确的初始化和身份验证
    • CODE_EXECUTION_FAILED :检查 Azure 权限和连接

贡献

欢迎贡献代码!欢迎提交 Pull 请求。

贡献者

致谢

  • Claude Desktop 团队负责 MCP 实施
  • Azure SDK 团队提供全面的 SDK
  • 用于实现 AI 服务集成的模型上下文协议

安全说明

此实现遵循 Azure 安全最佳实践:

  • 没有硬编码凭证
  • 安全凭证链实施
  • 正确的错误处理和清理

对于安全问题或漏洞,请创建问题。

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

通过 Claude Desktop 实现与 Azure 服务的自然语言交互,支持资源管理、订阅处理和租户选择以及安全身份验证。

  1. Features
    1. Prerequisites
      1. Installation
        1. Manual Installation
      2. Authentication
        1. Usage
          1. Example Conversation
        2. Development
          1. Project Structure
          2. Key Components
        3. Troubleshooting
          1. Contributing
            1. Contributors
              1. Acknowledgments
                1. Security Note
                  ID: 8lqipo67ap