Repo: github.com/bhavishyajain545/gcp-ai-mcp-gateway · rebuild runbook: REBUILD.md
claude mcp add to the first tool answer, including the browser sign-inThe four checks, in the order a call meets them:
| # | check | what happens | where |
|---|---|---|---|
| 1 | identity | unauthenticated → 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, JWKS | mcpAuthentication |
| 2 | authorisation | CEL 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 server | mcpAuthorization |
| 3 | approval | a 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 |
| 4 | record | e-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 |
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
| drill | shows |
|---|---|
drills/rbac.sh | bob and alice see different tool lists; bob's destructive call is refused by the gateway |
drills/approval.sh | the full human-in-the-loop path with the seconds it took |
drills/pii.sh | masked customer rows next to what the database really holds |
drills/latency.sh | end-to-end latency and the gateway's own metrics |
drills/audit.sh | Postgres ledger vs BigQuery gateway log |
drills/github.sh | GitHub's official MCP server (stdio in the gateway pod) behind the same identity |
aud=account and the gateway rejects them. Handing every client the same pre-registered public PKCE client through the gateway's registration endpoint keeps one audience, one set of redirect rules, and no "Trusted Hosts" surprises.kube-system, a managed namespace Autopilot refuses to write to; after an hour of evictions and probe tuning the honest answer was Headlamp, which needs nothing special.iss on the authorization response and Claude Code refuses the mismatch. Pointing authorization_servers straight at Keycloak, with a realm-default client scope carrying the audience mapper, made both pre-registered and dynamically registered clients work.