Skip to content
datarekha

MCP gateways & registries

One MCP server is easy; an organization with dozens of servers and many clients is a mess. An MCP gateway is the fix — a proxy that aggregates servers behind one endpoint and centralizes auth, security, and observability. Registries add discovery. The AI-gateway pattern, applied to MCP.

Written and reviewed by Last reviewed

7 min read Advanced Agentic AI Lesson 10 of 78

What you'll learn

  • Why a fleet of MCP servers needs a gateway layer
  • What a gateway centralizes — aggregation, auth, security, observability
  • How registries provide discovery for MCP servers
  • The parallel to AI gateways and the security stakes

Before you start

A single MCP server (a program that offers tools an AI agent can call) wired into one client is simple. Now scale it: an organization with dozens of servers (GitHub, databases, internal APIs) and many clients (the apps that talk to those servers: IDEs, chat apps, agents). Connect everything directly and you get a tangle — every client configures every server, each server handles its own authentication, and nobody has a central place for security, rate limits, or logging.

An MCP gateway untangles it: a proxy (a middleman that forwards requests) that sits between clients and servers, aggregates them behind one endpoint, and centralizes the cross-cutting concerns. It is exactly the AI-gateway pattern, applied to the MCP ecosystem.

One endpoint instead of a mesh

The first win is structural. Without a gateway, M clients each connect to N servers — an M × N mesh of connections and credentials. A gateway collapses that to M + N:

clients, servers = 20, 12
direct    = clients * servers     # every client wires up every server
gatewayed = clients + servers     # clients -> gateway -> servers

print(f"direct mesh: {direct} connections")
print(f"via gateway: {gatewayed} connections")
print(f"reduction:   {direct / gatewayed:.1f}x")
direct mesh: 240 connections
via gateway: 32 connections
reduction:   7.5x

Twenty clients and twelve servers go from 240 point-to-point connections to 32. But the connection count is the least of it — the real value is that the gateway becomes the one place to enforce everything that should be uniform:

MCP registry · discoveryclient Aclient Bclient CMCP Gateway· aggregate many → one· auth + secrets + access· security + rate + audit· observability (logs)· route by method / nameserver: GitHubserver: databaseserver: internal API
Clients see one gateway, not a fleet. The gateway aggregates, authenticates, secures, and observes — and pulls available servers from a registry.

What the gateway centralizes

  • Aggregation. Many servers appear as one MCP endpoint; a client connects once and gets the union of all tools.
  • Auth and secrets. Authentication, per-user/team tool access control, and secret management live in the gateway — individual servers don’t each juggle credentials.
  • Security. Input/output filtering, defense against tool poisoning (a server hiding malicious instructions in a tool description), rate limiting (capping how many calls per minute), and audit logging (a permanent record of who called what) in one chokepoint. MCP servers are a real attack surface, so a central enforcement point matters a lot (MCP security).
  • Observability. All MCP traffic flows through one place, so logging and tracing are uniform rather than per-server.
  • Routing. The gateway dispatches each tool call to the correct backend server.

What the stateless spec changed here

The 2026-07-28 revision was written partly for this layer, and three of its changes land straight on a gateway:

  • No session to pin. The initialize handshake and the Mcp-Session-Id header are gone. Every request carries its protocol version, client identity, and capabilities in _meta. The gateway no longer needs sticky routing or a shared session store — plain round-robin across replicas is correct. A backend can be restarted or scaled out mid-conversation without dropping anyone.
  • Routing without parsing the body. Streamable HTTP requests carry Mcp-Method and Mcp-Name headers naming the operation and its target. The gateway — or a rate limiter or WAF in front of it — can treat a tools/call on refund_order differently from a tools/list without parsing the JSON at all (a WAF is a web application firewall, a filter that blocks bad requests). That is faster, and safer: no routing decision depends on trusting the payload.
  • Cacheable listings. tools/list, prompts/list, resources/list, resources/templates/list, and resources/read now return ttlMs and cacheScope. The gateway can serve its aggregated tool list from cache (a stored copy) for ttlMs (how many milliseconds the copy stays valid) instead of fanning out to twelve servers every time a client connects. Honour cacheScope: public results may be shared across users. private results must not be shared — a shared cache that ignores that flag leaks one user’s tool list to another, the same mistake as a CDN caching a logged-in page.

Registries: discovery

A registry is the other half: a catalog of available MCP servers — name, description, capabilities, endpoint — so clients and gateways can discover servers instead of hard-coding them, much like a package index. There’s an official MCP registry for public servers, and organizations run private registries for internal ones. A gateway typically pulls its server list from a registry; a client browses the registry to find what’s available.

In one breath

  • A fleet of MCP servers + many clients is an M × N mesh of connections and credentials; an MCP gateway proxies it down to M + N (240 → 32 in the demo) behind one endpoint.
  • The connection count is minor; the point is centralizing the following in one place:
    • aggregation
    • auth + secrets + access control
    • security (filtering, rate limits, audit)
    • observability
    • routing
  • Since 2026-07-28 the protocol is stateless:
    • no session to pin (round-robin is fine);
    • Mcp-Method / Mcp-Name headers let you route without parsing the body;
    • ttlMs + cacheScope make list results cacheable — respect private.
  • Registries provide discovery — a catalog of MCP servers (official + private) so clients/gateways find servers instead of hard-coding them.
  • It’s the AI-gateway pattern one layer down (in front of tool servers, not model providers) — and, like any gateway, a critical dependency to run for high availability.

Quick check

Quick check

0/5
Q1What core problem does an MCP gateway solve?
Q2Beyond reducing connection count, what is the main value of an MCP gateway?
Q3What does an MCP registry provide?
Q4Your company has 15 MCP servers. A new rule says contractors may read tickets but never call the delete_ticket tool. Where is the best place to enforce it?
Q5How does an MCP gateway relate to an AI gateway?

Next

Gateways are the enforcement point for MCP security, and mirror the AI gateway for model providers. For the advanced server-side capabilities a gateway proxies, see advanced MCP primitives.

Sign in to track your progress

Completed lessons, your XP, level, and streak save to your account — it's free and takes a few seconds.

Practice this in an interview

All questions
What is the Model Context Protocol (MCP) and what problem does it solve?

MCP is an open protocol originally introduced by Anthropic that standardizes how an AI host discovers and uses tools, resources, and prompt templates exposed by separate servers. It solves bespoke integration sprawl by giving each server one common interface, while leaving model orchestration, permissions, and user approval to the host.

Why is OAuth token passthrough dangerous in an MCP server?

In a normal MCP deployment, blindly forwarding the client’s bearer token to a downstream API violates the token’s audience boundary and can create confused-deputy, replay, and audit risks. The server should validate a token intended for itself, authorize the tool call, and obtain a separate, narrowly scoped credential for the downstream resource.

How do MCP tool poisoning, cross-server shadowing, and rug pulls differ?

Tool poisoning is malicious instruction content in a tool description or result; cross-server shadowing uses one server’s names or content to influence or misroute another server’s capability; a rug pull changes a previously reviewed capability later. Defenses combine origin-aware namespaces, isolated trust contexts, capability snapshots and change review, exact-argument authorization, sandboxing, and runtime monitoring.

What is a model registry, and how does model versioning work in production ML systems?

A model registry is a central catalog for deployable model artifacts and their metadata, lineage, approvals, and immutable versions. Production systems promote a tested version through deployment controls, usually using a mutable alias such as champion while retaining the exact version for rollback and audit.

Related lessons

Explore further