設定 MCP

本文說明如何使用 Google Security Operations 遠端 Model Context Protocol (MCP) 伺服器,連線至 AI 應用程式,包括 Gemini CLI、ChatGPT、Claude,以及您開發的自訂應用程式。啟用 Google Security Operations API 時,系統會啟用 Google Security Operations 遠端 MCP 伺服器。

Model Context Protocol (MCP) 規範大型語言模型 (LLM) 和 AI 應用程式/代理程式連結外部資料來源的標準方式。MCP 伺服器可讓您使用工具、資源和提示,從後端服務執行動作及取得更新資料。

本機和遠端 MCP 伺服器有何不同?

本機 MCP 伺服器
通常在本機電腦上執行,並使用標準輸入和輸出串流 (stdio),在同一部裝置上的服務之間進行通訊。
遠端 MCP 伺服器
在服務的基礎架構上執行,並為 AI 應用程式提供 HTTP 端點,供 AI MCP 用戶端與 MCP 伺服器之間的通訊。如要進一步瞭解 MCP 架構,請參閱 MCP 架構

Google 和 Google Cloud 遠端 MCP 伺服器

Google 和 Google Cloud 遠端 MCP 伺服器具有下列功能和優點:

  • 簡化集中式探索作業
  • 代管全域或區域 HTTP 端點
  • 精細授權
  • 使用 Model Armor 保護機制,選擇性確保提示詞和回覆安全無虞
  • 集中式稽核記錄

如要瞭解其他 MCP 伺服器,以及 Google Cloud MCP 伺服器適用的安全性與控管措施,請參閱 Google Cloud MCP 伺服器總覽

事前準備

  1. 登入 Google Cloud 帳戶。如果您是 Google Cloud新手,歡迎 建立帳戶,親自評估產品在實際工作環境中的成效。新客戶還能獲得價值 $300 美元的免費抵免額,可用於執行、測試及部署工作負載。
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  4. Verify that billing is enabled for your Google Cloud project.

  5. Enable the Chronicle API.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

  6. 安裝 Google Cloud CLI。

  7. 若您採用的是外部識別資訊提供者 (IdP),請先使用聯合身分登入 gcloud CLI

  8. 執行下列指令,初始化 gcloud CLI:

    gcloud init
  9. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  10. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  11. Verify that billing is enabled for your Google Cloud project.

  12. Enable the Chronicle API.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

  13. 安裝 Google Cloud CLI。

  14. 若您採用的是外部識別資訊提供者 (IdP),請先使用聯合身分登入 gcloud CLI

  15. 執行下列指令,初始化 gcloud CLI:

    gcloud init

必要的角色

如要取得使用 Google SecOps 遠端 MCP 伺服器所需的權限,請要求管理員在您要使用 Google SecOps MCP 伺服器的專案中,授予下列 IAM 角色:

  • 發出 MCP 工具呼叫: MCP 工具使用者 (roles/mcp.toolUser)
  • 存取 Chronicle API 服務: Chronicle API 管理員 (roles/chronicle.admin)
  • 授予 Google SecOps 管理員存取權: Chronicle SOAR 管理員 (roles/chronicle.soarAdmin)
  • 選用: 設定自訂 IAM 角色,並授予 MCP 工具呼叫 Chronicle API 方法時所需的權限。

如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。

這些預先定義的角色具備使用 Google SecOps 遠端 MCP 伺服器所需的權限。如要查看確切的必要權限,請展開「Required permissions」(必要權限) 部分:

所需權限

如要使用 Google SecOps 遠端 MCP 伺服器,必須具備下列權限:

  • 發出 MCP 工具呼叫: mcp.tools.call

您或許還可透過自訂角色或其他預先定義的角色取得這些權限。

驗證及授權

Google Security Operations 遠端 MCP 伺服器會使用 OAuth 2.0 通訊協定搭配身分與存取權管理 (IAM) 進行驗證及授權。所有Google Cloud 身分都支援 MCP 伺服器的驗證。

Google SecOps MCP OAuth 範圍

OAuth 2.0 會使用範圍和憑證,判斷經過驗證的主體是否有權對資源執行特定動作。如要進一步瞭解 Google 的 OAuth 2.0 範圍,請參閱「使用 OAuth 2.0 存取 Google API」。

Google SecOps 具有下列 MCP 工具 OAuth 範圍:

