Designing a Self-Hosted MCP Gateway for Every AI Client
When I counted, Claude Code on my Mac had 25 MCP servers configured. Some ran as local processes started with npx or uvx . Two ran as local Docker containers, and both failed because Docker wasn't on the PATH. Six ran as containers on one of our Docker hosts behind Traefik. Of those six, two were protected by an IP allow-list, one of those also required a bearer token, and four had no…
The author counted 25 MCP servers configured for Claude Code on a Mac, with various authentication methods in place. Six of these servers ran as containers on a Docker host behind Traefik, with differing authentication levels. The design aims to create a self-hosted MCP gateway for all AI clients, including Claude Code, Codex, Hermes Agent, Home Assistant, open-webui, and n8n.
OAuth with a short-lived bearer token is the only supported method for all interactive clients, while mutual TLS is not feasible due to limitations on mobile devices. The gateway serves as a single entry point, utilizing Keycloak for user authentication and SPIRE for workload identification. Workloads such as open-webui, n8n, and agents receive SPIFFE identities and present JWT-SVIDs or use mTLS with X.509-SVIDs.
The gateway accepts tokens from Keycloak and SPIRE, validating them uniformly. It then enforces permissions for each workload, ensuring only authorized access. SPIFFE simplifies workload management but has limitations in accommodating human users and certain API requirements. The gateway approach consolidates authentication and authorization, enabling a unified solution for multiple MCP servers without extensive modifications.
The author plans to implement SPIRE on a non-production Talos cluster and set up the Vault login for SPIFFE identities in subsequent phases.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to