Explainer gateways/

MCP gateway explained: what it does between agents and servers

A gateway is an MCP server to your clients and an MCP client to your servers. This is what it does to each request, which parts of the spec govern it, and what it costs you.

Published
Read
6 min
Source
Markdown

Short answer

An MCP gateway is a proxy between MCP clients and several MCP servers that exposes them through one endpoint. To clients it is an MCP server and OAuth resource server; to each upstream server it is an MCP client. On each request it validates the caller's token, returns only the tools that caller may use from tools/list, calls the upstream with its own credential instead of the caller's token, and records the call. The MCP specification anticipates gateways as intermediaries but does not define one.

Checked against: the MCP specification’s Streamable HTTP, Tools, Caching and Authorization pages, plus the Security Best Practices and Local Server Security guides, December 6, 2026.

This explainer covers the function of an MCP gateway, not products. It names no vendors and ranks none.

What is an MCP gateway?

An MCP gateway is a proxy that puts several MCP servers behind one endpoint and applies one set of authentication, tool-access and logging rules to every caller.

MCP clients              MCP gateway                    upstream MCP servers
(hosts, agents)
   ── Bearer T1 ──▶  1. validate T1 (audience = gateway)
                     2. filter tools/list for this caller
                     3. route tools/call by Mcp-Name     ── own token ──▶  server A
                     4. attach upstream credential       ── own token ──▶  server B
                     5. write audit record                ── own token ──▶  server C

The MCP specification (revision 2026-07-28, current as of December 6, 2026) defines no gateway, but it plans for one. The Streamable HTTP transport copies request fields into headers “so that intermediaries (load balancers, gateways, observability tooling) can route and inspect requests without parsing the body.” The Tools page gives rules for “clients or proxies that aggregate tools from multiple servers.”

How does a gateway authenticate callers?

A gateway that uses MCP authorization is an OAuth resource server, so it validates every inbound token as issued for itself.

Inbound rule Source
Publish Protected Resource Metadata (RFC 9728) naming the authorization server Authorization
Validate that each token was issued for the gateway as audience; 401 if invalid or expired Authorization
Accept only tokens valid for its own resources; “MUST NOT accept or transit any other tokens” Authorization
Answer missing scopes with 403 and error="insufficient_scope" Authorization

On the upstream side, the gateway is an MCP client. Each upstream server that uses MCP authorization accepts only tokens its own authorization server issued for it. The gateway therefore holds a separate credential per upstream and never forwards the caller’s token, which would be token passthrough.

One more rule applies when the gateway brokers sign-in to third-party APIs with a single static client ID. If it also lets clients register dynamically, the gateway MUST collect per-client consent before forwarding to the third-party authorization server. Otherwise a consent cookie from an earlier sign-in can let an attacker’s client skip the consent screen (Security Best Practices).

How does tool filtering work?

The gateway calls tools/list on each upstream server, merges the results, and returns only the tools the caller is allowed to use.

Spec rule What it means for a gateway
The tool set “MAY vary by the authorization presented on the request” Per-caller filtering is allowed
It “MUST NOT vary per-connection” Filter by the caller’s credential, not by connection
Aggregators “SHOULD implement a disambiguation strategy such as prefixing tool names with a server identifier” Two upstreams with a search tool need distinct names
Server name from serverInfo “SHOULD NOT be relied upon for disambiguation” Use the gateway’s own identifier for each upstream
Servers SHOULD return tools in a deterministic order Keep the merged list stable to help client caches

Those rules come from the Tools page. Hiding a tool from tools/list is not enforcement on its own. Servers MUST implement proper access controls, so the gateway has to apply the same rule when a tools/call arrives for that tool.

Caching matters once lists differ per caller. A tools/list result carries ttlMs and cacheScope. A "public" result may be stored by a shared gateway and served to any user. A "private" result may be reused only within the same authorization context, and “caches MUST NOT be shared across authorization contexts” (Caching). A per-caller filtered list belongs in the private scope.

How does a gateway route without parsing JSON?

Streamable HTTP mirrors the JSON-RPC method and tool name into required headers, so a gateway can route and apply policy from headers alone.

