# MCP Gateway: What It Is and When You Need One (2026)
> What an MCP gateway does, the spec rules it must follow, how the stateless 2026-07-28 MCP revision changes routing, and six gateways compared with setup examples.
Canonical: https://www.mcpfolio.com/articles/mcp-gateway
Last updated: 2026-11-18
## What is an MCP gateway?

An MCP gateway is a proxy that sits between AI clients and MCP servers and enforces rules on every call. Clients connect to one endpoint. The gateway decides which servers and tools each caller may use, holds the credentials for the services behind it, translates between transports, and logs what happened.

You need one when several people or agents share servers and someone has to answer "who called which tool, with what access?" You usually do not need one when a single developer runs a handful of servers on their own machine.

[Compare 6 gateways](https://www.mcpfolio.com/articles/mcp-gateway#compare) · [Spec rules](https://www.mcpfolio.com/articles/mcp-gateway#spec-rules) · [Stateless MCP (2026-07-28)](https://www.mcpfolio.com/articles/mcp-gateway#stateless-spec) · [Setup examples](https://www.mcpfolio.com/articles/mcp-gateway#setup-examples) · [Checklist](https://www.mcpfolio.com/articles/mcp-gateway#checklist)



- A team shares GitHub, Slack or database servers and needs per-user access and an audit trail: use a gateway.

- You want upstream tokens off developer laptops: use a gateway that injects credentials server-side.

- Your agents connect to dozens of servers and the tool list is crowding the model's context: use a gateway that filters or hides tools.

- One person, two or three local servers: connect them directly. A gateway is one more service to run, patch and secure.

## What does an MCP gateway actually do?

Every product markets a different mix, but the jobs fall into six groups. Docker calls its gateway "a centralized proxy between clients and servers" that manages "configuration, credentials, and access control." Portkey's tagline is "centralized authentication, access control, and observability for MCP servers." Cloudflare says a portal "centralizes multiple Model Context Protocol (MCP) servers onto a single HTTP endpoint."

The useful question is not whether a product has a feature, but where the decision is made. A gateway is valuable because it moves decisions out of each client config and into one place someone can review.

| Job | What the gateway does | Example in the products we checked |
| --- | --- | --- |
| One endpoint | Clients store one URL instead of one per server | Cloudflare portals expose servers at https://<subdomain>.<domain>/mcp |
| Caller authentication | Identifies the user or agent once, usually with OAuth, an IdP or an API key | Microsoft's gateway checks Entra ID tokens; Portkey's API key decides which servers and tools are reachable |
| Credential injection | Holds upstream tokens and attaches them per call, so clients never see them | Docker and Portkey both inject credentials before forwarding |
| Tool filtering | Allows, hides or renames tools per user, team or profile | Docker enables tools as server.tool per profile; Cloudflare supports an allowlist and aliases |
| Transport translation | Lets an HTTP client reach a stdio server, or the reverse | ContextForge and agentgateway list stdio alongside HTTP, SSE and Streamable HTTP |
| Audit and limits | Logs user, tool, arguments and result; rate-limits by key, server or tool | Portkey logs every call and rate-limits by request count or token use |

## MCP gateway vs proxy vs registry vs AI gateway

These words get used interchangeably, which makes vendor pages hard to compare. The distinctions below are ours, but they match how the products actually behave.

The overlap is growing. Portkey, agentgateway and Cloudflare all sell or ship an AI gateway for model traffic, and MCP routing is being added to the same box. That is convenient, but it also means your model provider keys and your tool credentials can end up in one system. Decide deliberately whether you want that.

| Term | What it does | Enforces rules? |
| --- | --- | --- |
| MCP proxy or bridge | Forwards MCP traffic and often converts transports, for example mcp-remote turning a remote server into stdio for Claude Desktop | No, or very little |
| MCP registry | Lists servers and how to install them, like a package index | No; it describes, it does not route |
| MCP gateway | Routes calls to many servers and applies identity, tool access, credentials and logging | Yes; that is the point |
| AI gateway | Routes model API calls (OpenAI, Anthropic and others) with keys, caching and limits | Yes, for model traffic; many now add MCP |

## What 663 MCP servers tell us about the need for a gateway

We looked at the 663 servers in the MCPfolio catalog on November 18, 2026, using the transport and tool data recorded for each listing. Two numbers explain most of the demand for gateways.

Transports are split. 369 servers (56%) are documented as HTTP-only, 213 (32%) as stdio-only, and 61 (9%) support both. The other 20 do not state a transport we could classify. A hosted gateway cannot simply call a stdio server: something has to launch the process and translate. That is why Docker runs local servers in containers and why ContextForge and agentgateway treat stdio as a first-class transport. If a third of your servers are stdio, transport translation is not a nice extra. It decides which gateways can work for you.

Tool lists add up fast. Among the 246 servers with an exact tool count, the median exposes 11 tools, the 90th percentile exposes 78, and 34 servers expose 50 or more. The largest exposes 601. Five median servers already put about 55 tool definitions in front of the model. One large server can double that. Every definition costs context and gives the model another way to pick the wrong tool, so tool filtering is a quality control, not only a security control.

Gateways and clients attack this from both ends. Cloudflare portals offer query options that "reduce context window usage by minimizing or hiding tool definitions." Docker profiles enable tools one by one. On the client side, Claude Code's MCP tool search defers tool definitions and loads them when needed. If your only problem is context size, check your client before adding a gateway.

## The MCP spec rules every gateway has to respect

A gateway is an MCP server to its clients and an MCP client to its upstreams, so the specification's security rules apply on both sides. Four of them shape how a gateway must be built. Quotes are from the 2025-11-25 specification.

| Rule in the spec | What it means for a gateway |
| --- | --- |
| "MCP servers MUST NOT accept any tokens that were not explicitly issued for the MCP server." | No token passthrough. The gateway validates tokens issued for itself and uses its own, separately issued tokens upstream. Forwarding a user's token breaks audit trails and audience-based limits. |
| Clients MUST send the RFC 8707 resource parameter, and servers MUST check the token's audience | Every upstream needs its own grant. That is why gateway setup starts by connecting each service to the gateway, not by pasting tokens into clients. |
| "MCP proxy servers MUST implement per-client consent" when they use a static client ID with a third-party authorization server | A gateway that lets many dynamically registered clients share one upstream OAuth app is a textbook confused deputy. It needs its own consent screen per client, exact redirect URI matching and single-use state. |
| "MCP Servers MUST NOT use sessions for authentication" and session IDs must be secure and non-deterministic | Authenticate every request. A leaked session ID must not be enough to act as a user. The spec suggests binding sessions to the user, for example as <user_id>:<session_id>. |
| "Servers MUST validate the Origin header on all incoming connections"; local servers SHOULD bind to 127.0.0.1 | A gateway on a laptop is reachable by any web page through DNS rebinding unless it checks Origin and stays on localhost. |

## How the stateless 2026-07-28 MCP revision changes gateways

The 2026-07-28 revision of the specification is the biggest change for gateway builders so far. Its changelog lists "Make MCP stateless" as a major change. It removes the initialize handshake and "protocol-level sessions and the Mcp-Session-Id header from the Streamable HTTP transport." Protocol version and client capabilities now travel in each request's _meta, and servers must implement a new server/discover method.

No sessions means no sticky routing. Under 2025-11-25, a server could assign a session ID that clients must send on every request, so a gateway behind a load balancer had to keep each session on the same replica or share session state. Under 2026-07-28, any replica can handle any request. Microsoft's MCP Gateway already depends on this: its README says it "requires MCP 2026-07-28 clients and adapters" and runs "without transport-session affinity."

Gateways can route without reading the body. The revision requires Mcp-Method and Mcp-Name headers on Streamable HTTP POST requests. A gateway, WAF or load balancer can then allow, deny or route a tools/call for a specific tool by header, before parsing JSON.

Shared caching becomes safe to reason about. List and read results now carry ttlMs and a cacheScope of "public" or "private," which "controls whether shared intermediaries may cache the response." A gateway can cache a public tools/list for everyone, and must not serve one user's private list to another. Servers also SHOULD return tools/list in a deterministic order, which keeps caches stable.

Plan for a mixed fleet. Clients and servers will move to the new revision at different speeds, so a gateway in front of both old and new servers still needs session affinity for the older ones. Ask vendors which revisions they support on each side.

## MCP gateways compared: Docker, ContextForge, agentgateway, Microsoft, Cloudflare, Portkey

We read each project's own documentation or README on November 18, 2026. We did not run or benchmark them, so treat this as a map of documented capabilities, not a ranking. Products in this space change monthly. Check the source before you decide.

| Gateway | Runs where | Caller auth | Tool control | Worth knowing |
| --- | --- | --- | --- | --- |
| [Docker MCP Gateway](https://www.mcpfolio.com/servers/docker-mcp-gateway) | Your machine or infrastructure; MIT-licensed CLI plugin | Clients connect locally; OAuth for upstreams via docker mcp oauth | Per profile, as server.tool | Each local server runs in its own container; transports are stdio, sse and streaming |
| IBM ContextForge | Self-hosted (pip, uvx or container), default port 4444; Apache-2.0 | Basic, JWT or custom schemes | Virtual servers that bundle chosen tools | Federates MCP, A2A, REST and gRPC; OpenTelemetry tracing; requires JWT_SECRET_KEY and AUTH_ENCRYPTION_SECRET to start |
| agentgateway | Self-hosted binary or Kubernetes; Linux Foundation project, Apache-2.0 | OAuth for MCP | RBAC policies written in CEL | Also routes LLM and A2A traffic; guardrails include regex, moderation and webhooks; README says it is in active development |
| Microsoft MCP Gateway | Kubernetes (Docker Desktop locally, AKS on Azure); MIT | Entra ID bearer tokens with app roles | requiredRoles per adapter and tool | Stateless routing; requires 2026-07-28 clients; agent features are preview and single-replica |
| Cloudflare MCP server portals | Hosted on Cloudflare | Cloudflare Access with your identity provider; service tokens for machines | Per-tool allowlist (default_disabled plus updated_tools) and aliases | Warns that blocked users can still reach a server by its direct URL unless the server also enforces Access |
| Portkey MCP Gateway | Hosted | API key or IdP token (Okta and Auth0 named) | Per-user tool enablement | Logs every call; rate limits by request count or token use; approval workflows |



- Solo developer who wants isolation and one config for several clients: Docker MCP Gateway.

- Platform team that wants to self-host, federate many servers and wrap REST or gRPC APIs: ContextForge or agentgateway.

- Azure and Kubernetes shop already on Entra ID: Microsoft MCP Gateway, if your clients support 2026-07-28.

- Company already using Cloudflare Zero Trust: Cloudflare portals, with Access enforced on each server too.

- Team that wants a hosted control plane next to its LLM routing: Portkey.

## Setup examples from the official docs

These commands are taken from each project's README or quickstart. We have not run them, so try them on a test machine with read-only accounts first.

One change we recommend: ContextForge's quickstart binds to 0.0.0.0, which listens on every network interface. For local testing, use 127.0.0.1 instead. The spec says local servers SHOULD bind only to localhost, and a gateway holds more credentials than any single server.

**Docker MCP Gateway: allow one tool, connect Claude Code, or serve several clients over HTTP**

```
# Enable a single tool in a profile (server.tool)
docker mcp profile tools dev-tools --enable github.create_issue

# Connect a client to that profile
docker mcp client connect claude-code --profile dev-tools --global

# Or run the gateway over Streamable HTTP for several clients
docker mcp gateway run --profile dev-tools --port 8080 --transport streaming
```

**IBM ContextForge: generate the required secrets, then start the gateway**

```
python3 -m mcpgateway.scripts.init_secrets

# README uses --host 0.0.0.0; use 127.0.0.1 for local testing
uvx --from mcp-contextforge-gateway mcpgateway --host 127.0.0.1 --port 4444
```

**agentgateway: config.yaml from the MCP quickstart (run with agentgateway -f config.yaml)**

```
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
gateways:
  default:
    port: 4000
mcp:
  targets:
  - name: server-everything
    mcp:
      host: http://localhost:3005/mcp
ui: {}
```

## Failure modes most gateway guides skip

A gateway concentrates control, which also concentrates risk. These are the problems we would plan for before rollout.



- The gateway becomes your most valuable credential store. It holds tokens for every upstream. Put it behind your strongest authentication, keep it off the public internet where you can, and scope each upstream grant to the minimum.

- Direct URLs bypass the gateway. Cloudflare's docs say blocked users "can still connect to the server" through its direct URL. Any server that is also reachable directly needs its own authentication, or the gateway's rules are advisory.

- Audit logs contain your data. Logging every tool call's arguments and results means logging customer records, file contents and queries. Decide retention, access and redaction before you turn on full logging.

- Tool names collide when you federate. Two servers can both expose a search or create_issue tool. Use per-server prefixes or aliases, which Cloudflare resolves in the order portal alias, server alias, alias, then original name.

- Private results can leak through caches. Under 2026-07-28, a tools/list marked private must not be shared between users. Check that your gateway honors cacheScope before enabling response caching.

- Stdio servers are only as safe as the host. The spec says stdio servers should read credentials from the environment and recommends sandboxing. A gateway that launches stdio servers inherits that duty, which is why container isolation matters.

- A gateway is a new single point of failure. If it goes down, every agent loses every tool. Run more than one instance; with 2026-07-28 servers that no longer needs session affinity.

## When you do not need an MCP gateway

Skip the gateway if one person uses the servers, they run locally over stdio, and the credentials are already that person's own. Connecting directly is simpler and has fewer moving parts. Our [Obsidian MCP server guide](https://www.mcpfolio.com/articles/obsidian-mcp-server) is an example: one user, one local vault, and an mcp-remote bridge only where a client needs it.

Also check your client first. Many clients now handle OAuth per server, and Claude Code can defer tool definitions with tool search. If those solve your problem, a gateway adds cost without adding control.

## Checklist before you route real accounts through a gateway

Work through this list with one read-only account before you connect anything that can write.



1. Inventory your servers: transport (stdio or HTTP), tool count, and which tools write data. Each server's MCPfolio page, such as [GitHub MCP](https://www.mcpfolio.com/servers/github), lists its documented tools.

2. Confirm the gateway supports your transports. If a third of your servers are stdio, it must launch and isolate them.

3. Confirm which MCP revisions it supports on each side: 2025-11-25 needs session affinity; 2026-07-28 does not.

4. Check that it never passes client tokens upstream and that each upstream has its own grant.

5. Allowlist tools per user or team. Start read-only and add write tools one at a time.

6. Make the gateway the only path: require authentication on each upstream server too.

7. Decide log retention and redaction, then verify a test call appears with the right user.

8. Run at least two instances and test what clients do when one fails.

## How we researched this guide

We read the MCP specification (2025-11-25 authorization, security best practices and transports, plus the 2026-07-28 changelog) and each gateway's own documentation or README on November 18, 2026. Catalog figures come from the active MCPfolio release on the same day: 663 servers, with transport classified from each listing's documented transports and tool statistics limited to the 246 servers with an exact tool count. We did not install or benchmark any gateway. Where a project's own pages disagreed, as with Microsoft's description of session routing, we followed the README body over the summary.

## Frequently asked questions

### What is an MCP gateway?

A proxy between AI clients and MCP servers that applies rules to every call. Clients connect to one endpoint, and the gateway handles caller authentication, tool access, upstream credentials, transport translation and logging.

### Do I need an MCP gateway as a solo developer?

Usually not. If you run a few local servers with your own credentials, direct connections are simpler. A gateway starts to pay off with shared servers, many users, or audit requirements.

### Is an MCP gateway the same as an AI gateway?

No. An AI gateway routes model API calls; an MCP gateway routes tool calls to MCP servers. Several AI gateways, including Portkey, agentgateway and Cloudflare, now offer both.

### Can an MCP gateway pass my token through to GitHub or Slack?

It should not. The MCP specification says servers must not accept tokens that were not issued for them, so a gateway uses its own separately issued token for each upstream service.

### How does the 2026-07-28 MCP revision affect gateways?

It removes the initialize handshake and the Mcp-Session-Id header, so any gateway replica can handle any request. It also adds Mcp-Method and Mcp-Name headers for routing and a cacheScope field for safe shared caching.

### Can an MCP gateway reduce how many tools the model sees?

Yes. Docker enables tools per profile, Cloudflare portals support tool allowlists and modes that minimize or hide tool definitions, and Portkey enables tools per user. Some clients, such as Claude Code, can also defer tool definitions.

### Can a hosted MCP gateway use local stdio servers?

Not directly. Something has to launch the stdio process and translate it to HTTP. Self-hosted gateways such as Docker MCP Gateway, ContextForge and agentgateway support stdio; a hosted gateway generally needs the server exposed over HTTP.

## Primary sources

- [MCP specification 2026-07-28: changelog](https://modelcontextprotocol.io/specification/2026-07-28/changelog)
- [MCP specification 2025-11-25: authorization](https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization)
- [MCP specification 2025-11-25: security best practices](https://modelcontextprotocol.io/specification/2025-11-25/basic/security_best_practices)
- [MCP specification 2025-11-25: transports](https://modelcontextprotocol.io/specification/2025-11-25/basic/transports)
- [Docker MCP Gateway documentation](https://docs.docker.com/ai/mcp-catalog-and-toolkit/mcp-gateway/)
- [docker/mcp-gateway on GitHub](https://github.com/docker/mcp-gateway)
- [IBM ContextForge on GitHub](https://github.com/IBM/mcp-context-forge)
- [agentgateway on GitHub](https://github.com/agentgateway/agentgateway)
- [microsoft/mcp-gateway on GitHub](https://github.com/microsoft/mcp-gateway)
- [Cloudflare MCP server portals](https://developers.cloudflare.com/cloudflare-one/access-controls/ai-controls/mcp-portals/)
- [Portkey MCP Gateway documentation](https://portkey.ai/docs/aigw/product/mcp-gateway)
- [Claude Code MCP documentation](https://code.claude.com/docs/en/mcp)


## Related

- [docker-mcp-gateway](https://www.mcpfolio.com/servers/docker-mcp-gateway)
- [github](https://www.mcpfolio.com/servers/github)
- [playwright-browser-automation](https://www.mcpfolio.com/servers/playwright-browser-automation)
- [filesystem](https://www.mcpfolio.com/servers/filesystem)