AI Development

How Google Cloud API Gateway Turns a REST Operation into an MCP Tool and Locks tools/list (2026)

About 15 min read

The gateway does not stand up a second MCP server. It accepts JSON-RPC on POST /mcp and translates tools/call into the original REST request. The model only fills arguments. What reaches the backend is the HTTP call the gateway built.

Before you read

Object Public fact as of 2026-10-21 How an agent uses it
API Gateway Public Preview on 11 September. OpenAPI 3.x extensions turn existing REST into a remote MCP server. OpenAPI 2.0 does not POST /mcp only. The backend still sees ordinary REST
x-google-mcp-tool Set on one operation. The default tool name is operationId. Names are unique and use only letters, digits, underscore, dot, and hyphen, length 1 to 128 Upload rejects an operation with no resolvable description. Set false to hide one
tools/list Unauthenticated by default. The 30 September release notes add an API key, as an alternative to JWT. The key is read only from the x-api-key header, not from the query string A list does not authorize a later call
tools/call Reuses that operation’s API key or JWT. Path and query parameters are top-level arguments. The request body must sit under body A protocol error is often HTTP 200 plus a JSON-RPC code

The configure page was last updated on 2026-10-13 and the feature is still Pre-GA. The 24 September post said an API key cannot protect tools/list. Follow the 30 September release note and the 13 October docs. orders.example.test, A-1042, and sk_demo_not_real are fictional.

The gateway turns selected REST operations into tools. Discovery and invocation do not share one key

On 11 September the API Gateway release notes opened MCP as a Public Preview. The 24 September developer post describes the path: annotate the OpenAPI spec you already deploy, and /mcp starts accepting JSON-RPC. The configure page still marked the feature Pre-GA on 13 October. The supported methods are initialize, notifications/initialized, tools/list, and tools/call. Resources, prompts, stdio, streaming, and long-running calls are outside this preview. One API config cannot enable both MCP and x-google-model-router.

  • Annotate: x-google-api-management.mcp: true exposes every eligible operation. The object form does the same. Hide an operation with x-google-mcp-tool: false.
  • Discover: tools/list is open unless you name exactly one scheme under tools-list.security, a JWT or an API key.
  • Call: tools/call uses the operation’s own auth. The gateway maps arguments onto path, query, body, and ordinary headers.

What tools/call looks like on the wire: how a coding agent calls MCP. The plugin-directory contract in plugin.json is a different document: the Agent Plugins directory contract. This piece only covers how API Gateway builds one call from an OpenAPI operation.

The handshake, a path argument, and a request body are three JSON bodies

The documented handshake is this body. Initialize is unauthenticated. Later requests should send MCP-Protocol-Version. If the header is missing, the gateway falls back to 2025-03-26. The sample version is the documented 2025-11-25. Do not copy the sample hostname from the docs. Use orders.example.test:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {
    "protocolVersion": "2025-11-25",
    "capabilities": {},
    "clientInfo": {
      "name": "demo-client",
      "version": "1.0.0"
    }
  }
}

Path and query parameters become top-level fields of arguments, keyed by the OpenAPI parameter name. The call below replaces the docs’ delete example with a read, get_order_status, and uses the fictional id A-1042. Why a required field cannot live only in the prompt: why AI needs JSON Schema.

{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "get_order_status",
    "arguments": {
      "orderId": "A-1042"
    }
  }
}

A request body does not sit at the top level. The docs nest it under a property named body. Headers also become top-level properties, and the gateway injects them on the backend call. You cannot bind reserved system headers or headers that start with x-google-. The operation name below is fictional. Only the nesting is from the docs:

{
  "jsonrpc": "2.0",
  "id": 4,
  "method": "tools/call",
  "params": {
    "name": "create_order",
    "arguments": {
      "body": {
        "orderId": "A-1042"
      }
    }
  }
}

The acknowledgement has no id. The documented notification is notifications/initialized, and the gateway answers HTTP 202. After a call, a backend application error is typically still HTTP 200 with result.isError set to true and the backend error in the body. Protocol errors are often HTTP 200 plus a JSON-RPC code. Do not read 200 as proof that the order was found.

Three methods, three auth rules, three status readings

An agent will treat a successful connection as permission to change data:

What you see What it means
initialize Unauthenticated. It only negotiates the protocol version. After it succeeds, send the initialized notification, which has no id.
tools/list Open by default. After you add security, name exactly one scheme that already exists. An API key must be in the x-api-key header. Without a valid key the response is a JSON-RPC error and no tool list.
tools/call It does not inherit the discovery credential. It enforces the API key or JWT already on that REST operation. Discovery can succeed and the call can still be 401 or 403.
HTTP 200 and -32602 Unknown tool, invalid arguments, and an unsupported protocol version all use this code, with HTTP 200. On an argument error, check whether the body was nested one level too high.

