Skip to content

By the Octri team · Updated

What is an MCP gateway? How it differs from an MCP server

Share

An MCP gateway is one endpoint between AI agents and several MCP servers that signs each caller in once and decides which tools they can reach. This guide compares two open-source gateways, covers the token rule both follow, and shows what one did when we ran it.

What is an MCP gateway?

An MCP server gives an agent the tools for one system, like GitHub or your orders API. An MCP gateway sits in front of many of those servers at once. The agent connects to the gateway's single address, and the gateway passes each tool call on to the server that owns the tool, and it checks who's calling and keeps a record on the way through.

Think of the front desk in an office building. Visitors sign in once at the desk, the desk calls up to the right office and sends them up, and it keeps the visitor log. Each office still has its own lock on the door. A gateway is that desk for agents, and the MCP servers behind it are the offices.

Diagram of an AI agent calling one MCP gateway that signs the caller in, applies tool rules, holds server secrets and logs each call before routing to GitHub, Jira and orders MCP servers, with one orders tool blocked
One URL for the agent, one credential per hop: the gateway checks the agent's token and calls each server with its own.

Companies usually add a gateway when the number of MCP servers grows past what anyone can track by hand. Ten engineers with five servers each in their editor config is fifty connections with fifty sets of credentials, and nobody can say which agent called which tool last Tuesday.

MCP gateway vs MCP server

The two are easy to mix up because a gateway speaks MCP on both sides. To the agent it looks like an MCP server. To the servers behind it, it's an MCP client.

MCP server MCP gateway
What it fronts One system or API Many MCP servers
Who usually runs it The team that owns the API The company whose agents connect
Tools it offers Its own Everyone's, filtered
Sign-in For its own API One sign-in for all the servers behind it
Where policy lives Per server In one place

Rule of thumb: the company that publishes an API runs the MCP server, and the company whose agents use many APIs runs the gateway. The two meet in the middle, and a well-built server works the same with or without a gateway in front of it.

What an MCP gateway does

Most gateways do some mix of the same jobs. The names change from product to product but the jobs don't.

Job What it means in practice
One endpoint Agents get one URL and the gateway routes each call to the right server
One sign-in Callers authenticate to the gateway with the company's identity provider
Tool filtering Allow or block tools per team, role or profile
Secrets Upstream API keys live in the gateway's store and stay out of editor configs
Logging Every tool call is recorded with who made it
Isolation Local servers run in containers with limited access to the host

You won't find all six in every gateway. Some lean on routing and identity, and others lean on running servers safely on a laptop.

The token rule every gateway has to follow

A gateway is a proxy, and proxies have one well-known trap. The easy build takes the token the agent sends and forwards it to the server behind. The MCP spec forbids that. Its authorization security considerations say a server must not accept a token that wasn't issued for it, and to the agent a gateway is a server.

So a gateway checks the agent's token against itself first: issuer, expiry, audience and scopes. Then it calls each server behind it with a credential issued for that server. Forwarding the original token lets a token meant for one service work at another, and the server behind the gateway can no longer check that the token was issued for it. MCP token passthrough walks through the attack and a local check for it.

The spec's earlier security best practices add a second rule for proxies that sign in to third-party APIs with one fixed client ID. They must ask each client for consent before forwarding it to the third party's authorization server, and they must check the redirect URI by exact match. Without that, a consent cookie from one client can be reused by another.

Open-source MCP gateways

Two open-source gateways show the range. Docker's runs MCP servers in containers on a developer's machine. Microsoft's routes requests to MCP servers running in a Kubernetes cluster.

Docker MCP Gateway Microsoft MCP Gateway
Where it runs Docker Desktop or the Docker CLI Kubernetes (Azure Kubernetes Service in its guide)
How servers run Each one in its own container Registered tool servers in the cluster
How agents connect stdio by default, or streaming on a port HTTP, one route per server plus a tool router at /mcp
Sign-in Built-in OAuth flows for upstream services Microsoft Entra ID with role-based access
Tool rules Allow and deny lists per profile Roles per tool server
Logging Logging and call tracing Status and logs per tool server
License MIT MIT

Docker's gateway groups servers into profiles and stores upstream secrets with docker mcp secret, which keeps them out of environment variables (docker/mcp-gateway). Microsoft's routes each request on its own, without tying a session to one router instance, and its current release needs clients on the 2026-07-28 version of the protocol (microsoft/mcp-gateway).

API gateway vendors sell MCP gateways too, usually as a feature of the gateway a company already runs for its REST APIs. If you have one of those, check it before adding another moving part.