gcloud CLI 的範圍 URI 說明
https://www.googleapis.com/auth/chronicle 有權讀取及修改資料。

設定 MCP 用戶端,以便使用 Google SecOps MCP 伺服器

AI 應用程式和代理 (例如 Claude 或 Antigravity) 可以例項化 MCP 用戶端,並連至單一 MCP 伺服器。AI 應用程式可有多個連線至不同 MCP 伺服器的用戶端。如果您的應用程式未列在特定用戶端指南中,則可以使用下列資訊,從大多數應用程式連線。

在 AI 應用程式中,尋找新增或連線至遠端 MCP 伺服器的方法。 針對 Google SecOps MCP 伺服器,請視需要輸入下列資訊:

  • 伺服器名稱:Google SecOps MCP 伺服器
  • 「伺服器網址」或「端點」:選取區域端點,並在結尾加上 /mcp。例如:https://us-chronicle.googleapis.com/mcp
  • 傳輸:HTTP
  • 驗證詳細資料:視驗證方式而定,您可以輸入 Google Cloud 憑證、OAuth 用戶端 ID 和密鑰,或是代理程式身分和憑證。如要進一步瞭解驗證,請參閱「向 MCP 伺服器進行驗證」。
  • OAuth 範圍:連線至 Google SecOps MCP 伺服器時要使用的 OAuth 2.0 範圍。如果是 Google SecOps,請使用 https://www.googleapis.com/auth/chronicle

重新導向 URI

如果是網頁應用程式和部分桌面應用程式,您必須在建立驗證用的用戶端 ID 和密鑰時,將重新導向 URI 加入允許清單。授權伺服器會使用重新導向 URI 將權杖傳送至應用程式。應用程式的說明文件應指定您必須使用的重新導向 URI。系統不支援自訂重新導向 URI

如需設定及連線至 MCP 伺服器的應用程式專屬指引,請參閱用戶端專屬指引

如需更多一般指引,請參閱下列資源:

設定 Antigravity 使用 Google SecOps MCP 伺服器

您可以設定 Google Antigravity (包括電腦版 IDE 和 CLI),連線至 Google SecOps MCP 伺服器。

設定共用 MCP 設定檔

Antigravity 會為所有 MCP 伺服器使用共用設定檔。

  1. 在文字編輯器中開啟共用的 MCP 設定檔 ~/.gemini/config/mcp_config.json
  2. 將 Google SecOps MCP 伺服器設定新增至 mcpServers 物件:

    {
      "mcpServers": {
        "google-cloud-secops": {
          "serverUrl": "https://us-chronicle.googleapis.com/mcp",
          "authProviderType": "google_credentials",
          "oauth": {
            "scopes": [
              "https://www.googleapis.com/auth/cloud-platform"
            ]
          },
          "timeout": 300000
        }
      }
    }
    

    https://us-chronicle.googleapis.com/mcp 替換為 Google SecOps 執行個體的適當區域端點

設定租戶專屬內容

Google SecOps MCP 伺服器需要額外內容:customer_idproject_idregion。在 Antigravity 中,您可以使用工作區專屬設定來管理這項功能。

  1. 為租戶建立專屬工作區目錄 (例如 ~/workspace/secops/tenant-a/)。
  2. 在該目錄中,建立名為 secops_tenant.json 的設定檔,並加入下列內容:

    {
      "customer_id": "YOUR_CUSTOMER_ID",
      "project_id": "YOUR_PROJECT_ID",
      "region": "YOUR_REGION"
    }
    

    YOUR_CUSTOMER_IDYOUR_PROJECT_IDYOUR_REGION 替換為實際的租戶詳細資料。區域必須為小寫 (例如 useu)。

使用設定

您可以在 Antigravity CLI 或桌面 IDE 中使用設定。

在 Antigravity CLI 中

  1. 在終端機中,前往您建立的工作區目錄:

    cd ~/workspace/secops/tenant-a/
    
  2. 啟動 Antigravity CLI:

    agy
    

    CLI 會在啟動時自動從 secops_tenant.json 載入內容。

  3. 在 CLI 中執行 /mcp 指令,查看有效工具來驗證設定。如果無法順利載入脈絡,您可以在 ~/.gemini/antigravity-cli/log/ 中使用 Antigravity CLI 記錄進行偵錯。

