Model Context Protocol (MCP) 规范了大语言模型 (LLM) 以及 AI 应用或 智能体连接到外部数据源的方式。借助 MCP 服务器,您可以使用其工具、资源和提示来执行操作,并从其后端服务获取更新后的数据。
本地 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 服务器概览。
准备工作
- 登录您的 Google Cloud 账号。如果您是 Google Cloud的新用户, 请创建账号,以评估我们的产品在 实际场景中的表现。新客户还可获享 $300 赠金,用于 运行、测试和部署工作负载。
-
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
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.
Enable the Policy Analyzer API.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. 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.-
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
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.
Enable the Policy Analyzer API.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. 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.
所需的角色
如需获得使用 Policy Analyzer MCP 服务器所需的权限,请让您的管理员为您授予要在其中使用 Policy Analyzer MCP 服务器的项目中的以下 IAM 角色:
- Cloud Asset Viewer (
roles/cloudasset.viewer) -
如需使用自定义 IAM 角色分析政策:
Role Viewer (
roles/iam.roleViewer) -
如需使用 Google Cloud CLI 分析政策:
Service Usage Consumer (
roles/serviceusage.serviceUsageConsumer) -
进行 MCP 工具调用:
MCP Tool User (
roles/mcp.toolUser)
如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限。
这些预定义角色包含 使用 Policy Analyzer MCP 服务器所需的权限。如需查看所需的确切权限,请展开所需权限部分:
所需权限
使用 Policy Analyzer MCP 服务器需要以下权限:
-
cloudasset.assets.analyzeIamPolicy -
cloudasset.assets.searchAllResources -
cloudasset.assets.searchAllIamPolicies -
如需使用自定义 IAM 角色分析政策:
iam.roles.get -
如需使用 Google Cloud CLI 分析政策:
serviceusage.services.use -
进行 MCP 工具调用:
mcp.tools.call
您也可以使用自定义角色或其他