Designing a Self-Hosted MCP Gateway for Every AI Client
An MCP gateway is a central entry point between AI clients and MCP servers. Instead of connecting each client directly to every server, clients send their requests through the gateway. This matters when many clients and servers need to work together: authentication and access rules can be managed in one place rather than repeated across separate tools. In this design, the gateway listens on port 443 on the LAN and NetBird mesh, with no public endpoint. People authenticate through Keycloak using OAuth 2.1, while server-based workloads use identities from SPIRE. The gateway checks tokens from those two issuers, applies permissions for each caller and tool, then connects to backend servers using mTLS. The proposed gateway would also centralize audit logging and rate limiting. MCP servers would accept calls only from the gateway's SPIFFE identity, keeping other callers out even inside the cluster. The team has not built it yet. A proof of concept must confirm that its candidate proxy supports both token issuers, SPIFFE mTLS to backends, and the metadata clients expect.
What is an MCP gateway, and how does it connect AI clients to MCP servers?
An MCP gateway is a central entry point between AI clients and MCP servers. Instead of connecting each client directly to every server, clients send their requests through the gateway. This matters when many clients and servers need to work together: authentication and access rules can be managed in one place rather than repeated across separate tools.
In this design, the gateway listens on port 443 on the LAN and NetBird mesh, with no public endpoint. People authenticate through Keycloak using OAuth 2.1, while server-based workloads use identities from SPIRE. The gateway checks tokens from those two issuers, applies permissions for each caller and tool, then connects to backend servers using mTLS.
The proposed gateway would also centralize audit logging and rate limiting. MCP servers would accept calls only from the gateway's SPIFFE identity, keeping other callers out even inside the cluster. The team has not built it yet. A proof of concept must confirm that its candidate proxy supports both token issuers, SPIFFE mTLS to backends, and the metadata clients expect.
How many MCP servers were already configured, and how many different AI client environments must the design support?
The starting point was a single Mac with 25 MCP servers configured. That setup included local processes, local Docker containers, and containers on Docker hosts. It was built around one person's use of Paradox Code, but the design had to account for more than that single client and machine.
The article lists four broad client environments: Paradox Code and Codex on macOS, Linux, and Windows; Hermes Agent; the self-hosted AI stack of open-webui, its pipelines, and n8n; and Home Assistant. The list makes clear that both desktop clients and server-based services need access. The clients do not all have the same capabilities.
This wider support requirement changed the design's starting point. Instead of configuring authentication separately for one client, the plan uses a shared internal gateway. It will accept people authenticated by Keycloak and workloads identified through SPIRE. The design is still a proposal; a proof of concept must verify that the selected gateway works with the clients and identity systems.
Why did configuring each MCP server separately stop working once more AI clients needed access?
Configuring MCP servers one client at a time worked for one person and one tool, but it did not provide a shared way for other AI clients to reach the same services. Each client could require its own server setup and credentials. That creates duplication and makes it harder to keep access rules consistent as the number of clients grows.
The original configuration shows the problem: local tokens sat in a JSON file in the user's home directory, while remote servers had mixed protections. Of six containers on Docker hosts, two had IP allow-lists, one of those also required a bearer token, and four had no authentication. Two local Docker containers failed because Docker was not on the PATH.
With clients such as Codex, Hermes Agent, open-webui, n8n, and Home Assistant in scope, the plan replaces scattered access with one gateway. Clients authenticate to that shared point, which checks permissions before routing calls. This moves the design away from per-client credentials and toward centrally managed access, though implementation still depends on a successful proof of concept.
How do people and server-based workloads prove their identities to the gateway?
The design separates people from server-based workloads because they can prove identity in different ways. People sign in through Keycloak using OAuth 2.1. Workloads such as open-webui, n8n, and agents running on servers receive identities from SPIRE. The gateway trusts exactly two issuers, so it has a defined set of identities to validate.
For people, interactive clients use the authorization-code flow with PKCE, and Keycloak issues short-lived tokens. Devices without a browser can use the device authorization grant. Workloads present either a JWT-SVID or use mTLS with an X.509-SVID. Both issuers provide signed JWTs for the gateway to validate, according to the design.
The gateway then decides what each caller may do with each tool. For example, Vault and Kubernetes MCP servers are limited to the user and named workloads, while write tools are for people unless a workload receives explicit permission. The proposal also requires backend servers to accept only the gateway's SPIFFE identity over mTLS. These controls are planned, not yet built.
Why use one gateway instead of adding authentication to every MCP server?
The design uses one gateway because the team runs more than a dozen MCP servers from many authors. Their authentication support varies: some accept bearer tokens, some support nothing, and none support SPIFFE. Adding authentication separately to every server would mean patching and maintaining many different codebases.
A gateway places authentication, authorization, audit logging, and rate limiting in one shared layer. The MCP servers can remain stock, and adding a server means adding a route and a policy. The gateway can also enforce the rule that backend pods accept only its SPIFFE identity over mTLS, rather than relying on each server to implement that control itself.
The trade-off is that the gateway becomes a single point of failure for AI tooling. The planned production setup therefore has two replicas. Agentgateway is the first candidate, but a proof of concept must check its support for both issuers, SPIFFE mTLS to backends, and Keycloak metadata. Envoy with an external authorization service is the fallback if it falls short.
What security benefits and risks follow from putting all MCP traffic through one internal gateway?
Routing all MCP traffic through one internal gateway gives the team a central place to authenticate callers, authorize tool access, log activity, and apply rate limits. The gateway listens on the LAN and NetBird mesh, not on a public endpoint. Backend servers accept only the gateway's SPIFFE identity over mTLS, so other callers cannot connect to them directly, even inside the cluster.
For example, the gateway would accept signed tokens from Keycloak and SPIRE, then decide which callers may use Vault, Kubernetes, Home Assistant, or write tools. The design also avoids exposing MCP servers directly to clients and avoids requiring every server to implement its own identity checks.
Centralization brings an availability risk: if the gateway fails, all AI tooling that depends on it can be affected. The article identifies it as a single point of failure and plans two production replicas. The gateway itself is not selected yet. Agentgateway must pass three checks, with Envoy and an external authorization service as the fallback.
What is the Model Context Protocol, and how does it let an AI application use tools provided by another service?
The article does not give a formal definition of the Model Context Protocol. As general background, MCP is a protocol that lets an AI application connect to external services that provide tools and other context. It gives the application and service a common way to communicate, rather than requiring a unique integration for every pair. This helps explain why the article discusses both AI clients and MCP servers.
In the article's setup, clients such as Paradox Code, Codex, and Home Assistant need access to MCP servers. Those servers provide services such as Vault, Kubernetes, and Home Assistant tools. The proposed gateway sits between clients and servers, authenticates callers, applies permissions per tool, and routes allowed requests to the right backend.
The article focuses on securing and sharing those connections, not on the protocol's full technical design. Its plan keeps MCP servers stock and puts access controls in a central proxy. The proxy has not yet been chosen: agentgateway is the first candidate, with Envoy as a fallback if the proof of concept does not meet requirements.
This brief was written by AI from the original reporting and checked by other models. Names, figures and quotes come from the source; read it for full context.
Read more in the JupiteX app
Pulse is free. New stories every 4 hours, each one broken into the questions that explain it.
Or read more news on the web