Azure MCP 服务器使用模型上下文协议(MCP)来标准化 AI 应用与外部工具和数据源之间的集成,使 AI 系统能够执行对上下文敏感的操作,并且能够识别和处理您的 Azure 资源。
本文介绍如何完成以下任务:
- 安装和向 Azure MCP 服务器进行身份验证
- 使用 Cline 的 AI 驱动的助手连接到 Azure MCP 服务器
- 运行提示以测试 Azure MCP 服务器作并与 Azure 资源交互
先决条件
安装 Azure MCP 服务器
若要在 Cline 中安装和配置 Azure MCP 服务器,请执行以下作:
在编辑器中打开 Cline 面板。
选择“ 管理 MCP 服务器 ”以打开 MCP 服务器 浮出控件,然后选择 “设置” 图标。
在面板的 MCP 服务器 部分中,选择“ 配置 MCP 服务器 ”以打开
cline_mcp_settings.json文件进行编辑。将以下配置添加到
mcpServersJSON 对象:"Azure MCP Server": { "command": "npx", "args": [ "-y", "@azure/mcp@latest", "server", "start" ] }
选择 “完成 ”以关闭配置面板并返回到聊天界面。
向 Azure 进行身份验证
Azure MCP 服务器使用 Azure 帐户和 Microsoft Entra ID 提供无缝身份验证体验。 若要使用 Azure MCP 服务器,必须先使用 Azure CLI、Azure 开发人员 CLI、Visual Studio 或 Visual Studio Code 等本地开发工具向 Azure 进行身份验证。 Azure MCP 服务器会自动发现这些工具中的凭据,并使用这些凭据向 Azure 服务进行身份验证。
例如,若要使用 Azure CLI 登录:
az login运行以下命令来验证身份验证状态,以查看当前登录的帐户和订阅:
az account show确保用户帐户具有要与之交互的 Azure 服务的适当角色分配。 要通过 Azure MCP 服务器访问的 Azure 资源必须已存在于 Azure 订阅中。 例如,常见的角色分配包括:
- Blob 存储数据贡献者 - 在存储帐户中读取和写入 Blob 数据。
- 存储帐户参与者 - 管理存储帐户配置。
- 参与者 - 订阅中的常规资源管理。
- 读取者 - 对 Azure 资源的只读访问权限。
有关角色分配和本地开发身份验证的详细信息,请参阅 在本地开发期间向 Azure 服务验证 .NET 应用。
使用提示测试 Azure MCP 服务器
在 Cline 聊天面板中,输入使用 Azure MCP 服务器功能的提示,例如:
List my Azure storage accounts如果系统提示你向 Azure 进行身份验证,请运行建议的身份验证工具以通过浏览器登录。
注释
如果已通过其他本地工具(如 Azure CLI)进行身份验证,Cline 不会提示你登录到 Azure。
Cline 会提示运行工具来检索存储帐户,例如
storage account list。 选择 “运行”工具 以继续。输出应类似于以下文本:
The following resource groups are available for your subscription: 1. **DefaultResourceGroup-EUS** (Location: `eastus`) 2. **rg-testing** (Location: `centralus`) 3. **rg-azd** (Location: `eastus2`) 4. **msdocs-sample** (Location: `southcentralus`) 5. **ai-testing** (Location: `eastus2`) Let me know if you need further details or actions related to any of these resource groups!使用其他相关提示探索更多 Azure MCP作,例如:
List all of the storage accounts in my subscription Get the available tables in my storage accounts Show me the configuration of my App Service instances