Eclipse 中的 Azure MCP 服务器入门

Azure MCP 服务器使用模型上下文协议(MCP)来标准化 AI 应用与外部工具和数据源之间的集成,使 AI 系统能够执行对上下文敏感的操作,并且能够识别和处理您的 Azure 资源。

本文介绍:

  • 使用 Azure MCP 服务器安装和进行身份验证
  • 在 Eclipse 的 AI 开发环境中连接到 Azure MCP 服务器
  • 运行提示以测试操作并与 Azure 资源进行交互

先决条件

  • 具有活动订阅的 Azure 帐户
  • Eclipse - AI 提供支持的代码编辑器
  • GitHub Copilot 插件

向 Azure 进行身份验证

Azure MCP 服务器使用 Azure 帐户和 Microsoft Entra ID 提供无缝身份验证体验。 若要使用 Azure MCP 服务器,必须先使用 Azure CLI、Azure 开发人员 CLI、Visual Studio 或 Visual Studio Code 等本地开发工具向 Azure 进行身份验证。 Azure MCP 服务器会自动发现这些工具中的凭据,并使用这些凭据向 Azure 服务进行身份验证。

  1. 例如,若要使用 Azure CLI 登录:

    az login
    
  2. 运行以下命令来验证身份验证状态,以查看当前登录的帐户和订阅:

    az account show
    
  3. 确保用户帐户具有要与之交互的 Azure 服务的适当角色分配。 要通过 Azure MCP 服务器访问的 Azure 资源必须已存在于 Azure 订阅中。 例如,常见的角色分配包括:

    • Blob 存储数据贡献者 - 在存储帐户中读取和写入 Blob 数据。
    • 存储帐户参与者 - 管理存储帐户配置。
    • 参与者 - 订阅中的常规资源管理。
    • 读取者 - 对 Azure 资源的只读访问权限。

    有关角色分配和本地开发身份验证的详细信息,请参阅 在本地开发期间向 Azure 服务验证 .NET 应用

安装 Azure MCP 服务器

在 Eclipse 中安装和配置 Azure MCP 服务器:

  1. 转到 帮助 > Eclipse Marketplace

  2. Eclipse 市场窗口中搜索 Azure 工具包

  3. 在搜索结果中,选择“安装 Azure 工具包

    Eclipse 市场的屏幕截图,其中显示了 Azure 工具包安装选项。

    注释

    在安装过程中,请确保 GitHub Copilot 和 GitHubCopilot – 夜间 插件都更新到其最新版本。

  4. 在“ 确认所选功能 ”窗口中,检查是否选择了 用于 Eclipse 的 Azure MCP 服务器

  5. 选择 “确认”,并等待插件安装。 安装完成后,Eclipse 将重启。

    “确认所选功能”窗口的屏幕截图,其中选择了“用于 Eclipse 的 Azure MCP 服务器”。

验证并测试 Azure MCP 服务器

安装 Azure 工具包后,请在 Copilot 中批准 Azure MCP 服务器注册。

  1. 在 Copilot 聊天窗格中,选择 “工具” 图标,然后选择 找到的新 MCP 服务器 - 需要审批

    Eclipse 中 Copilot 聊天窗格工具图标的屏幕截图。

  2. 在“ 确认 MCP 服务器注册 ”窗口中,选择“Azure MCP 服务器”行,然后选择“ 批准”。

    “确认 MCP 服务器注册”窗口的屏幕截图,其中已选择“Azure MCP 服务器并批准”选项。

  3. 在 Copilot 聊天窗格中,再次选择 “工具” 图标以打开首选项窗口。

  4. 检查用于 Eclipse 的 Azure MCP 服务器是否显示在 MCP 工具 部分中。

    MCP 工具部分的屏幕截图,显示 Azure MCP Server for Eclipse 在列表中。

使用提示测试 Azure MCP 服务器

  1. 在 Copilot 聊天面板中,输入使用 Azure MCP 服务器功能的提示,如下所示。

    List my Azure resource groups
    

    注释

    还可以要求 Copilot 直接使用带有语言的 Azure MCP 服务器工具: 使用 Azure MCP 服务器列出我的 Azure 资源组。

  2. 当 Eclipse 提示运行该工具 azuremcp/group_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!
    
  3. 通过如下所示的提示探索更多 Azure MCP操作。

    List all storage accounts in my subscription
    List available tables in my storage accounts
    Show the configuration of my App Service instances
    

后续步骤