# mcp stack — one shared MCP gateway for every agent on every machine. # # Before: each agent session (Claude Code, Codex, Gemini/Antigravity, ...) on # each machine spawned its own 9 npx/uvx/Go processes, with API tokens copied # into ~/.claude.json, ~/.codex/config.toml, ~/.gemini/... by hand. # Now: mcp-proxy runs those servers once here and exposes each over # streamable HTTP at https://mcp.ginnoir.com/servers//mcp # (SSE at .../sse for older clients). Clients hold a URL + one bearer token. # # Servers: arr, bookstack, ntfy, uptime-kuma, portainer, gitea, authentik, # freshrss, vault (list: gateway/servers.json; pins: gateway/Dockerfile). # Obsidian is NOT here: its Local REST API MCP runs inside the Obsidian app # itself (desktop-local, and valhalla's instance binds 127.0.0.1 only). # # Auth: MCP_PROXY_AUTH_TOKEN (stack.env) — every request, /status included, # needs `Authorization: Bearer `; mcp-proxy strips it from the child # env. Caddy additionally keeps it internal-only (LAN + tailnet). Not behind # Authentik forward_auth: agents can't do a browser login. # # The token is effectively admin over the lab (Portainer, Gitea, Authentik # writes). Treat it like the Portainer API key. Vault access is scoped: the # gateway holds a periodic mcp-gateway-policy token, not root (vault-policy.hcl; # kept alive by vault-token-renewer below). # # Upstreams are the public https://*.ginnoir.com names (same as the clients # used before); container -> Caddy hairpin passes internal_only (172.16/12). # # Image is built by .gitea/workflows/build-mcp-gateway.yml; no build: key here # (Portainer never builds — see portainer-never-builds-only-pulls). services: mcp-gateway: image: registry.ginnoir.com/ginnoir/mcp-gateway:latest pull_policy: always container_name: mcp-gateway restart: unless-stopped networks: [edge] env_file: - stack.env command: - --named-server-config=/app/servers.json - --pass-environment - --host=0.0.0.0 - --port=8096 - --allowed-host=mcp.ginnoir.com - --allowed-host=mcp-gateway:8096 - --log-level=INFO # No published port: only reachable through Caddy on edge. healthcheck: # /healthz needs the bearer token too. test: ["CMD-SHELL", "python -c \"import os,urllib.request as u;u.urlopen(u.Request('http://127.0.0.1:8096/healthz',headers={'Authorization':'Bearer '+os.environ['MCP_PROXY_AUTH_TOKEN']}),timeout=5)\""] interval: 60s timeout: 10s retries: 3 start_period: 60s # Keeps the gateway's scoped Vault token alive. VAULT_TOKEN is an orphan # periodic token (720h period, policy mcp-gateway — see vault-policy.hcl), NOT # root. A periodic token dies if not renewed within its period, so renew it # daily; on failure (e.g. Vault sealed) log + ntfy the homelab topic and retry # hourly. Same image digest as the Vault server (portainer-compose.yml). vault-token-renewer: image: hashicorp/vault@sha256:3fd53308acccd9e4e83fde3e6c6cf5b15e0f7fac1ff7510780b8b23f5e4c3de7 container_name: vault-token-renewer restart: unless-stopped networks: [edge] env_file: - stack.env labels: - com.centurylabs.watchtower.enable=false entrypoint: ["/bin/sh", "-c"] command: - | while :; do if out=$$(vault token renew -format=json 2>&1); then echo "$$(date -u +%FT%TZ) renewed (ttl $$(echo "$$out" | grep -o '"lease_duration": [0-9]*' | grep -o '[0-9]*')s)" sleep 86400 else echo "$$(date -u +%FT%TZ) RENEW FAILED: $$out" wget -q -O- --header "Title: mcp-gateway Vault token renew failed" \ --post-data "vault-token-renewer could not renew the gateway's Vault token (sealed?). It expires 30 days after the last good renewal. $$(echo "$$out" | tail -1)" \ "$$NTFY_URL/$$NTFY_TOPIC" >/dev/null 2>&1 || true sleep 3600 fi done networks: edge: name: edge external: true