MCP gateway with identityone door for every MCP client · four checks · every call on the record · GKE Autopilot behind a Cloudflare Tunnel

agentgateway v1.7Keycloak OAuth 2.1 + PKCECEL per tool × roleapprovals consoleledger Postgres + BigQueryCloud TraceCloudflare TunnelHeadlamp cluster UI

Repo: github.com/bhavishyajain545/gcp-ai-mcp-gateway · rebuild runbook: REBUILD.md

Demo (narrated)

Measured on the recorded run

19 s + 19 s
from claude mcp add to the first tool answer, including the browser sign-in
0
servers touched when a plain user calls a destructive tool (refused at the door, tool hidden from tools/list)
37 s
request → admin approval → executed, same call, nothing retried blindly
52 / 265 ms
p50 / p95 of a cheap tool call through Cloudflare → tunnel → gateway → server
168
personal values masked before the model saw them in the recorded calls
721 / 504
ledger rows (Postgres) vs tools/call rows in the gateway's BigQuery log, which lands a few minutes behind

How it works

The four checks, in the order a call meets them:

#checkwhat happenswhere
1identityunauthenticated → 401 + protected-resource metadata; client discovers Keycloak through the gateway, signs in with PKCE (the gateway's registration endpoint hands out one pre-registered public client, so Keycloak's audience mapper covers every client); the gateway verifies issuer, audience agentgateway, expiry, JWKSmcpAuthentication
2authorisationCEL on jwt.realm_access.roles × mcp.tool.name; read tools for mcp-user, destructive ones only for mcp-admin; tools/list is filtered, a forbidden call is 403 before any servermcpAuthorization
3approvala destructive tool parks the exact call as A-xxxxxx; the console (OIDC, admins) or its API approves/denies; the identical call executes once within 15 min@guarded, console
4recorde-mail, phone, PAN, Aadhaar, card numbers masked in the output; audit_log row with who/roles/tool/args/decision/latency/masks; OpenTelemetry span → Cloud Trace; JSON access log → BigQuery via a log sink@audited, OTel, sink

Connect

claude mcp add --transport http ops https://mcp.jainosoft.com/mcp      # Claude Code; then /mcp → sign in as alice (admin) or bob (user)
# Claude Desktop / Cursor: custom connector with the same URL
python drills/mcpctl.py tools --as bob                                   # the drills use the same door

Drills

drillshows
drills/rbac.shbob and alice see different tool lists; bob's destructive call is refused by the gateway
drills/approval.shthe full human-in-the-loop path with the seconds it took
drills/pii.shmasked customer rows next to what the database really holds
drills/latency.shend-to-end latency and the gateway's own metrics
drills/audit.shPostgres ledger vs BigQuery gateway log
drills/github.shGitHub's official MCP server (stdio in the gateway pod) behind the same identity

What I learned

Part of the GCP AI-platform series by Bhavishya Jain · portfolio.futurnex.io · Keycloak, the console and Headlamp are reached only through the tunnel; nothing here has a public IP.