Microsoft MCP Gateway: how it works, how to deploy it, and its limits
Microsoft MCP Gateway is an open-source reverse proxy and management layer that deploys Model Context Protocol servers into Kubernetes and routes MCP requests to them. The project lives at microsoft/mcp-gateway on GitHub under the MIT license, and its latest release as of November 2026 is v1.0.1. This explainer covers its architecture, local and Azure setup, access control, how it differs from Azure API Management, and its documented limits. The MCP topic hub collects related guides.
What is Microsoft MCP Gateway?#
Microsoft MCP Gateway is a self-hosted MCP gateway that runs MCP servers as Kubernetes workloads and forwards each MCP request to a ready server pod. It is written in C# on .NET 8, ships as two container images (the gateway and a tool gateway router), and stores resource metadata in Redis locally or Azure Cosmos DB in the cloud.
v1.0.0 was tagged on October 16, 2026, two weeks after the maintainers rebuilt the gateway around MCP revision 2026-07-28. v1.0.1, released on November 16, 2026, is a security fix that the release notes say all deployments should take. Tool invocations previously followed HTTP redirects, so a tool pod could make the gateway fetch another reachable host and return that response as the tool result. A redirect now comes back as a tool error. Deployments that pull the latest images restart onto the fix with:
kubectl rollout restart deployment/mcpgateway statefulset/toolgateway -n <namespace>The repository's GitHub description still mentions "session-aware stateful routing," a design older write-ups describe; the README now describes stateless routing.
How the control plane and data plane work#
Microsoft MCP Gateway runs a control plane and a data plane in one ASP.NET service. The control plane is a REST API that deploys, updates, and deletes MCP servers as Kubernetes resources. The data plane accepts MCP requests over the Streamable HTTP transport, checks the caller's bearer token and roles, and forwards each request to a ready backend pod.
Three building blocks carry the traffic:
- Adapters are complete MCP server images, each with its own URL,
/adapters/{name}/mcp. - Tools are containers that serve one HTTP tool, registered with an MCP tool definition that includes a JSON Schema for its input. Tools share one URL,
/mcp. - The tool gateway router is the
toolgatewayStatefulSet, an MCP server that holds the tool catalog and forwards eachtools/callto the matching tool server.
| Plane | Endpoint | What it does |
|---|---|---|
| Control | POST /adapters, POST /tools |
Deploys and registers an MCP server or a tool |
| Control | GET /adapters, GET /tools |
Lists the resources the caller can read |
| Control | GET /adapters/{name}/status, GET /adapters/{name}/logs |
Returns deployment status and logs (same paths under /tools) |
| Control | PUT and DELETE on /adapters/{name} or /tools/{name} |
Updates or removes the deployment |
| Data | POST /adapters/{name}/mcp |
Sends one MCP request to one adapter; returns JSON or a request-scoped event stream |
| Data | POST /mcp |
Sends one MCP request to the tool gateway router |
The gateway also serves a React management portal at /portal/ with pod logs and a JSON-RPC test console.
Stateless routing and the MCP 2026-07-28 requirement#
Microsoft MCP Gateway routes each MCP request independently: it authorizes the request, picks a ready backend pod, and keeps no MCP transport session. Since the October 2026 rewrite, it accepts only MCP revision 2026-07-28 clients and adapters. The README calls this a breaking change, with no legacy initialization, transport sessions, or protocol downgrade.
The gateway tracks ready pods through a Kubernetes watch and sends each request to one chosen at random; a 503 means none are ready.
The migration guide lists what every POST must carry:
MCP-Protocol-Version: 2026-07-28, matching the version in the request body.Mcp-Method, set to the JSON-RPC method.Mcp-Namefortools/callandprompts/get(params.name) and forresources/read(params.uri).Mcp-Param-*headers for arguments the tool's input schema annotates withx-mcp-header.- An
Acceptheader listing bothapplication/jsonandtext/event-stream. io.modelcontextprotocol/protocolVersionandio.modelcontextprotocol/clientCapabilitiesinparams._meta.
These headers come from the protocol. The 2026-07-28 transports page says Streamable HTTP mirrors selected body fields into HTTP headers so intermediaries can route requests without parsing the body. The explainer on what the Model Context Protocol is covers the stateless revision.
The initialize handshake is rejected, GET and DELETE on MCP endpoints return 405, streams cannot resume with Last-Event-ID, and Mcp-Session-Id no longer affects routing. Tools that need state across calls should pass an explicit handle as an argument. Clients or adapters that cannot upgrade must stay on an earlier gateway image pinned by tag or digest.
How the gateway runs on Kubernetes#
The local manifest puts everything in one namespace, adapter: the gateway Deployment, the tool gateway router StatefulSet, a Redis Deployment for resource metadata, two service accounts, a namespaced Role, and three NetworkPolicies. Each adapter or tool registered through the API then becomes its own StatefulSet and a Service named <name>-service in that namespace.
In deployment/k8s/local-deployment.yml, mcpgateway and toolgateway run one replica each on port 8000, and Redis (redis:7-alpine) accepts connections only from those two. The app-manager Role lets the gateway's service account manage StatefulSets, services, pods, and pod logs in that namespace only, and deployed servers run under a separate workload-sa account.
The deployment manager code fixes the shape of every server pod. It pulls imageName and imageVersion from the configured registry, exposes port 8000, runs as user and group 1100, blocks privilege escalation, drops all Linux capabilities, and caps each container at 1 CPU, 512Mi of memory, and 2Gi of ephemeral storage. The API accepts a replica count but no resource settings, so a server that needs more memory requires a code change.
This NetworkPolicy, copied from the local manifest, limits who can reach server pods:
# NetworkPolicy: Only mcpgateway and toolgateway can reach adapter/tool pods
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: adapter-access
namespace: adapter
spec:
podSelector:
matchExpressions:
- key: adapter/type
operator: In
values: [mcp, tool]
policyTypes:
- Ingress
ingress:
- from:
- podSelector:
matchLabels:
app: mcpgateway
- podSelector:
matchLabels:
app: toolgateway
ports:
- protocol: TCP
port: 8000The mcp-proxy sample warns against loosening it just to chain proxies between adapters.
How to run Microsoft MCP Gateway locally#
The README's local path runs the full stack on the Kubernetes cluster built into Docker Desktop. It needs the .NET 8 SDK, Docker Desktop with Kubernetes turned on, and a local image registry on port 5000. The commands below are copied from the README and run from the repository root.
- Start a local image registry.
docker run -d -p 5000:5000 --name registry registry:2.7- Build and push the sample MCP server.
docker build -f sample-servers/mcp-example/Dockerfile sample-servers/mcp-example -t localhost:5000/mcp-example:1.0.0
docker push localhost:5000/mcp-example:1.0.0- Publish the gateway image and the tool gateway router image.
dotnet publish dotnet/Microsoft.McpGateway.Service/src/Microsoft.McpGateway.Service.csproj -c Release /p:PublishProfile=localhost_5000.pubxml
dotnet publish dotnet/Microsoft.McpGateway.Tools/src/Microsoft.McpGateway.Tools.csproj -c Release /p:PublishProfile=localhost_5000.pubxml- Apply the manifest and forward the gateway port.
kubectl apply -f deployment/k8s/local-deployment.yml
kubectl port-forward -n adapter svc/mcpgateway-service 8000:8000- Create an adapter for the sample server.
POST http://localhost:8000/adapters
Content-Type: application/json{
"name": "mcp-example",
"imageName": "mcp-example",
"imageVersion": "1.0.0",
"description": "test"
}- Point a 2026-07-28 client, such as an up-to-date VS Code, at
http://localhost:8000/adapters/mcp-example/mcp. To remove everything, runkubectl delete namespace adapter.
Treat this stack as a sandbox. The manifest sets ASPNETCORE_ENVIRONMENT to Development, which replaces Entra ID with a handler that signs in unauthenticated requests and reads X-Dev-UserId and X-Dev-Roles headers, so any caller can claim mcp.admin. Its Redis password and gateway secret are plain values marked for local development only.
Register a tool behind the tool gateway router#
A registered tool puts a small HTTP service behind the shared /mcp endpoint. Build the sample tool server, then register it with its MCP tool definition:
docker build -f sample-servers/tool-example/Dockerfile sample-servers/tool-example -t localhost:5000/weather-tool:1.0.0
docker push localhost:5000/weather-tool:1.0.0POST http://localhost:8000/tools
Content-Type: application/json{
"name": "weather",
"imageName": "weather-tool",
"imageVersion": "1.0.0",
"description": "Weather tool for getting current weather information",
"toolDefinition": {
"tool": {
"name": "weather",
"title": "Weather Information",
"description": "Gets the current weather for a specified location.",
"type": "http",
"inputSchema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
}
},
"required": ["location"]
}
},
"port": 8000
}
}Check GET http://localhost:8000/tools/weather/status, then connect a client to the router with the README's .vscode/mcp.json:
{
"servers": {
"tool-gateway": {
"url": "http://localhost:8000/mcp"
}
}
}Use an adapter for a complete MCP server image; the mcp-proxy sample also wraps a stdio server (MCP_COMMAND, MCP_ARGS) or an existing HTTP server (MCP_PROXY_URL). Use a tool for small HTTP functions meant for tool calling, served from one catalog the router filters per caller. The tutorial on how to build an MCP server covers writing a server to package as an adapter.
Deploying Microsoft MCP Gateway on Azure#
The documented cloud path targets Azure only. A Bicep template provisions AKS, Azure Container Registry, Cosmos DB, Application Gateway, Application Insights, managed identities, a public IP, and a virtual network, and the deployed gateway then requires Microsoft Entra ID bearer tokens. The deployment needs an Azure subscription with Owner access and the Azure CLI.
Entra ID comes first:
- Create a single-tenant app registration, such as
mcp-gateway, and copy its Application (client) ID. - Under Expose an API, keep the default
api://<your-client-id>URI and add a scope namedaccess. - Authorize the Azure CLI (
04b07795-8ddb-461a-bbee-02f9e1bf7b46) and VS Code (aebc6443-996d-45c2-90f0-388ff96faa56) as client applications for that scope. - Create app roles, always including
mcp.admin, and assign them asdocs/entra-app-roles.mddescribes.
The infrastructure README recommends its PowerShell script; basic usage, from the repository root:
.\deployment\Deploy-McpGateway.ps1 -SubscriptionId "<subscription-id>" -TenantId "<tenant-id>" -ResourceGroupName "rg-mcpgateway-dev" -ResourceLabel "mcpdev" -ClientId "<your-entra-client-id>" -Stage InfrastructureAfter -Stage Infrastructure, build the images into the new registry, then run -Stage Kubernetes with exact -GatewayImage and -ToolGatewayImage references. Production defaults are two Standard_D4ds_v5 nodes. Pass tlsCertificateData and tlsCertificatePassword through -SecureParametersFile before sending tokens; without them the template exposes only an HTTP listener meant for bring-up. Callers get a token with:
az account get-access-token --resource $clientIdThe README's production checklist leaves this work to the operator:
- HTTPS on the Application Gateway listener with valid certificates.
- Virtual network restrictions and Private Endpoints; the script's
-EnablePrivateEndpointsflag covers Cosmos DB, not the container registry. - A strong random
GatewaySettings:Secretshared by themcpgatewayandtoolgatewaypods. Router requests without a validX-Gateway-Secretheader get401 Unauthorized. - Telemetry, alerts, and scaling, plus finer-grained RBAC or custom ACLs for adapter-level permissions.
Streaming must stay unbuffered at the ingress; the Application Gateway template disables buffering and sets a 600-second backend timeout.
Access control with Entra ID app roles#
Microsoft MCP Gateway authorizes each request from three inputs: who created the resource, whether the caller holds the mcp.admin app role, and the resource's requiredRoles list. In cloud mode, identity and roles come from a validated Entra ID token. Read access lets a caller list a resource and send it MCP traffic; write access lets a caller update or delete it.
- Read goes to the creator,
mcp.adminholders, and callers holding a role listed inrequiredRoles. - Write goes to the creator and
mcp.adminholders only.
The documentation disagrees on one default. The README says an empty requiredRoles list leaves reads to the creator and mcp.admin, while docs/entra-app-roles.md says an empty list allows all reads. The SimplePermissionProvider code matches the README, so test the behavior before relying on either document.
On the /mcp path, the gateway forwards the caller's user ID and roles to the router under the shared gateway secret, and the router applies the same rules per tool. Adapter pods never receive that secret.
Setting useWorkloadIdentity: true binds a pod to the namespace's shared workload-sa federated identity, so any container in it can mint Entra ID tokens. By default only mcp.admin holders can set the flag, with no exception for the creator. In production mode the gateway also publishes OAuth Protected Resource Metadata naming the Entra tenant as the authorization server, the discovery step described in the MCP security guide.
Microsoft MCP Gateway vs Azure API Management and other Azure MCP gateways#
Microsoft MCP Gateway is open-source software that deploys and runs MCP servers in a cluster. The MCP server features in Azure API Management belong to a managed service that fronts existing MCP servers or turns REST APIs into MCP tools, then applies policies. Searches for an Azure MCP gateway return both, plus two newer Azure products.
| Microsoft MCP Gateway | Azure API Management MCP servers | AI Gateway | Application Gateway for Containers | |
|---|---|---|---|---|
| What it is | Open-source reverse proxy and management layer (MIT) | MCP features of a managed API service | Managed gateway for model and MCP traffic | Kubernetes ingress with an MCPRoute resource |
| Where it runs | Your Kubernetes cluster; documented on AKS | Azure, or its self-hosted gateway | Azure (Microsoft.ApiManagement/aigateways) |
Azure, in front of an AKS cluster |
| Deploys MCP server containers | Yes, as StatefulSets | No | No | No; routes to existing Services |
| What it fronts | Adapter images and HTTP tools | REST APIs it manages and existing MCP servers | Remote MCP servers, OpenAPI APIs, built-in connectors | One or more MCP server Services, aggregated |
| Traffic policies | Per-resource Entra roles; no documented rate limits | Rate limits, quotas, JWT validation, IP filtering, caching | Access, consumption limits, tool protection | JWT AuthPolicy, WAF policy |
| Protocol notes | Stateless; MCP 2026-07-28 only | Tools only, no resources or prompts | Federates tools behind one MCP endpoint | Optional best-effort session affinity; preview |
The API Management column comes from its MCP server overview, which lists the supported classic and v2 tiers. AI Gateway shares a resource provider with API Management but is a separate product. The Application Gateway for Containers MCP guide marks MCP routing as preview.
API Management and AI Gateway suit teams that need managed rate limiting, quotas, and monitoring in front of servers that run elsewhere; the explainer on what an AI gateway is covers the model traffic they also handle.
Documented limits of Microsoft MCP Gateway#
Microsoft MCP Gateway's documented limits fall into three groups: a single protocol revision, Azure-specific wiring for identity and storage, and traffic controls left to the operator. Each row names where the limit is stated or implemented on the main branch as of November 2026.
| Area | Limit | Where it is stated |
|---|---|---|
| Protocol | MCP 2026-07-28 only, with no legacy initialization or downgrade | README |
| Request size | Each MCP request body at or below 4 MB, or the gateway returns 413 |
Migration guide |
| Streams | JSON or request-scoped SSE; not resumable, and closing a stream cancels the request | Migration guide |
| Identity and storage | Outside Development mode, Entra ID and Cosmos DB are wired in code | Program.cs |
| Secrets | Management GET and LIST responses include adapter environmentVariables |
mcp-proxy README |
| Agents and sessions | Preview and single-replica; built-in shell and file tools disabled for all callers | README |
| Traffic controls | No rate limits, quotas, or budgets described; telemetry goes to Application Insights | README, Program.cs |
Permissions apply per adapter and per tool. The documentation does not describe filtering individual tools inside one adapter or checking tool arguments.
When Microsoft MCP Gateway fits#
Microsoft MCP Gateway fits a platform team that already runs AKS with Entra ID and wants to host MCP servers as containers behind one lifecycle API, with per-server roles and stateless routing that scales by adding replicas. It fits poorly when clients or servers cannot move to MCP 2026-07-28, when the platform is not Azure, or when the gateway itself must enforce rate limits or budgets.
A practical first step is the local stack: register one internal MCP server image as an adapter and read its logs through GET /adapters/{name}/logs before planning an Azure rollout. The MCP security guide lists the controls the gateway leaves to the operator, such as tool allowlists and approval for write actions.
For alternatives, the MCP platforms directory lists registries, hosted tool platforms, and MCP gateways, and the AI gateways directory lists gateways that handle MCP traffic alongside model calls.
Frequently asked questions
Is Microsoft MCP Gateway open source?
- Yes. Microsoft MCP Gateway is published at github.com/microsoft/mcp-gateway under the MIT license. The gateway and the tool gateway router are written in C# on .NET 8, the management portal is a React app, and the sample servers are Python. Most contributions require Microsoft's Contributor License Agreement. The code is free, but the documented Azure deployment creates billable resources such as AKS, Cosmos DB, and Application Gateway.
What is the difference between Microsoft MCP Gateway and Azure API Management?
- Microsoft MCP Gateway is self-hosted open-source software that deploys MCP server containers into Kubernetes and routes requests to them. Azure API Management is a managed Azure service that exposes a REST API it manages as an MCP server, or fronts an existing MCP server, and applies policies such as rate limits, quotas, JWT validation, and IP filtering. API Management does not deploy servers and currently supports MCP tools but not resources or prompts.
Can Microsoft MCP Gateway run outside Azure?
- Only for local testing. The local manifest runs on a Kubernetes cluster such as the one built into Docker Desktop, with Redis for resource metadata and a development sign-in handler that accepts any caller. Outside Development mode, the code wires authentication to Microsoft Entra ID and resource storage to Azure Cosmos DB, so a production deployment on another cloud or identity provider means changing and maintaining that code.
Does Microsoft MCP Gateway support session affinity?
- No. Since it adopted MCP 2026-07-28 in October 2026, Microsoft MCP Gateway sends each request to a randomly chosen ready pod, and Mcp-Session-Id, Last-Event-ID, and its old session_id query parameter no longer affect routing. A server that keeps session state in memory needs an earlier gateway image or a redesign that passes an explicit handle between calls. Application Gateway for Containers offers best-effort session affinity in preview.
Which MCP clients work with Microsoft MCP Gateway?
- Clients that implement MCP revision 2026-07-28 over Streamable HTTP. Each POST must carry the MCP-Protocol-Version, Mcp-Method, and, for tool calls, Mcp-Name headers, plus the protocol version and client capabilities in params._meta. The README tests with VS Code and asks that it be kept up to date. Clients that still send an initialize handshake are rejected, and the gateway has no setting to accept them.
How does Microsoft MCP Gateway authenticate users?
- In cloud mode, Microsoft MCP Gateway validates Microsoft Entra ID bearer tokens issued for its app registration and reads app-role claims, such as mcp.admin, to decide read and write access per adapter or tool. It also publishes OAuth Protected Resource Metadata that names the Entra tenant as the authorization server. In Development mode, a test handler signs in every unauthenticated request, so that mode must stay off public networks.
Terms in this guide
Cite this guide
The AI Engineering Editors. "Microsoft MCP Gateway: how it works, how to deploy it, and its limits." The AI Engineering, updated Nov 27, 2026. https://theaiengineering.com/articles/microsoft-mcp-gateway
- Title
- Microsoft MCP Gateway: how it works, how to deploy it, and its limits
- Author
- The AI Engineering Editors
- Publisher
- The AI Engineering
- Published
- Updated