What we saw running Docker's MCP gateway

We ran Docker's gateway, image docker/mcp-gateway:v0.44.3, on a developer machine in front of one remote MCP server: an Octri-hosted server for a test project with 31 tools, 23 from its API's operations and 8 for its docs. The gateway listened with its streaming transport on port 8811. Between the gateway and the server we put a small relay that logged every request the server received.

  • Sign-in at the gateway. A request with no bearer token, or the wrong one, got 401 Unauthorized. The right token got in, and tools/list returned all 31 tools.
  • The token stayed at the gateway. None of the requests the server received carried the agent's bearer token. Each one carried only the header we set for that server in the gateway's catalog.
  • One upstream session per agent session. The gateway opened a session with the server on an agent's first tool call and reused it for the rest of that agent's session, so session-scoped limits on the server still count per agent.
  • Tool rules. Restarting with --tools search_docs,listCustomers,getCustomer cut the list to 3 tools. A call to createCustomer came back as unknown tool "createCustomer", and nothing reached the server.
  • The call log. Each call was logged with the tool name and the shape of its arguments, like object with 1 field(s), after a scan of the arguments and the response for secrets. The blocked call was logged as a call too, with no line saying it was refused.

Two setup notes. The gateway refuses remote servers on private or plain-HTTP addresses unless you set DOCKER_MCP_ALLOW_INSECURE_REMOTE_URLS=1, which we did for this local test. It also needs the Docker socket, even when every server behind it is remote.

Two things stood out. In this mode the gateway's own sign-in is one shared token from MCP_GATEWAY_AUTH_TOKEN, so its log records the client app's name, gateway-probe@0 in our run, and has no field for the person. And every agent reached the server with the same header and the same Go-http-client user agent, so the server couldn't tell them apart either. If you need to know which person called which tool, check that the gateway you pick signs in each person and passes who they are to the servers behind it.

When you need an MCP gateway

You probably need one if agents across your company connect to more than a handful of MCP servers, or if security has asked who called which tool, or if API keys for those servers are sitting in editor config files. That's the point where one sign-in and one log pay for the extra hop.

You probably don't need one yet if a single team uses one or two servers, or if you're the one publishing an MCP server for your own API. In that second case the controls belong in your server. The people connecting to it may put their own gateway in front, and your server should work either way.

Tip: before you choose a gateway, list every MCP server your agents use today and where each one's credentials live. That list is your migration plan, and it usually shows which job matters most.

MCP gateway checklist

Use this before you put a gateway in front of production tools:

  • The gateway validates the agent's token against itself and never forwards it upstream.
  • Each server behind the gateway gets its own credential, held in the gateway's secret store.
  • Tool rules are set per team or role, and writes are blocked by default for agents that only read.
  • Every tool call is logged with the person, the client, the tool and the result, and a blocked call is logged as blocked.
  • Servers that run locally are isolated from the host.
  • The servers behind the gateway still check their own authorization and limits.

The last point matters most. A gateway adds a layer of control, and it shouldn't be the only one.

The MCP server behind the gateway, with Octri

Octri is on the other side of the gateway. We host an MCP server for your API at one URL, and any MCP client can connect to it and sign in with OAuth, and so can a gateway. Each operation becomes a tool, and when you publish a change to your API the tools change with it. If a company puts your server behind their gateway, it works the same as it does on its own.

For this guide we also opened MCP Studio on that same test project and checked its controls against the gateway jobs above. Each tool has its own rule for what happens when an agent calls it. On createCustomer, a POST, the rule was Asks first: the server shows the person the exact request and sends it only on a yes, and clients that can't ask refuse the call.

Octri MCP Studio tool rule for createCustomer with Runs on its own, Asks first (selected) and Off
A tool rule set in the server holds whether or not a gateway sits in front of it.

Sign-in follows the two-credential rule from earlier. With the Octri sign-in option, Octri signs each person in with your OAuth app, keeps their API tokens encrypted on our side and refreshes them. Their AI client, or the gateway acting for it, only ever holds an Octri token.

Octri MCP Studio sign-in options with Octri sign-in selected
The client's token is for the MCP server; the API token stays with the server.

The controls from the checklist are in the server itself too. Writes ask the person first by default, there's a cap on calls per minute per tool and on writes per session, and an audit log records every write an agent attempts with secrets redacted, and you can export it as CSV or JSON. Tool groups cut smaller servers from the same tools, and you can serve it from your own domain, like mcp.acme.com. Octri's MCP server is on every plan, Free too.

Share

Keep reading