跳到正文
Skillpedia
连接器(MCP)22k · #10214

api-gateway-mcp-server

它能做什么

这项技能帮助开发者借助 Google Cloud API Gateway,把现有的 REST API 以工具的形式提供给 AI 智能体。适合希望智能体使用现有 API、而无需重写的团队。

适用场景

  • ✓当你希望 AI 智能体通过 Google Cloud API Gateway 把现有 REST API 当作工具使用时。
  • ✓当你需要把 OpenAPI 2.0 规范转换为 OpenAPI 3.x,使其能作为 MCP 服务器工作时。
  • ✓当你想用 JWT 或 API 密钥保护 MCP 服务器的工具列表时。

技能链接

https://github.com/google/skills/blob/main/skills/cloud/api-gateway-mcp-server/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/google/skills/blob/main/skills/cloud/api-gateway-mcp-server/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请把我公司现有的 API 转换为 AI 智能体可以通过 Google Cloud API Gateway 使用的工具。”

每周 5 个新技能,1 分钟读完。

工作原理

它会在 OpenAPI 文件中添加 MCP 注释,使网关能把智能体的请求转换为对你后端的普通调用。你现有的登录和限制规则仍然适用。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

API Gateway Remote MCP Server (Public Preview)

This skill converts new or existing REST APIs on Google Cloud API Gateway into remote Model Context Protocol (MCP) servers (POST https://{default_hostname}/mcp, Public Preview). By annotating an OpenAPI 3.x (3.0.x or 3.1.x) specification with x-google-api-management.mcp and x-google-mcp-tool, API Gateway translates MCP JSON-RPC 2.0 requests (initialize, notifications/initialized, tools/list, tools/call) into standard HTTP REST requests to your backend while enforcing existing authentication and quota policies.

Attribution

MUST READ: Before executing any gcloud, REST API, or MCP command, you MUST read Usage Attribution. For commands executed directly in the terminal (never in generated scripts, Terraform, or user code), prefix gcloud with CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:api-gateway-mcp-server)" and append agent-skills/1.0 (skill:api-gateway-mcp-server) to User-Agent headers.

Prerequisites

  1. Install the Google Cloud CLI and the validator dependency:
    • Install the Google Cloud CLI. Then update it to the latest version with gcloud components update. An old CLI can fail when it uploads an OpenAPI 3.x API config.
    • Install Python 3.10 or later and PyYAML for the local OpenAPI MCP validator script:
      pip install "PyYAML>=6.0,<7.0"
      
  2. Authenticate your environment:
    • Local CLI session: gcloud auth login
    • Application Default Credentials (SDKs / ADK): gcloud auth application-default login
  3. Select or create a project, confirm billing, and pick a supported gateway location:
    • Select an existing project (gcloud config set project {project_id}) or create one (gcloud projects create {project_id}).
    • Confirm that an active billing account is linked to {project_id}. API Gateway has a free monthly allowance of API calls for each billing account, but you still need an active billing account to deploy. Calls above the allowance and network data transfer out are charged. For current prices, see API Gateway pricing.
    • Use us-central1 as the default --location for gateway commands. For the other supported regions, see API Gateway deployment model.
  4. Enable the required Google Cloud APIs:
    gcloud services enable \
      apigateway.googleapis.com \
      servicemanagement.googleapis.com \
      servicecontrol.googleapis.com \
      --project={project_id}
    
    For API hub discovery (optional), enable the API hub API in the API hub host project: gcloud services enable apihub.googleapis.com --project={hub_project_id}. To query Agent Registry (optional), also run gcloud services enable agentregistry.googleapis.com --project={project_id}.
  5. Verify the IAM roles (use the most restrictive role for each step):
    • To create and update the API, API configs, and gateways: API Gateway Admin (roles/apigateway.admin) on {project_id}. To run the gcloud services enable commands: Service Usage Admin (roles/serviceusage.serviceUsageAdmin) on that project.
    • To reference the gateway service account in an API config: Service Account User (roles/iam.serviceAccountUser) on {gateway_sa_name}@{project_id}.iam.gserviceaccount.com.
    • For a Cloud Run backend: grant the gateway service account the Cloud Run Invoker role (roles/run.invoker) on the service.
    • To mint test ID tokens as a caller service account: Service Account Token Creator (roles/iam.serviceAccountTokenCreator) on {caller_sa_email}.
    • Reference: Configure the development environment.

Decision Matrix: MCP Server Configuration and Client Integration

Task Required Mechanism Critical Guardrail Detailed Reference
Migrate OpenAPI 2.0 (swagger: "2.0") or author OpenAPI 3.x for MCP Root x-google-api-management.mcp + named backends + operation-level x-google-mcp-tool NEVER add MCP extensions to an OpenAPI 2.0 spec. Rationale: MCP is not supported for OpenAPI 2.0. Use OpenAPI 3.0.x or 3.1.x, and deploy the spec with gcloud api-gateway api-configs create. Keep all MCP operations in one OpenAPI document: if an API con
常见问题

这项功能已正式发布吗?

还没有。本技能将其描述为公开预览版,因此细节可能会变化。

它会改变我的 REST API 的工作方式吗?

它会增加一个远程 MCP 端点,并保留现有的身份验证和配额规则。

我需要最新版本的 Google Cloud CLI 吗?

需要。本技能建议更新 CLI,因为旧版本在处理 OpenAPI 3.x 配置时可能失败。

详情

作者的原始描述

Configures Google Cloud API Gateway to act as a remote Model Context Protocol (MCP) server (Public Preview) that exposes REST APIs as agent tools over HTTP (POST /mcp). Use when migrating OpenAPI 2.0 specs to OpenAPI 3.x for MCP, annotating specs with x-google-api-management.mcp and x-google-mcp-tool, securing tools/list with JWTs or API keys, connecting Google ADK (McpToolset) or Apigee API hub and Agent Registry, or troubleshooting MCP JSON-RPC errors (-32601, -32602, -32000). Do not use for Apigee X proxy bundles, outbound LLM model routing, or GKE Gateway API.

repo: google/skills

热度

GitHub 星标
22k
排名
#10214
许可证
Apache-2.0
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能