POST /mcp HTTP/1.1
Host: example.com
Content-Type: application/json
Accept: application/json, text/event-stream
MCP-Protocol-Version: 2026-07-28
Mcp-Method: tools/call
Mcp-Name: get_weather
Header Carries Required on
MCP-Protocol-Version Protocol version from _meta Every POST
Mcp-Method JSON-RPC method All requests
Mcp-Name params.name or params.uri tools/call, resources/read, prompts/get
Mcp-Param-{Name} A tool argument the server marked with x-mcp-header When that argument has a value

These are the headers from the spec’s tools/call example, which continues with the JSON-RPC body. Servers that process the body MUST reject header-body mismatches with 400 and error -32020 (HeaderMismatch). An intermediary that enforces policy on mirrored headers SHOULD check that MCP-Protocol-Version names a version requiring that validation, and SHOULD reject older or missing versions rather than trust the headers. Names outside the header-safe character set arrive Base64-encoded as =?base64?...?=, and intermediaries that inspect them MUST decode them.

Two more transport details affect a gateway:

  • No sessions. Revision 2026-07-28 removed protocol-level sessions and the Mcp-Session-Id header. Every request carries its own version and capabilities in _meta, so a gateway needs no protocol session affinity.
  • Streaming. Responses can be SSE streams. Servers SHOULD send X-Accel-Buffering: no so proxies don’t buffer events, and closing a response stream cancels that request.

What should the audit record contain?

An audit record should tie each tool call to a validated identity, an upstream server, a tool and an outcome.

Field Where the gateway gets it
Caller Claims of the validated inbound token
Upstream server The gateway’s routing decision
Tool or resource Mcp-Name, or params.name / params.uri
Time Gateway clock
Outcome JSON-RPC error, or isError in the tool result
Trace context traceparent in _meta (OpenTelemetry)

Take the caller from the token, not from _meta. The spec says clientInfo is self-reported and SHOULD NOT be relied on for security decisions (Overview). The Tools page asks clients to “log tool usage for audit purposes,” and the Local Server Security guide asks administrators to record “which server, which tool, when.” See audit log.

What does a gateway not cover, and what does it cost?

A gateway centralizes control of remote MCP traffic, and the costs come with that centralization.

Trade-off Why
Local stdio servers bypass it A host launches a stdio server as its own child process, so that traffic never reaches a remote gateway
Concentrated credentials The gateway stores upstream tokens for many users; the spec requires secure token storage
Extra hop and a shared dependency Every request passes through it, so its availability and latency apply to every server behind it
Tool descriptions still reach the model Filtering decides which tools appear, not what their descriptions say; see tool poisoning
Header trust depends on version Policy based on mirrored headers is safe only for versions that require header-body validation
Confused deputy exposure Brokering third-party sign-in with one static client ID requires per-client consent

The MCP project’s guidance for administrators favors central deployment where local access isn’t needed. A centrally managed remote server gives “one instance to patch, audit, and control instead of hundreds” (Local Server Security). A single developer with a few servers gets less from a gateway, because the tools spec already expects hosts to show which tools are exposed and to let a human deny calls.

Sources

  1. Streamable HTTP (specification 2026-07-28)Model Context Protocol modelcontextprotocol.io
  2. Tools (specification 2026-07-28)Model Context Protocol modelcontextprotocol.io
  3. Caching (specification 2026-07-28)Model Context Protocol modelcontextprotocol.io
  4. Overview: statelessness and _meta (specification 2026-07-28)Model Context Protocol modelcontextprotocol.io
  5. Authorization (specification 2026-07-28)Model Context Protocol modelcontextprotocol.io
  6. Authorization Security Considerations (specification 2026-07-28)Model Context Protocol modelcontextprotocol.io
  7. Security Best Practices (2026-07-28)Model Context Protocol modelcontextprotocol.io
  8. Local Server Security (2026-07-28)Model Context Protocol modelcontextprotocol.io

Changelog

  • First published.

Cite this page

Agents for Devs. "MCP gateway explained: what it does between agents and servers." Published Dec 6, 2026. https://agentsfordevs.com/guides/mcp-gateway-explained
Cite one section