Repository navigation
Description
Depends on: a pinned ToolHive release that resolves ID-JAG subjects ("Delegated access: turn on subject resolution at ID-JAG redemption" (stacklok/toolhive#7247), in v0.70.1).
Part of this ticket is done (#3002): AS-2 trusts AS-1 for ID-JAGs only, issues at+jwt gateway tokens, fetches AS-1's keys from a private address only when asked, and tests cover its step (8) refusals and the vMCP's refusal of bad gateway tokens. This ticket is the rest.
Problem
The embedded gateway's authorization server is meant to act as AS-2. In production it trusts no ID-JAG issuer, so every authorized gateway call fails closed, and mecak8s refuses servers in the identity broker's embedded gateway entry. Only tests trust an AS-1, one they start themselves, and only for subjects they list. The gateway token names the AS-1 subject rather than a gateway user, so the gateway cannot find that user's provider credentials.
Design
Implements:
- mcp-gateway-modes.md: Embedded mode
- mcp-gateway-modes.md: How AS-2 resolves the user
- mcp-gateway-modes.md: Who holds what
- credentials-and-lifecycle.md: (8) AS-2 access token: checks 6 and 7, the output, and the failures
- credentials-and-lifecycle.md: Identifying claim
- implementation.md: Credential verification ("Test AS-2 redemption")
Requirements
With the identity broker on:
- Trust in AS-1. AS-2 trusts AS-1 in production, as an ID-JAG issuer only, for any subject AS-1 names. User resolution decides who is redeemed, not a list of subjects.
- AS-1's signing keys. AS-2 fetches AS-1's keys from AS-1's issuer, over HTTPS. Two operator settings, both off by default, cover an AS-1 issuer at a private address with a private CA, as in a cluster: allowing private addresses for that fetch, and a CA bundle to trust. Both are exposed in the Helm chart and described in the operator guide. A private key-set address without the setting fails at startup.
- Company IdP sign-in at AS-2. AS-2's sign-in starts with the same company IdP as AS-1. It uses its own application registration there: the operator supplies its client ID and secret. The IdP issuer, its CA and the identifying claim come from AS-1's settings, so the two can't differ. AS-2 forces no prompt, so the step is silent while the company session is live.
- User resolution. AS-2 finds the gateway user from the ID-JAG's
upstream_subject, using the same identifying claim as AS-1, and never throughsub_id, email or display name. Approval is implicit, set by configuration. An unknown or ambiguous user is refused withsubject_unknown, and AS-2 creates no user while looking one up. - Who may redeem. Only client
mecatlmay redeem, with the agent trust domain as the actor's issuer, for the vMCP resource. Anything else is refused withactor_deniedorresource_denied. - Gateway token. It names the gateway user, keeps the ID-JAG's
actand the clientmecatl, is for the vMCP only, carries the delegated-access marker, lives no longer than the ID-JAG, and comes with no refresh token. A marked token is refused at token exchange, whether presented as the subject or the actor token. - Production gateway entry. Startup accepts servers in the broker configuration's embedded gateway entry, in mecak8s and in the Helm chart.
- Operator guide. It covers AS-2's registration at the company IdP and the caveats real IdPs bring: a first-time consent screen (in Entra, grant admin consent), an account picker when several accounts are signed in, and conditional access or MFA step-up.
With the flag off, nothing changes.
Not here: using the user's provider credential and the connect link (#2537), tool listing (#2729), and the kind fixture (#2542).
Shortcuts
Removes:
- Until AS-2 trusts AS-1 in production, mecak8s configures no gateway entry for the identity broker, so authorized gateway calls work only in tests (Phase 1: Signed-in users' agents call gateway tools with their own access #2451).
- The broker client can exchange a gateway token AS-2 issued to it (Phase 1: Signed-in users' agents call gateway tools with their own access #2451). A test pins this today; this ticket flips it to a refusal.
- The test-only AS-2 trust in the app and the MCP broker.
Keeps:
- The vMCP accepts AS-2-signed tokens with
typJWTor with notyp. Removed once Mecatl pins vMCP: optionally refuse JWT access tokens whose typ is not at+jwt (RFC 9068) toolhive#7345 and turns its check on. - Each ID-JAG and gateway token is single-use per replica only. Removed by [Phase 3] Run mecak8s with the identity broker on more than one replica #2805.
- A cancelled or failed provider leg fails a user's whole first sign-in at AS-2, so they cannot finish it while skipping that provider. Removed by Connect link for a missing provider connection, through the gateway's URL elicitation #2973 (phase 2), once ToolHive's embedded runner can set non-fatal provider legs (Embedded runner: an option to set NonFatalSecondaryLegs toolhive#7370).
- Marked gateway tokens reach protected backends only through ToolHive's per-user credential read, so calls on protected routes keep failing closed. Removed by Connect provider accounts at the embedded gateway #2537.
Done when
Tests run against the real embedded ToolHive authorization server as AS-2 and the real hosted AS-1, built through mecak8s's startup wiring, with servers in the production gateway entry and no test-only trust. They show that:
- a valid AS-1 grant redeems for a marked gateway token naming the resolved gateway user, and the vMCP accepts it;
- an unknown user is refused with
subject_unknownand no user is created, and a matchingsub_idwithout a resolved user is refused; - an unaccepted actor issuer is refused with
actor_denied, and a disallowed issuer, client or resource is refused withresource_denied; - a marked gateway token is refused at token exchange as the subject and as the actor token;
- AS-2 configured with a private key-set address, and without the setting, fails at startup.
#3002's tests still pass. With the flag off, nothing changes.
Activity
16 remaining items
feat(identitybroker): declare gateways and the embedded gateway's sig…
test(identitybroker): pin the typ shortcut to toolhive#7345 and test …
feat(mcpbroker): type AS-2's access tokens at+jwt
ChrisJBurns commentedon Nov 26, 2026
#3002 does the part of this ticket that ToolHive v0.69.0 allows. AS-2 now trusts AS-1 for ID-JAGs only and issues
at+jwtgateway tokens, and the step (8) refusals have tests.Production trust needs this decided:
test(mcpbroker): check the cause of each AS-2 refusal
refactor(mcpbroker): drop the gateway token lifetime setting until #2533
docs(agent-identity): record the review's follow-ups on call binding
ChrisJBurns commentedon Nov 28, 2026
Done in #3002, #3014, #3015 and #3018.
With the
--identity-broker-as2-*settings (Helm:identityBroker.as2), the embedded gateway's authorization server (AS-2) trusts the hosted AS-1:Startup builds the trust from AS-1's own settings, and the gateway entry may list servers. Without the settings, nothing changes.
Where the result differs from "Done when":
resource_deniedcan't occur with AS-2's configuration: the broker client may request only the vMCP resource, and no other client can redeem. Those requests are refused withinvalid_assertionorinvalid_targetinstead.subject_unknownrefusal, the marked token, vMCP acceptance, and the private-address key fetch. Theactor_deniedrefusal, the exchange refusals and "no user created" are tested on the same trust type at the adapter level, not through flags.Shortcuts this leaves, each listed in #2451 with what removes it:
typother thanat+jwt(vMCP: optionally refuse JWT access tokens whose typ is not at+jwt (RFC 9068) toolhive#7345);The company IdP step keeps
offline_accesspermanently, so the IdP must issue AS-2 a refresh token without a consent prompt. This keeps a later on-behalf-of (OBO) exchange with the company IdP possible.