Repository navigation
Description
Mecatl change in the MCP broker's HTTP surface (mecak8s and mecated). No ToolHive dependency.
Problem
The embedded gateway's authorization server is reachable without signing in: its token, authorize, consent, callback, discovery, and key-set routes. mecak8s and mecated mount the MCP broker's routes with no rate limit and no cap on the request body or query (HandlerBundle.Mount, internal/adapter/mcpbroker/handlers.go; mountBrokerHandlers, cmd/mecak8s/serve.go; cmd/mecated/main.go). Anyone who can reach the server can flood them or send oversized requests.
AS-1's routes on the same mux already have both: global rate limits, with the token endpoint and the sign-in routes in separate buckets, plus query and body caps (limitAS1, cmd/mecak8s/serve.go).
This predates the identity broker, since gateway logins already used these routes. #2738 makes it matter more: with the identity broker on, the same server is AS-2, and its token endpoint also redeems ID-JAGs for gateway tokens.
Design
- threat-model.md: "Anonymous traffic at AS-1" covers AS-1's routes only. Add the embedded AS-2's routes to it.
- mcp-gateway-modes.md: Embedded mode
- implementation.md: Modulith constraints: no in-process shortcut may skip a check.
Requirements
- Rate-limit the embedded authorization server's routes with global limits, the token endpoint in its own bucket, and cap the query and request body, as
limitAS1does for AS-1. Apply them wherever the MCP broker's routes are mounted, in mecak8s and mecated. - The broker's own calls. While the identity broker shares the process, it reaches AS-2's token endpoint in process through
mcpbroker.AS2.Handler()(Wire the embedded gateway's authorization server into startup as AS-2 #2738), not through the mux. Apply the same body and query caps on that path, so it skips no check the network route makes. - Decide whether the broker's ID-JAG redemptions share the public token bucket. If they do, a flood of anonymous token requests refuses users' gateway calls; consider a separate budget for the in-process path.
- Decide whether the limits are fixed, like AS-1's, or operator settings (Keys and gateway entries for the identity broker #2538).
Done when
- Requests beyond the token endpoint's budget get 429, oversized queries get 414, and oversized bodies are refused, on the mounted routes in mecak8s and mecated.
- Flooding the sign-in routes doesn't exhaust the token endpoint's budget.
- The in-process path to AS-2 applies the same caps.
- With no protected MCP route, nothing changes.
Activity
ChrisJBurns commentedon Nov 13, 2026
Moved from phase 1 (#2455) to phase 2 (#2558): this is hardening, and phase 1 doesn't need it. A phase 1 attempt (#2781) was closed so this can be redone from scratch after #2560.
When picking this up, also decide:
AS2.Handler().as1server.InProcessClientskips the capsmountAS1applies.implementation.md("Modulith constraints") says in-process calls get the same checks and limits. Decide whether that means size caps only, not the public rate buckets, and update the wording.0meaning disabled, on by default, covering AS-1 and AS-2 together (Keys and gateway entries for the identity broker #2538). Size caps stay fixed and always on. ToolHive v0.63.0 already caps every auth-server body at 64 KiB.