在 Antigravity 電腦版 IDE 中

  1. 開啟 Antigravity 電腦版應用程式。
  2. 建立新專案,然後選取您建立的工作區資料夾 (內含 secops_tenant.json)。
  3. 發起新對話。代理程式將可存取具有正確租戶環境的 Google SecOps MCP 工具。

設定 Gemini Enterprise,以便使用 Google SecOps MCP 伺服器

您可以使用自訂 MCP 資料存放區,將 Google SecOps 與 Gemini Enterprise 整合。使用者可直接在 Gemini Enterprise 主對話中查詢 Google SecOps。

必要條件

  1. 確認 Google SecOps 執行個體已啟用遠端 MCP 伺服器。
  2. 確認機構政策不會禁止建立自訂 MCP 伺服器。

步驟 1:設定 OAuth 2.0 網路應用程式

您必須在與 Google SecOps 執行個體相關聯的 Google Cloud 專案中,建立 OAuth 2.0 網頁應用程式。

  1. 在 Google Cloud 控制台中,依序前往「API 和服務」>「憑證」
  2. 按一下「建立憑證」,然後選取「OAuth 用戶端 ID」
  3. 將應用程式類型設為「Web application」(網頁應用程式)
  4. 輸入用戶端名稱 (例如 Gemini Enterprise SecOps MCP)。
  5. 在「已授權的重新導向 URI」下方,新增下列網址:
    • https://vertexaisearch.cloud.google.com/oauth-redirect
    • https://vertexaisearch.cloud.google.com/static/oauth/oauth.html
  6. 點按「建立」並儲存產生的「用戶端 ID」和「用戶端密鑰」

步驟 2:在 Gemini Enterprise 中新增 Google SecOps 資料存放區

