Microsoft MCP Gateway: how it works, how to deploy it, and its limits

Explainer · MCP

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 toolgateway StatefulSet, an MCP server that holds the tool catalog and forwards each tools/call to 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
MCP and management clients call the gateway's data plane and control plane; the data plane routes to adapter pods or the tool router, and the control plane deploys pods through the Kubernetes API. MCP Gateway serviceServer pods in the gateway namespaceMCP clientVS Code or an agentManagement clientREST API or /portal/Data plane/adapters/{name}/mcp/mcpControl plane/adapters and /tools CRUDmetadata in Redis or Cosmos DBAdapter podsone StatefulSet per serverTool gateway routertoolgateway StatefulSetKubernetes APIpods and readinessTool server podsone per registered toolbearer tokenready pod/mcpby tool namedeploy
Figure 1: One gateway service hosts both planes; adapters, the tool router, and tool servers run as pods in the gateway's namespace.

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-Name for tools/call and prompts/get (params.name) and for resources/read (params.uri).
  • Mcp-Param-* headers for arguments the tool's input schema annotates with x-mcp-header.
  • An Accept header listing both application/json and text/event-stream.
  • io.modelcontextprotocol/protocolVersion and io.modelcontextprotocol/clientCapabilities in params._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: 8000

The 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.

  1. Start a local image registry.
docker run -d -p 5000:5000 --name registry registry:2.7
  1. 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
  1. 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
  1. 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
  1. 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"
}
  1. 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, run kubectl 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.0
POST 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:

  1. Create a single-tenant app registration, such as mcp-gateway, and copy its Application (client) ID.
  2. Under Expose an API, keep the default api://<your-client-id> URI and add a scope named access.
  3. Authorize the Azure CLI (04b07795-8ddb-461a-bbee-02f9e1bf7b46) and VS Code (aebc6443-996d-45c2-90f0-388ff96faa56) as client applications for that scope.
  4. Create app roles, always including mcp.admin, and assign them as docs/entra-app-roles.md describes.

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 Infrastructure

After -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 $clientId

The 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 -EnablePrivateEndpoints flag covers Cosmos DB, not the container registry.
  • A strong random GatewaySettings:Secret shared by the mcpgateway and toolgateway pods. Router requests without a valid X-Gateway-Secret header get 401 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.admin holders, and callers holding a role listed in requiredRoles.
  • Write goes to the creator and mcp.admin holders 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.

An MCP client sends a tools/call to the gateway, which forwards the caller's identity and the shared secret to the tool router, which calls the tool pod only if the caller's roles allow it. MCP client2026-07-28mcpgatewaydata planetoolgatewaytool routerTool podregistered tool1POST /mcp tools/call2identity + secret3call if role allows4tool result5JSON or SSE6response
Figure 2: A tool call through /mcp. The gateway validates the token and MCP headers; the router checks the caller's read access to the tool.

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
View as Markdown

The AI Engineering Editors ·