A non-POST to /mcp is HTTP 405. A JSON parse error is -32700 and HTTP 400. A missing method or id is -32600 and HTTP 200. An unsupported method, such as resources, prompts, or ping, is -32601 and HTTP 200. An oversized response or an unparseable backend body is -32000 and HTTP 200. An oversized transport body is HTTP 413.

Six checks before an operation is handed to an agent

Do not start by pasting a key into the prompt:

  1. Confirm the spec is OpenAPI 3.x. OpenAPI 2.0 does not become MCP. Every exposed operation needs a backend and a non-empty description, summary, or override.
  2. Expose only the operations you name. Using the object form to authenticate tools/list turns MCP on globally. Set x-google-mcp-tool: false on the rest. The docs’ own sample is a shelf delete. Do not leave that kind of operation behind a global switch.
  3. Check the tool name. Without a name, the gateway uses operationId. The name must be unique and contain only letters, digits, underscore, dot, and hyphen, with length 1 to 128.
  4. Put a separate key on discovery. Choose either a JWT or an API key. A JWT must also appear in the spec’s top-level security requirement. The API key scheme must be a header named x-api-key, as in the docs.
  5. Fill arguments by parameter location. Path and query stay at the top. The request body stays inside body. Check the call credential separately from the discovery credential.
  6. Read HTTP, then the JSON-RPC code and isError. 200 only means the transport returned JSON. The sample key is sk_demo_not_real. Do not commit a real one.

The transcoded backend request cannot be distinguished in code from a direct REST call. The 24 September post also says the same operation draws on one policy path and one quota allocation no matter which side it came from. The backend does not grow a second router for MCP.

Spread three JSON values out before a call is allowed

Most failures are a discovery key treated as call authorization, a body at the wrong level, or HTTP 200 read as a successful lookup.

  • format the arguments you are about to send, then use schema validation to see that path parameters are top-level and that body wraps only the request body.
  • Use JSONPath extract to pull $.method, $.params.name, and $.params.arguments.orderId. Stop if the name is not a tool you deployed.
  • Use JSON Diff on the OpenAPI parameter names and the argument keys. An extra top-level field is a reason to check whether it belonged inside body.
  • If the return has error.code, read it against the docs’ table. If it has result.isError, read the backend body next.
  • Do not paste keys, JWTs, or the gateway host into a public formatter. JSONSort runs locally in the browser.

When the three pieces match, the agent is calling the REST operation you selected. Indentation itself is not an error.

Common mistakes

  • Quoting the 24 September line that an API key cannot protect tools/list. The 30 September release notes add the API key. The 13 October docs show the header. A key in the query string still does not count.
  • Letting the agent change a resource because the list came back. Discovery and invocation are different credentials. initialize is unauthenticated too. A handshake only means the protocol version was accepted.
  • Spreading body fields across the top of arguments. The docs use one body property. Invalid arguments come back as JSON-RPC -32602, often still on HTTP 200.
  • Setting mcp to an object and forgetting that every other eligible operation turns on. After the global switch, a DELETE with an allowed method, a backend, and a description becomes a tool. Opt out one by one.
  • Staying on OpenAPI 2.0, or enabling model routing in the same config. The docs reject both. Resources, prompts, stdio, and streaming are outside this preview.
  • Putting the API key in the prompt or in JSON you commit. Discovery uses the x-api-key header. The sample is sk_demo_not_real.

FAQ

Do I still deploy a separate MCP server?

No. The Public Preview annotates the OpenAPI spec you already deploy, and the gateway serves remote MCP on /mcp. The backend still receives ordinary REST. The 24 September post calls API Gateway the lightweight path. A fuller platform and outbound governance are other products, and this piece does not cover them.

Can tools/list use an API key now?

Yes. The 30 September release notes add it beside JWT inside tools-list.security, and you name exactly one scheme. The key goes in the x-api-key header. Do not keep the 24 September sentence, that an API key cannot protect this method, as the current contract.

Why is HTTP 200 if the tool did not run?

The gateway puts many protocol errors on HTTP 200 so clients do not treat a non-200 as a transport failure. An unknown tool or invalid arguments is -32602. A backend error is HTTP 200 with result.isError set to true. Separate those three before you change the prompt.

Does operationId become the tool name?

Yes, when MCP is enabled globally. You can override it with x-google-mcp-tool.name. The name must be unique and match the documented character and length limits. An operation with no description is rejected at upload, not at call time.

Can the backend tell that this request came from MCP?

The configure page says the transcoded request cannot be distinguished in code from a direct REST call. That is why the operation’s existing auth still runs, and why a tools/list credential is not enough for the call.

Conclusion

Google Cloud API Gateway turns an existing REST operation into an MCP tool. The annotation decides what is exposed, tools/list decides who can see the catalog, and tools/call hits the backend under that operation’s own auth. The model fills arguments. The gateway translates them.

Check first that get_order_status comes from the spec you deployed, that orderId is a top-level argument, that a request body appears only under body, and that A-1042 appears only in the illustration. When those four match, a live resource can change.

Further reading

Changelog: First published