Loading...
Loading...
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.
npx skill4agent add google/skills api-gateway-mcp-serverPOST https://{default_hostname}/mcpx-google-api-management.mcpx-google-mcp-toolinitializenotifications/initializedtools/listtools/callgcloud components updatePyYAMLpip install "PyYAML>=6.0,<7.0"gcloud auth logingcloud auth application-default logingcloud config set project {project_id}gcloud projects create {project_id}{project_id}us-central1--locationgcloud services enable \
apigateway.googleapis.com \
servicemanagement.googleapis.com \
servicecontrol.googleapis.com \
--project={project_id}gcloud services enable apihub.googleapis.com --project={hub_project_id}gcloud services enable agentregistry.googleapis.com --project={project_id}roles/apigateway.admin{project_id}gcloud services enableroles/serviceusage.serviceUsageAdminroles/iam.serviceAccountUser{gateway_sa_name}@{project_id}.iam.gserviceaccount.comroles/run.invokerroles/iam.serviceAccountTokenCreator{caller_sa_email}| Task | Required Mechanism | Critical Guardrail | Detailed Reference |
|---|---|---|---|
Migrate OpenAPI 2.0 ( | Root | 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 | OpenAPI 2.0 to 3.x Migration |
| Optimize tool names, descriptions, and schemas for LLM tool selection | | Every operation MUST have an | OpenAPI Agent Tool Optimizer |
Secure | | | OpenAPI 2.0 to 3.x Migration |
Connect Google ADK ( | | No separate registration step is needed. After you attach the API Gateway project to API hub, the MCP server appears in API hub as | ADK and API Hub Discovery |
Verify | | Keep | MCP Verification and Troubleshooting |
openapi3.0.4x-google-allowx-google-api-management.backendsjwtAudiencedisableAuthx-google-api-management.mcp.tools-list.securitysecurityx-google-mcp-toolx-google-mcp-tool: falsex-google-mcp-tool: falsetools/listsecuritysecurityhttps://{default_hostname}/mcpserversGETPOSTPUTPATCHDELETEtype: ["string", "null"]HTTP 204x-google-api-management.metricsFailed to call Service Control Quotascripts/validate_mcp_openapi.py{candidate_openapi_spec}python3 scripts/validate_mcp_openapi.py --spec={candidate_openapi_spec}scripts/validate_mcp_openapi.py1status: "FAIL"{candidate_openapi_spec}x-google-allowx-google-mcp-tooloperationIdx-google-tools-list.securityoauth2apiKeytools-list.securitysecurityx-google-model-router0status: "PASS"2HTTP 204mcpgcloud api-gateway apis create {api_id} --project={project_id}
gcloud api-gateway api-configs create {config_id} \
--api={api_id} \
--openapi-spec={candidate_openapi_spec} \
--backend-auth-service-account={gateway_sa_name}@{project_id}.iam.gserviceaccount.com \
--project={project_id}
gcloud api-gateway gateways update {gateway_id} \
--api={api_id} \
--api-config={config_id} \
--location={region} \
--project={project_id}
gcloud services enable $(gcloud api-gateway apis describe {api_id} --project={project_id} --format="value(managedService)") --project={project_id}gcloud api-gateway gateways create {gateway_id} ...gateways updateapi-configs createhttps://{default_hostname}/mcpservers404 Page not foundACTIVEThe current request is not defined by this API.tools/listx-google-auth.audiencesgcloud auth print-identity-token --impersonate-service-account={caller_sa_email} --audiences={jwt_audience}tools/listx-api-keyinitializenotifications/initializedtools/listtools/callMcpToolset{your_api} (MCP)openapi: 3.0.x3.1.xswagger: "2.0"x-google-allowx-google-model-routerpython3 scripts/validate_mcp_openapi.py --spec={candidate_openapi_spec}status: "PASS"0operationIdx-google-api-management.mcp.tools-list.securityoauth2x-google-authsecurityapiKeyin: headername: x-api-keytools/listsecurityHTTP 204x-google-mcp-tool: falsehttps://{default_hostname}/mcp{basepath}/mcptools/callparams.arguments.bodyMCP-Protocol-Version: 2025-11-25gcloud api-gateway gateways delete {gateway_id} --location={region} --project={project_id}
gcloud api-gateway api-configs delete {config_id} --api={api_id} --project={project_id}
gcloud api-gateway apis delete {api_id} --project={project_id}
gcloud iam service-accounts delete {gateway_sa_name}@{project_id}.iam.gserviceaccount.com --project={project_id}