使用 Knowledge Catalog 遠端 MCP 伺服器

本文說明如何使用 Knowledge Catalog 遠端 Model Context Protocol (MCP) 伺服器,連結 Antigravity、ChatGPT、Claude 等 AI 應用程式,以及您開發的自訂應用程式。Knowledge Catalog 遠端 MCP 伺服器可讓您與 Knowledge Catalog (舊稱 Dataplex Universal Catalog) 互動,探索資料資產、搜尋中繼資料,以及擷取項目詳細資料。啟用 Dataplex API 時,Dataplex API 遠端 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. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Dataplex API, if it is not already enabled.

    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

  5. 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

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

  7. Enable the Dataplex API, if it is not already enabled.

    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

必要的角色

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

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

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

所需權限

必須具備下列權限,才能使用 Knowledge Catalog MCP 伺服器:

  • serviceusage.mcppolicy.get
  • serviceusage.mcppolicy.update
  • 發出 MCP 工具呼叫:mcp.tools.call

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

驗證及授權

Dataplex API 遠端 MCP 伺服器使用 OAuth 2.0 通訊協定和 Identity and Access Management (IAM) 進行驗證和授權。所有Google Cloud 身分都支援 MCP 伺服器驗證。

建議您為使用 MCP 工具的代理建立獨立身分,以便控管及監控資源存取權。如要進一步瞭解驗證,請參閱「向 MCP 伺服器驗證」。

Knowledge Catalog 需要哪些 MCP OAuth 範圍?

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

Knowledge Catalog 具有下列 MCP 工具 OAuth 範圍:

gcloud CLI 的範圍 URI 說明
https://www.googleapis.com/auth/dataplex.readonly 僅允許讀取資料。
https://www.googleapis.com/auth/dataplex.read-write 可讀取及修改資料。

在工具呼叫期間存取的資源,可能需要額外的範圍。如要查看 Knowledge Catalog 所需的範圍清單,請參閱「Dataplex API」。

設定 MCP 用戶端,以便使用 Knowledge Catalog MCP 伺服器

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

在 AI 應用程式中,找出新增或連線至遠端 MCP 伺服器的方法。如果是 Knowledge Catalog MCP 伺服器,請視需要輸入下列資訊:

  • 伺服器名稱:Knowledge Catalog MCP 伺服器
  • 伺服器網址或端點:https://dataplex.googleapis.com/mcp (探索) 或 https://dataplex.googleapis.com/mcp/data-products (資料產品)
  • 傳輸:可串流 HTTP
  • 驗證詳細資料:視您要採用的驗證方式而定,您可以輸入 Google Cloud 憑證、OAuth 用戶端 ID 和密鑰,或代理身分和憑證。如要進一步瞭解驗證,請參閱「向 MCP 伺服器驗證」。
  • OAuth 範圍:連線至 Knowledge Catalog MCP 伺服器時要使用的 OAuth 2.0 範圍。

重新導向 URI

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

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

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

Knowledge Catalog 提供哪些 MCP 工具?

如要查看 Knowledge Catalog MCP 伺服器的可用 MCP 工具詳細資料和說明,請參閱「Knowledge Catalog MCP 參考資料」。

清單工具

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

curl -X POST https://dataplex.googleapis.com/TOOLSET_ENDPOINT \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/json' \
    -H 'MCP-Protocol-Version: MCP_PROTOCOL_VERSION' \
    -H 'Mcp-Method: tools/list' \
    -d '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "tools/list",
      "params": {
        "_meta": {
          "io.modelcontextprotocol/protocolVersion": "MCP_PROTOCOL_VERSION",
          "io.modelcontextprotocol/clientCapabilities": {
            "extensions": {
              "io.modelcontextprotocol/ui": {
                "mimeTypes": ["text/html;profile=mcp-app"]
              }
            }
          }
        }
      }
    }'

更改下列內容:

  • TOOLSET_ENDPOINT:服務名稱後方的 MCP 端點其餘部分。舉例來說,如果是 Knowledge Catalog,這可能是 mcp/toolset-name。
  • MCP_PROTOCOL_VERSION:MCP 通訊協定版本。例如:2026-07-28。

用途範例

Knowledge Catalog MCP 伺服器的應用實例,是在指定專案或組織中,找出符合搜尋條件的 Knowledge Catalog 項目。

提示範例

  • 「找出貴組織中與customer churn and retention相關的所有資料集,以便分析客戶行為」
  • 「在 marketing-analytics-prod 專案中搜尋與 marketing campaigns 相關的所有 BigQuery 資料表」
  • 「列出 test-project 中所有以資料集 test_dp 為資源的資料產品」
  • 「如何使用資料產品存取 test_dp dataset」
  • 「在 us-central1 的 test-project 中建立資料產品。命名為 test-data-product,並使用 cloudysanfrancisco@gmail.com 做為擁有者電子郵件」
  • 「將分析師存取權群組新增至 test-dp 中的資料資產 test-data-asset,並授予 BigQuery 管理員角色」
  • 「取得資料產品 test-dp 中資料資產 test-asset 的結構定義」

選用安全性和安全防護設定

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

如要進一步瞭解 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 所需的角色

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

    啟用 API

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

gcloud

開始之前,請按照下列步驟,搭配使用 Google Cloud CLI 和 Model Armor API:

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

    啟用 Cloud Shell

    Google Cloud 控制台底部會開啟 Cloud Shell 工作階段,並顯示指令列提示。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

Identity and Access Management (IAM) 拒絕政策和允許政策可協助您保護 Google Cloud 和 Google MCP 伺服器。

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

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

詳情請參閱「使用 Identity and Access Management 控管 MCP 使用情形」。

後續步驟