管理員必須全域設定自訂 MCP 連接器。

  1. 開啟 Gemini Enterprise 並前往應用程式,或建立新的應用程式。
  2. 前往「連結的資料儲存庫」,然後點選「新增資料儲存庫」
  3. 選取「自訂 MCP」,並輸入下列詳細資料:
    • MCP 伺服器網址:選取區域端點,並在結尾加上 /mcp (例如 https://us-chronicle.googleapis.com/mcp)。
    • 授權網址https://accounts.google.com/o/oauth2/v2/auth
    • 權杖網址https://oauth2.googleapis.com/token
    • 「Client ID」(用戶端 ID):輸入步驟 1 中的用戶端 ID。
    • 用戶端密鑰:輸入步驟 1 中的用戶端密鑰。
    • 「OAuth Scopes」(OAuth 範圍):輸入 https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/chronicle (以半形空格分隔)。
  4. 儲存資料儲存庫 (例如命名為 Agentic SOC)。
  5. 在 Gemini Enterprise 應用程式中,選取「連結的資料儲存庫」,並確認已啟用新的資料儲存庫。
  6. 在選單中選取「動作」,然後按一下「重新載入自訂動作」
  7. 選取要為使用者啟用的動作,然後按一下「啟用動作」

步驟 3:在即時通訊中驗證連結器

每位使用者都必須授權 Gemini 代表自己存取 Google SecOps。

  1. 開啟主要的 Gemini Enterprise 對話。
  2. 在對話視窗底部找到已連結的資料儲存空間 (例如 Agentic SOC),然後將其切換為「開啟」
  3. 完成登入提示,授予必要的 OAuth 權限。

步驟 4:設定 Gemini 記憶體,提供背景資訊

為確保 Gemini 能正確傳送 API 呼叫,並提供必要的租戶環境,您必須將環境詳細資料儲存至 Gemini 的記憶體。

將下列提示詞傳送給 Gemini (請將預留位置值替換為實際資料):

Remember that for all Google SecOps and Agentic SOC queries, my Customer ID is [CUSTOMERID], my Region is [REGION], and my GCP Project ID is [PROJECTID].

Gemini 會確認已儲存這些詳細資料。

步驟 5:開始查詢

現在您可以在主聊天室中使用自然語言查詢 Google SecOps。例如:

  • 「使用 Agentic SOC 連接器,找出過去 3 天的登入嘗試。」
  • 「Summarize the latest open cases in SecOps.」(彙整 SecOps 中最新的未結案件)。

可用的工具

如要查看 Google SecOps MCP 伺服器可用的 MCP 工具詳細資料和說明,請參閱 Google SecOps MCP 參考資料

清單工具

使用 MCP 檢查器列出工具,或直接將 tools/list HTTP 要求傳送至 Google Security Operations 遠端 MCP 伺服器。tools/list 方法不需要驗證。

POST /mcp HTTP/1.1
Host: https://europe-west2-chronicle.googleapis.com
Content-Type: application/json

{
  "jsonrpc": "2.0",
  "method": "tools/list",
}

應用實例

以下是 Google SecOps MCP 伺服器的範例用途:

工具list_rule_errors

提示詞範例

List rule errors for the rule: ru_ddd45753-d749-4fee-b068-29072e750cfb

回覆

Here are the rule errors for ru_ddd45753-d749-4fee-b068-29072e750cfb:

Error Message: query took too long to execute, see https://cloud.google.com/chronicle/docs/detection/yara-l-best-practices for tips for optimizing rules; these optimization tips are applicable to various types of queries

Time Range: 2025-02-16T10:00:00Z to 2025-02-16T11:00:00Z
Rule: projects/935934211738/locations/US/instances/eb3b937b-3ab6-47e5-8185-24837b826691/rules/ru_ddd45753-d749-4fee-b068-29072e750cfb@v_1740004374_748943000
Error Message: query took too long to execute, see https://cloud.google.com/chronicle/docs/detection/yara-l-best-practices for tips for optimizing rules; these optimization tips are applicable to various types of queries

Time Range: 2025-02-16T11:00:00Z to 2025-02-16T12:00:00Z
Rule: projects/935934211738/locations/US/instances/eb3b937b-3ab6-47e5-8185-24837b826691/rules/ru_ddd45753-d749-4fee-b068-29072e750cfb@v_1740004374_748943000
The errors indicate that the queries for this rule took too long to execute during the specified time ranges. You may want to review the YARA-L best practices for optimizing rules.

工具create_rules

提示詞範例

Create the following rule:
successful_user_logins_from_outside_us_test {
meta:
author = "Google SecOps Gemini"
description = "Detect successful user logins originating from outside the United States."
severity = "Medium"
events:
$e.metadata.event_type = "USER_LOGIN"
$e.security_result.action = "ALLOW"
$e.principal.ip_geo_artifact.location.country_or_region != "United States"
outcome:
$user = array($e.principal.user.userid)
$source_ip = array($e.principal.ip)
$country = array($e.principal.ip_geo_artifact.location.country_or_region)
$city = array($e.principal.ip_geo_artifact.location.city)
condition:
$e
}

回覆

The rule successful_user_logins_from_outside_us_test has been successfully created with the following details:

Name: projects/935934211738/locations/US/instances/eb3b937b-3ab6-47e5-8185-24837b826691/rules/ru_cff9cae1-bb88-4456-b725-4c08f21803ed
Revision ID: v_1768208899_054095000
Display Name: successful_user_logins_from_outside_us_test
Author: Google SecOps Gemini
Description: Detect successful user logins originating from outside the United States.
Severity: Medium
Compilation State: SUCCEEDED
Create Time: 2026-01-12T09:08:19.054095Z

選用的安全防護設定

MCP 工具可執行各種動作,因此會帶來新的安全風險和考量。為盡量降低及管理這些風險,Google Cloud 提供預設和可自訂的政策,控管機構或專案中 MCP 工具的使用情形。 Google Cloud

如要進一步瞭解 MCP 安全性和控管措施,請參閱「AI 安全性」。

Model Armor

Model Armor 是一項Google Cloud 服務,旨在提升 AI 應用程式的安全性。這項功能會主動篩選 LLM 提示詞和回覆,防範各種風險並支援負責任的 AI 做法。無論您是在雲端環境或外部雲端供應商部署 AI,Model Armor 都能協助您防範惡意輸入、驗證內容安全性、保護敏感資料、維持法規遵循狀態,以及在多元的 AI 環境中,持續落實 AI 安全政策。

啟用 Model Armor 並啟用記錄功能後,Model Armor 會記錄整個酬載。這可能會導致記錄中出現私密資訊。

MCP 要求轉送至 Model Armor

Model Armor 僅在特定區域推出。啟用 Model Armor 後,如果您在 Model Armor 不支援的管轄區使用 MCP 伺服器,不同 MCP 伺服器的呼叫路徑行為可能不同,且可能會違反使用中和傳輸中資料的資料落地法規。如要進一步瞭解個別 MCP 伺服器的行為,請參閱「Model Armor 支援的產品」。

啟用 Model Armor

您必須先啟用 Model Armor API,才能使用 Model Armor。

控制台

  1. 啟用 Model Armor API。

    啟用 API 時所需的角色

    如要啟用 API,您必須具備 serviceusage.services.enable 權限。如果您建立了專案,可能已透過「擁有者」角色 (roles/owner) 取得這項權限。否則,您可以透過「服務使用情形管理員」角色 (roles/serviceusage.serviceUsageAdmin) 取得這項權限。瞭解如何授予角色

    啟用 API

  2. 選取要啟用 Model Armor 的專案。

gcloud

開始前,請使用 Google Cloud CLI 搭配 Model Armor API 執行下列步驟:

  1. 在 Google Cloud 控制台中啟用 Cloud Shell。

    啟用 Cloud Shell

    控制台底部會開啟 Cloud Shell 工作階段,並顯示指令列提示。 Google Cloud Cloud Shell 是已安裝 Google Cloud CLI 的殼層環境,並已針對您目前的專案設定好相關值。工作階段可能要幾秒鐘的時間才能初始化。

  2. 執行下列指令,為 Model Armor 服務設定 API 端點。

    gcloud config set api_endpoint_overrides/modelarmor "https://modelarmor.LOCATION.rep.googleapis.com/"

    LOCATION 替換為要使用 Model Armor 的區域。

設定 Google 和 Google Cloud 遠端 MCP 伺服器的防護功能

如要保護 MCP 工具呼叫和回應,可以使用 Model Armor 底限設定。底限設定會定義適用於整個專案的最低安全性篩選條件。這項設定會對專案中的所有 MCP 工具呼叫和回覆套用一致的篩選器。

設定 Model Armor 底限設定,並啟用 MCP 清理功能。詳情請參閱「設定 Model Armor 底價」。

請參閱下列指令範例:

gcloud model-armor floorsettings update \
--full-uri='projects/PROJECT_ID/locations/global/floorSetting' \
--enable-floor-setting-enforcement=TRUE \
--add-integrated-services=GOOGLE_MCP_SERVER \
--google-mcp-server-enforcement-type=INSPECT_AND_BLOCK \
--enable-google-mcp-server-cloud-logging \
--malicious-uri-filter-settings-enforcement=ENABLED \
--add-rai-settings-filters='[{"confidenceLevel": "MEDIUM_AND_ABOVE", "filterType": "DANGEROUS"}]'

PROJECT_ID 替換為 Google Cloud 專案 ID。

請注意下列設定:

  • INSPECT_AND_BLOCK:強制執行類型,可檢查 Google MCP 伺服器的內容,並封鎖符合篩選條件的提示和回應。
  • ENABLED:啟用篩選器或強制執行的設定。
  • MEDIUM_AND_ABOVE:負責任的 AI 技術 - 危險篩選器設定的信心水準。您可以修改這項設定,但較低的值可能會導致更多誤判。詳情請參閱「Model Armor 信心水準」。

停用使用 Model Armor 掃描 MCP 流量

如要停止 Model Armor 根據專案的底限設定,自動掃描往返 Google MCP 伺服器的流量,請執行下列指令:

gcloud model-armor floorsettings update \
  --full-uri='projects/PROJECT_ID/locations/global/floorSetting' \
  --remove-integrated-services=GOOGLE_MCP_SERVER

PROJECT_ID 替換為 Google Cloud 專案 ID。Model Armor 不會自動將這個專案底限設定中定義的規則,套用至任何 Google MCP 伺服器流量。

Model Armor 底限設定和一般設定的影響範圍不只 MCP,由於 Model Armor 會與 Vertex AI 等服務整合,因此您對底限設定所做的任何變更,都會影響所有整合服務 (不只是 MCP) 的流量掃描和安全行為。

使用 IAM 政策控管 MCP 使用情形

身分與存取權管理 (IAM) 拒絕政策允許政策可協助您保護 Google Cloud 和 Google MCP 伺服器。

您可以組合多項條件,根據下列項目允許或拒絕存取權,建立自訂的安全性和控管政策:

  • 本金。
  • 工具屬性,例如唯讀屬性。
  • 服務名稱或工具名稱。
  • 應用程式的 OAuth 用戶端 ID。

詳情請參閱「使用身分與存取權管理功能控管 MCP 使用情形」。

後續步驟

還有其他問題嗎?向社群成員和 Google SecOps 專業人員尋求解答。