Repository navigation
Description
Depends on: #2728 (the Gateway interface, with tools listed over HTTP), #2538 (keys and gateway entries), #2539 (pre-approval part), #2811 (fixture on the pinned ToolHive version); the "to file" row in "Phase 3, Track: ToolHive — The remaining ToolHive changes for audit, sign-out, and schedules" (#2570) for subject mode and approval settings in run config and the CRD
Problem
Only the embedded gateway implements the gateway interface, and the broker knows of only one gateway. An external gateway's administrator has no way to get the broker's keys or setup values. Nothing shows that Mecatl works with a gateway it does not run, so external mode would first run in a customer deployment.
Implements
- mcp-gateway-modes.md: Integration requirements and evidence limits
- mcp-gateway-modes.md: Gateway administrator configuration
- credentials-and-lifecycle.md: (6) Per-operation authorization: check 6
- credentials-and-lifecycle.md: (5) Broker client authentication and the key-set row of Lifetimes and renewal
- implementation.md: Credential verification: the external-mode bullets
Scope
The Gateway implementation PR lands first.
- Gateway: HTTP only, built from the gateway entry (MCP endpoint, vMCP resource, AS-2 issuer, token endpoint). Keys and gateway entries for the identity broker #2538's entry has no MCP endpoint field: this ticket adds it, and an optional in-cluster address if the question below settles on one. Keys and gateway entries for the identity broker #2538's
token_endpointis AS-2's advertised endpoint, never a dial address. Tool calls and listing (List gateway tools with a broker-issued token #2729) use the same code as the embedded gateway. The gateway must serve MCP2025-11-25(initialize), which the gateway paths pin; a gateway that serves only2026-07-28needs Support MCP 2026-07-28 on the gateway call and listing paths #2917. - Several gateways: the broker holds a list of gateway entries. Check 6 picks the gateway whose routed servers include the call's server, and server names are unique across gateways. Binding is keyed by the AS-2 issuer. Both brokers pick the same gateway and refuse a token whose resource names another one.
- Keys: the broker client key set is given to administrators as an inline JWK set they can copy. Rotation adds and removes the key at each external gateway, and restarts the gateway if ToolHive still reads the key set only at startup.
- Operator guide: what the gateway's administrator receives: AS-1's issuer, client
mecatland its keys, the subject claim AS-2 must also use, and single use for AS-1's issuer (recommended). What comes back: the AS-2 issuer and the vMCP resource. Also the rotation steps. - Helm: egress to each external gateway's AS-2 and vMCP.
- Fixture and test: a separately deployed ToolHive gateway in kind, set up as the administrator configuration describes. It uses the approval-record subject mode, pre-approval, per-user connections, and operator-supplied broker keys (generated keys change on every restart). A second source issuer has no shared IdP. Both gateways run the pinned ToolHive version. The approval-link cases are added when Users and administrators approve Mecatl at an external gateway #2539's link part lands.
Decide before starting
Does the broker call a gateway's public token endpoint through an ingress, which needs DNS, CA trust, and hairpin routing inside the cluster? Or does the gateway entry carry an optional in-cluster address, with the issuer and aud kept public? The same choice applies to the embedded gateway after #2807.
Done when
In CI, the MCP client reaches the external fixture through the same code it uses for the embedded gateway, and tool calls and listing work against both. These cases pass: pre-approval, an unapproved user, no shared IdP, revocation, and connected calls that use only the user's own credential. A user without a connection is asked to connect, with the gateway's link, and the call continues after they connect, against an external gateway that sends the chosen signal ("Ask users to connect a provider before the call (authorization pending)" (#2592)).
Earlier notes: #2540 (closed, merged here).
Activity
[-][Phase 3] External gateway implementation of the Gateway interface[/-][+]External gateway: Gateway implementation, operator setup, and end-to-end test[/+]ChrisJBurns commentedon Nov 18, 2026
Design decision for this ticket: Does a gateway entry carry an optional in-cluster address the broker dials, while the issuer and
audstay public, or does the broker always use the public token endpoint through an ingress? The same applies to the embedded gateway once it is its own deployment.Where it goes: mcp-gateway-modes.md: Gateway administrator configuration.
Decide it when this ticket is picked up, and record the answer as a small design edit (reviewed by the design's author) before or with the ticket's first PR.
fix(mcpbroker): take the embedded gateway endpoint from its resource
jhrozek commentedon Nov 20, 2026
Notes from the review of #2887 for the external gateway work. None of these is a bug today; they become real once a gateway runs outside the Mecatl process.
Prove that the endpoint serves the resource
Today the gateway token can only reach the embedded vMCP: the in-process HTTP client refuses every URL except the endpoint (
gatewayInProcessClient,internal/app/mcp_broker_construction.go). Once the gateway is built from a gateway entry, the endpoint and the vMCP resource are two operator-configured strings, and the startup check only compares the resource with AS-2's resource. Example: endpointhttps://evil.example/mcp, resourcehttps://gateway.example/mcp. The check passes, and every call sends a bearer token with audiencehttps://gateway.example/mcptoevil.example.Proposal: at startup, fetch the gateway's RFC 9728 metadata and require its
resourceto equalGateway.Resource()exactly.mcp.DiscoverDirectIssuer(internal/adapter/mcp/direct_discovery.go). It already requires an exact HTTPS resource, refuses redirects on the probe, requires the metadata'sresourceto equal the URL exactly and to name exactly one authorization server, caps the body, and then fetches that server's metadata. So one call also checks the entry's AS-2 issuer and token endpoint.discovery.FetchResourceMetadata(pkg/auth/discovery) is not a good fit. It only checks thatresourceis not empty ("For now we just check it's not empty"), allows plain HTTP for localhost, follows same-host redirects, and logs through the defaultslog.auth.NewAuthInfoHandler), so nothing is needed on the gateway side.DiscoverDirectIssuerfetches from the resource's own address, so that case needs a small transport on top.Keep the token's resource tied to the gateway it is sent to
There are two copies of the vMCP resource. The MCP client has
mcpbroker.Gateway.Resource(), and the identity broker hasidentitybroker.GatewayAS2.Resource. At call time the token is requested for the identity broker's copy (identitybroker/authorize.go,IssueIDJAGandRedeemboth useas2.Resource), but it is sent to the MCP client'sGateway.Endpoint()(mcpbroker/gateway_call.go). The only place the two copies are compared ischeckGatewayResourceinbuildBundledMCPBroker.BindGatewayAS2checks only that the fields are non-empty.Today both copies come from the same
process.AS2, so they cannot differ. With several gateways built from gateway entries, a token for gateway A could be sent to gateway B if gateways are built or AS-2 is bound outsidebuildBundledMCPBroker.Proposal: enforce the rule where binding and gateway selection happen, not only at bundled startup. Either check inside
BindGatewayAS2against the gateway entry, or have the authorizer take the resource from the gateway the call is sent to. This is the same rule this issue states: "Both brokers pick the same gateway and refuse a token whose resource names another one."docs(agent-identity): record the review's follow-ups on call binding