Azure MCP 伺服器使用 Model Context Protocol(MCP)來標準化 AI 應用程式與外部工具及資料來源之間的整合,讓 AI 系統能執行對 Azure 資源具上下文感知的操作。
在本文中,您將瞭解如何完成下列工作:
- 安裝並認證至 Azure MCP 伺服器
- 透過使用 Google Antigravity 的代理優先開發環境連接 Azure MCP 伺服器
- 執行提示以測試 Azure MCP 伺服器操作並與 Azure 資源互動
先決條件
- 具有有效訂閱的 Azure 帳戶
- Google Antigravity 已安裝
- Node.js 已安裝 LTS
安裝 Azure MCP 伺服器
要在 Google Antigravity 安裝並設定 Azure MCP 伺服器:
在編輯的代理人側面板中,選擇 ......>MCP 伺服器>管理 MCP 伺服器。
在 管理 MCP 中,選擇 「檢視原始設定 」以開啟
mcp_config.json該檔案進行編輯。Antigravity 從以下地點讀取 MCP 伺服器設定:
-
~/.gemini/config/mcp_config.json以全局配置伺服器,涵蓋所有工作空間。 -
.agents/mcp_config.json只針對目前的工作區設定伺服器。
-
在檔案中的
mcp_config.json物件中新增以下設定mcpServers:{ "mcpServers": { "azure-mcp": { "command": "npx", "args": [ "-y", "@azure/mcp@latest", "server", "start" ] } } }欲了解更多資訊,請參閱 Google 反重力 MCP 文件。
向 Azure 驗證
Azure MCP Server 透過 Azure 帳號與 Microsoft Entra ID 提供無縫的認證體驗。 要使用 Azure MCP Server,首先透過本地開發工具如 Azure CLI、Azure Developer CLI、Visual Studio 或 Visual Studio Code 來認證 Azure。 Azure MCP 伺服器會自動從這些工具中發現你的憑證,並用它們來驗證 Azure 服務。
例如,若要使用 Azure CLI 登入:
az login執行下列命令來驗證您的驗證狀態,以查看您目前登入的帳戶和訂用帳戶:
az account show確保你的使用者帳號有針對你想互動的 Azure 服務所設定的適當角色分配。 你打算透過 Azure MCP Server 存取的 Azure 資源,必須已經存在於你的 Azure 訂閱中。 例如,常見的角色指派包括:
- Blob 儲存體資料貢獻者 - 讀取和寫入儲存體帳戶中的 Blob 資料。
- 儲存體帳戶參與者 - 管理儲存體帳戶設定。
- 貢獻者 - 跨訂用帳戶的全面資源管理。
- Reader - 唯讀存取Azure資源。
欲了解更多關於角色指派與本地開發認證的資訊,請參閱 在本地開發期間驗證 .NET 應用程式到 Azure 服務。
使用提示來測試 Azure MCP 伺服器
在 Google Antigravity 裡面打開代理人側面板。
輸入一個使用 Azure MCP Server 功能的提示,例如:
List my Azure storage accounts如果系統提示你要驗證到 Azure,請使用建議的認證工具透過瀏覽器登入。
Note
如果你已經透過其他本地工具(如 Azure CLI)認證,Antigravity 不會提示你登入 Azure。
Antigravity 會提示你允許執行一個或多個 Azure MCP Server 工具來取得儲存帳號,例如
storage account list。 選取所需的允許動作以繼續。輸出內容類似以下文字:
The following storage accounts are available in your subscription: 1. **sttesting001** (Resource group: `rg-testing`, Location: `centralus`) 2. **stazddeploy** (Resource group: `rg-azd`, Location: `eastus2`) 3. **stmsdocssample** (Resource group: `msdocs-sample`, Location: `southcentralus`) 4. **staitesting** (Resource group: `ai-testing`, Location: `eastus2`) Let me know if you need further details or actions related to any of these storage accounts!透過使用其他相關提示,探索更多 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