diff --git a/docs/drafts/agent-identity/README.md b/docs/drafts/agent-identity/README.md
index 2713e09d63..83f435f0d0 100644
--- a/docs/drafts/agent-identity/README.md
+++ b/docs/drafts/agent-identity/README.md
@@ -65,7 +65,7 @@ The alternative, giving the agent the user's provider token, would undo the othe
The agent host still has to send calls to the gateway, so it needs some token. If that token allowed any call, the agent host could ask the broker to approve a harmless call and then use the token for a different one, and the broker's check would mean nothing.
-So the agent host asks the broker before every protected call, and the broker returns a token only for the call it approved: this tool, with these arguments, once. The gateway refuses the token for anything else. A refused call gets no token and never reaches the provider. A token taken from the agent host is good for one call that was already approved, and only briefly.
+So the agent host asks the broker before every protected call, and the broker returns a token only for the call it approved: this tool, with these arguments, once. The gateway refuses the token for anything else, and for a second use of it, because it records each token it has accepted. A refused call gets no token and never reaches the provider. A token taken from the agent host is good for one call that was already approved, and only briefly.
### The broker ties each agent to its session
@@ -201,7 +201,7 @@ Alice asks her main agent to list pull requests and review PR 42. The main agent
**Sign-in and session open.** Alice signs in at AS-1, which redirects her to the company IdP, and her client calls mecak8s with the AS-1 access token. Sign-in happens at AS-1 rather than in mecak8s so that Mecatl cannot invent a user: mecak8s checks that Alice owns the session and forwards the token to the broker once, and the broker exchanges it at AS-1 for a refresh token, which the broker holds for that broker session. Every later grant names the user from AS-1's record of that refresh token, never from anything mecak8s sends with a call. The broker holds the refresh token because agents keep working after Alice closes her client. It carries her authority for that one session, has a hard expiry, and is revoked when the session closes or she signs out everywhere. The broker is one OAuth client, `mecatl`, at both AS-1 and AS-2, so a leaked refresh token is useless without the broker's key.
-**Each call.** mecak8s's MCP client asks the broker to authorize the call, naming the server, the tool, and a hash of the arguments. The broker sends the refresh token and the acting agent's JWT-SVID to AS-1. The broker has already checked that the agent is registered to the session. AS-1 checks that the agent's session belongs to the refresh token's user and that the combination of client, user, agent, and gateway is allowed, then returns an ID-JAG naming Alice and the agent in its `act` claim. The JWT-SVID gives the gateway and the audit trail the acting agent; it asserts that agent rather than authenticating it, because agents share one process. The broker redeems the ID-JAG at AS-2 for the vMCP access token `V`, bound to that one call and usable once, and returns it to the MCP client, which sends the call and discards `V`. AS-2 maps AS-1's user to its own account for Alice and never receives her AS-1 token or the agent's JWT-SVID. An external gateway also requires a one-time consent link, which Alice creates at AS-2's own login. The link is her own statement, made at the gateway, that Mecatl may act for her, so a compromised AS-1 cannot use the gateway credentials of a user who never chose Mecatl.
+**Each call.** mecak8s's MCP client asks the broker to authorize the call, naming the server, the tool, and a hash of the arguments. The broker sends the refresh token, the acting agent's JWT-SVID, and an entry naming the call (the server, tool, argument hash, and operation ID) to AS-1. The broker has already checked that the agent is registered to the session. AS-1 checks that the agent's session belongs to the refresh token's user and that the combination of client, user, agent, and gateway is allowed, then returns an ID-JAG naming Alice and the agent in its `act` claim, and an `authorization_details` claim holding the call entry that AS-1 signs. The JWT-SVID gives the gateway and the audit trail the acting agent; it asserts that agent rather than authenticating it, because agents share one process. The broker redeems the ID-JAG at AS-2 for the vMCP access token `V`, bound to that one call and usable once. It checks that `V` carries the entry it sent, then returns `V` to the MCP client, which sends the call and discards `V`. AS-2 maps AS-1's user to its own account for Alice and never receives her AS-1 token or the agent's JWT-SVID. An external gateway also requires a one-time consent link, which Alice creates at AS-2's own login. The link is her own statement, made at the gateway, that Mecatl may act for her, so a compromised AS-1 cannot use the gateway credentials of a user who never chose Mecatl.
**The checks.** The broker checks the session, the workload, that the acting instance is registered to the session, the run and its owner, and the route. It also uses Cedar, a policy engine, to check the reviewer's effective ceiling: the reviewer's definition ceiling, narrowed by the main agent's. The design does not evaluate PR-specific bounds or comprehensive enterprise user policy. AS-2 redeems only for a mapped user, and in external mode only for a linked one, and the vMCP dispatches only with Alice's stored GitHub credential, which never reaches the harness or the model. If any check denies the call, no request reaches GitHub. Missing, stale, or revoked identity, consent, connection, or authorization evidence fails closed, with no fallback to a service credential, another user, or a more privileged agent.
diff --git a/docs/drafts/agent-identity/audit.md b/docs/drafts/agent-identity/audit.md
index 46e50a6f73..1ba1bf8f29 100644
--- a/docs/drafts/agent-identity/audit.md
+++ b/docs/drafts/agent-identity/audit.md
@@ -19,8 +19,8 @@ Records must distinguish verified facts from trusted reports. Qualify subjects b
| Session authority | AS-1 records the one-time conversion at `OpenSession`: client `mecatl` authenticated with `private_key_jwt`, user, source access-token `jti`, and hard expiry. The broker records the open: broker session, the owner match, and the same `jti` | Shows that the broker held a valid AS-1 token for that user when the session opened. The session reference is broker-asserted. The conversion does not show that the user approved any later call. |
| Run and execution-delegation links | mecak8s reports them in the workload-authenticated call request as part of the [execution context](mcp-authorization.md#authentication-and-execution-context) | Correlation is not proof that the broker enforced delegated resource bounds. Creation ancestry is separate. The delegation lives in Mecatl's harness and broker records only; the ID-JAG and `V` name the current actor, not the instance that delegated the task. |
| Ceiling evaluation and broker decision | Broker's evaluation of the registered actor's exact server/tool ceiling and route, together with its session, workload, actor, and run-owner checks | A Cedar permit does not establish user entitlement or connection authority; AS-2 and vMCP enforce those. An allow proves neither dispatch nor downstream success. |
-| ID-JAG issuance | AS-1 records each issuance: user from the broker refresh token's grant record, validated actor, target AS-2, and ID-JAG `jti`. AS-1 validated the SVID and checked that the instance's session belongs to that user. The broker records the same `jti` with the session, run, and instance. | AS-1 does not see the user again per call; the user comes from the grant record. Instance membership comes from the broker registry, and only the broker knows the session. |
-| AS-2 redemption and consent | AS-2 records each redemption or denial: ID-JAG `jti`, client `mecatl`, native user, actor, resource, and decision. In external mode, AS-2 also records creation and revocation of the consent link. | AS-2 trusts AS-1's signature and receives neither the AS-1 access token nor the SVID. In external mode the consent link is AS-2's own evidence that the user chose Mecatl; in embedded mode consent is implicit. |
+| ID-JAG issuance | AS-1 records each issuance: user from the broker refresh token's grant record, validated actor, target AS-2, ID-JAG `(iss, jti)`, and the call entry it signed. AS-1 validated the SVID and checked that the instance's session belongs to that user. The broker records the same `jti` with the session, run, and instance. | AS-1 does not see the user again per call; the user comes from the grant record. Instance membership comes from the broker registry, and only the broker knows the session. |
+| AS-2 redemption and consent | AS-2 records each redemption or denial: ID-JAG `(iss, jti)`, client `mecatl`, native user, actor, resource, and decision. In external mode, AS-2 also records creation and revocation of the consent link. | AS-2 trusts AS-1's signature and receives neither the AS-1 access token nor the SVID. In external mode the consent link is AS-2's own evidence that the user chose Mecatl; in embedded mode consent is implicit. |
| vMCP decision | vMCP records its decision with the access-token reference `(iss, jti)`, native user, actor, tool, outcome, and the propagated operation ID | The gateway sees only the current actor in `act.sub`, not who delegated the task. The operation ID is reported, unverified trace context, as is other forwarded context unless independently verified. |
| Observed result and provider correlation | The response received by the recording component and safe provider references, when available | A broker-observed MCP response is not independent proof of provider-side effects. |
@@ -41,7 +41,7 @@ Every component records evidence as a [toolhive-core](https://github.com/stacklo
| Where it was recorded | `Component`, `Metadata.Extra` | `mecatl-broker`, `mecatl-as1`, or the ToolHive component name, plus the recording replica and deployment; components with a SPIFFE identity also record its trust domain. |
| Operation and target | `Target` | toolhive-core's keys: `type=tool`, `name`, `method=tools/call`, and the MCP server. For token-endpoint events, the requested audience and resource. Request metadata appears only if allowlisted for that type. |
| When | `LoggedAt`, `Metadata.Extra` | `LoggedAt` is the recorder's clock when it created the record, in UTC; a re-send keeps it. `mecatl.occurred_at` (RFC 3339 with offset) and `mecatl.clock` record when the event happened and whose clock said so. Events from different components are ordered by attempt and a per-component sequence number, never by timestamp alone. |
-| Correlation | `Metadata.Extra` | `mecatl.operation_id` and `mecatl.attempt_id`. A retry is a new attempt. A result that arrives after an `unknown` outcome is a new event that references the earlier one; records are never edited. The broker passes the operation and attempt IDs to AS-1 and the vMCP, which record them as reported. |
+| Correlation | `Metadata.Extra` | `mecatl.operation_id` and `mecatl.attempt_id`. A retry is a new attempt. A result that arrives after an `unknown` outcome is a new event that references the earlier one; records are never edited. The broker passes the operation ID to AS-1 inside the call entry, and the operation and attempt IDs to the vMCP, which records them as reported. |
| Evidence references | `Data` | Built from a typed structure per event type. Credential references are `(iss, jti)` or `(authorization server, record ID)`, never values. Definition revision and provenance. When `V` is a JWT, the broker's decision event records its `(iss, jti)`, read without verification and never used to authorize; otherwise it references AS-2's redemption event. |
| OAuth actor history | `DelegationChain` | Only an `act` chain the recorder validated in a token: AS-2 and the vMCP fill it, and broker events leave it empty. |
| Creation and delegation | `Data.lineage` | The run, plus references: the `AuditID` of the delegation event the call runs under and of the acting instance's registration event. The [lineage](#lineage) events hold the relationships, marked as reported by mecak8s. They are never derived from the SPIFFE path or from `act`. |
@@ -78,7 +78,7 @@ These records have limits:
- They are unsigned, so they do not provide non-repudiation.
- In external mode, AS-2 and vMCP records belong to the gateway operator; the Mecatl-side trail ends at the broker's dispatch event.
-- An external gateway may allow an ID-JAG to be re-submitted until it expires, as ID-JAG §4.4.4 permits, so one ID-JAG can lead to several redemption events there, all linked by its `jti`. The embedded gateway accepts each ID-JAG once. In external mode, AS-2 records which approval record authorized each redemption.
+- An external gateway may allow an ID-JAG to be re-submitted until it expires, as ID-JAG §4.4.4 permits, so one ID-JAG can lead to several redemption events there, all linked by its `(iss, jti)`. The embedded gateway accepts each ID-JAG once. In external mode, AS-2 records which approval record authorized each redemption.
- Reaching one operation from a gateway record depends on the propagated operation ID, which vMCP records as reported, not verified.
### Lineage
@@ -100,7 +100,7 @@ The broker records its authorization decision. mecak8s's MCP client, which sends
Decision, dispatch, and observed-outcome evidence must survive broker restart; [delivery, protection, and reconciliation](#delivery-protection-and-reconciliation) sets the write order and what happens when evidence cannot be delivered. This design does not claim atomicity between an audit write and an external effect.
-Use operation and attempt references to connect the evidence; individual events also need their own references. The operation ID, the ID-JAG `jti`, and the AS-2 access token `(iss, jti)` are separate references. Each access token is bound to one call and names its operation ID in its `authorization_details`, so a gateway record leads to one operation through the token AS-2 signed. mecak8s also propagates the operation ID with each MCP request, and vMCP records it as reported, unverified trace context that must match the token. The broker sends the IDs as request parameters at AS-1, and mecak8s sends them in each MCP request's `_meta`; that propagation is not an authenticated contract. Because `act` names only the current actor, this operation ID is what keeps delegation `D42` reachable from a gateway log.
+Use operation and attempt references to connect the evidence; individual events also need their own references. The operation ID, the ID-JAG `(iss, jti)`, and the AS-2 access token `(iss, jti)` are separate references. Each access token is bound to one call and names its operation ID in its `authorization_details`. AS-1 signed that entry into the ID-JAG, so a gateway record leads to one operation through the entry that AS-1 and AS-2 signed. The broker records the result of its output check, which compares the token's entry with the one it sent. mecak8s also propagates the operation ID with each MCP request, and vMCP records it as reported, unverified trace context that must match the token. The broker sends the operation ID to AS-1 only inside the call entry. mecak8s sends them in each MCP request's `_meta`; that propagation is not an authenticated contract. Because `act` names only the current actor, this operation ID is what keeps delegation `D42` reachable from a gateway log.
## Delivery, protection, and reconciliation
@@ -131,6 +131,7 @@ Correctly shaped records are not enough if they can be lost, rewritten, or never
| Mismatch | What it can mean |
| --- | --- |
| An AS-2 redemption with no matching AS-1 ID-JAG issuance | An ID-JAG minted outside the recorded path |
+| An AS-1 ID-JAG issuance with no broker record for its `(iss, jti)` | A response lost after AS-1 issued the ID-JAG; the signed call entry still names the operation |
| A vMCP tool call with no matching broker decision for the same token `jti` and operation | An access token used outside the broker |
| A reported dispatch with no matching vMCP tool call, or a vMCP tool call with no reported dispatch | A record suppressed or misreported on one side |
| A session-open conversion whose source token has no AS-1 issuance and sign-in | A user token minted outside the recorded path |
diff --git a/docs/drafts/agent-identity/credentials-and-lifecycle.md b/docs/drafts/agent-identity/credentials-and-lifecycle.md
index add6d1a8a0..c2b6a15ffb 100644
--- a/docs/drafts/agent-identity/credentials-and-lifecycle.md
+++ b/docs/drafts/agent-identity/credentials-and-lifecycle.md
@@ -24,8 +24,8 @@ The human enters the flow once, when Alice signs in through AS-1. AS-1 runs that
| **Broker refresh token** | Alice's delegated authority for one broker session, usable without her present. | AS-1 → broker → AS-1. Bound to client `mecatl` and the user. Accepted only as the subject of an ID-JAG exchange. | Broker, in shared session storage with the session's owner and the grant's expiry. Does not rotate. |
| **Schedule grant** | Alice's delegated authority for one schedule, until its horizon. | AS-1 → broker → AS-1. Bound to client `mecatl` and the user. Accepted only to open a scheduled run's session. | Broker, in shared storage under the schedule. |
| **Broker client credential** | That the caller at AS-1 and AS-2 is the broker, OAuth client `mecatl`. | Broker's private key; each request carries a short-lived `private_key_jwt` assertion verified by AS-1 and AS-2. | KMS or HSM where available; public key registered at each server as a configured key set (not `jwks_uri`), again on rotation. |
-| **ID-JAG** | Alice and the acting agent, for redemption at AS-2. | AS-1 → broker → AS-2. Short-lived; the broker uses each once. | Broker, from issuance to redemption. |
-| **AS-2 access token (`V`)** | AS-2's native Alice, the acting agent, and client `mecatl`, for the vMCP resource. | AS-2 → broker → mecak8s's MCP client → vMCP. Bound to one call and accepted for that call only. | Not cached. mecak8s holds each `V` only while it sends the one call it is bound to. |
+| **ID-JAG** | Alice, the acting agent, and the one call the ID-JAG authorizes (its `authorization_details` entry), for redemption at AS-2. | AS-1 → broker → AS-2. Short-lived; the broker uses each once. | Broker, from issuance to redemption. |
+| **AS-2 access token (`V`)** | AS-2's native Alice, the acting agent, and client `mecatl`, for the vMCP resource. | AS-2 → broker → mecak8s's MCP client → vMCP. Bound to one call: the entry AS-1 signed into the ID-JAG, which AS-2 copied. Accepted for that call only. Single use: the vMCP records the token's `jti` and refuses a second `tools/call` with it. | Not cached. mecak8s holds each `V` only while it sends the one call it is bound to. |
| **Provider credential** | Access to Alice's GitHub account. | GitHub → gateway credential store → GitHub. | Gateway credential store, keyed by (gateway, user, provider); never leaves the gateway. |
| **Signing keys** | Authority to issue credentials. | AS-1, AS-2, and the agent-instance issuer each keep their own key. | Separate keys are not process isolation when components share a process. |
@@ -102,12 +102,13 @@ sequenceDiagram
Note over H,G: (6) Main call: pull_request_list
H->>B: AuthorizeCall: workload credential, A42, run R41, run owner Alice,
op-list-prs-001, server, tool, argument hash, agentJwtSvid = mainSVID
B->>B: Check session, workload, actor, run owner = grant owner, a gateway routes the server
(ceiling with the authority work)
- B->>A1: (7) RFC 8693: subject_token = RT-A42
actor_token = mainSVID
requested_token_type = id-jag, audience = AS-2
(5) client mecatl, private_key_jwt
- A1->>A1: RT-A42 bound to mecatl, issues id-jag, not revoked or expired
upstream IdP re-checked if due
main's session owned by RT-A42's user, build act (iss = AS-1)
+ B->>A1: (7) RFC 8693: subject_token = RT-A42
actor_token = mainSVID
requested_token_type = id-jag, audience = AS-2
(5) client mecatl, private_key_jwt
authorization_details: this call (server, tool, argument hash, op-list-prs-001)
+ A1->>A1: RT-A42 bound to mecatl, issues id-jag, not revoked or expired
upstream IdP re-checked if due
main's session owned by RT-A42's user, build act (iss = AS-1)
call entry checked for shape, signed into id-jag
A1-->>B: J-main
- B->>A2: (8) RFC 7523: assertion = J-main, client mecatl
authorization_details: this call (server, tool, argument hash, op-list-prs-001)
+ B->>A2: (8) RFC 7523: assertion = J-main, client mecatl
no authorization_details parameter
A2->>A2: Map AS-1 subject to native user
External mode: require consent link
A2-->>B: V-main (sub usr-alice-7c1d, act main, aud vMCP, bound to this call)
+ B->>B: (8a) V-main carries the entry sent in (7)
B-->>H: V-main (decision recorded)
H->>V: (9) tools/call pull_request_list + Bearer V-main
V->>V: Validate V-main, call matches its binding, jti not used
Load credential (gateway, usr-alice-7c1d, github)
@@ -527,7 +528,7 @@ The broker takes `RT-A42` from `A42`'s record only after checks 3 to 5 have pass
For each call, the broker asks AS-1 for an ID-JAG ([draft-ietf-oauth-identity-assertion-authz-grant-06](https://datatracker.ietf.org/doc/draft-ietf-oauth-identity-assertion-authz-grant/)).
-**Input.** An RFC 8693 token exchange with `RT-A42` as subject token, `reviewerSVID` as actor token, AS-2 as audience, and the vMCP as `resource`. The ID of the operation that caused the exchange travels as a request parameter for AS-1's record, as reported trace context:
+**Input.** An RFC 8693 token exchange with `RT-A42` as subject token, `reviewerSVID` as actor token, AS-2 as audience, and the vMCP as `resource`. The call entry is an RFC 9396 `authorization_details` entry of type `https://toolhive.dev/mcp_tool_call`. It names the server, the tool, the argument hash, and the operation ID. A tool listing sends the list form, which names the server and the method. The broker sends one entry on every gateway call, tool calls and tool listings alike. The operation ID is carried only in the entry, so no other Mecatl parameter is sent to AS-1:
```text
POST https://broker.example.com/as/oauth/token
@@ -539,17 +540,21 @@ actor_token_type=urn:ietf:params:oauth:token-type:jwt
requested_token_type=urn:ietf:params:oauth:token-type:id-jag
audience=https://gateway.example.com
resource=https://gateway.example.com/mcp
-mecatl_operation=op-pr42-001
+authorization_details=[{"type": "https://toolhive.dev/mcp_tool_call",
+ "server": "github", "tool": "github.pull_request_read",
+ "arguments_sha256": "", "operation_id": "op-pr42-001"}]
client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer
client_assertion=
```
ID-JAG makes a refresh token as subject token optional (§4.3: an IdP "MAY additionally accept" them); AS-1 must support it.
+**Standards position.** The entry on the ID-JAG request is permitted by the draft (§4.3). The claim itself is defined by §3.1, and AS-1 signing the granted entries into it is required by §4.3.3. AS-2 processing the signed claim is required by §4.4.1. These parts are ours: the shape check in check 2 below, the rule that AS-1 does not refuse an ID-JAG that carries no entry (the broker's output check covers that case), and the field checks, which belong to each type's own hook. Refusing the whole request on an unknown type follows RFC 9396 §5, which we apply here.
+
**Checks, at AS-1:**
1. Client authentication as `mecatl`.
-2. The request is well formed: the three token types above, an `audience`, and a `resource`.
+2. The request is well formed: the three token types above, an `audience`, and a `resource`. If it carries `authorization_details`, that is a JSON array of objects, each with a string `type` registered for token exchange. AS-1 reads no other member of an entry. The type's own hook, run by ToolHive's registry, checks the fields. A request with no entry is not refused here.
3. `audience` is one of the AS-2 issuers configured for `mecatl`, and `resource` is a vMCP configured for that AS-2.
4. `RT-A42` resolves to a grant for client `mecatl` that lists `id-jag` as its output, is not revoked, and has not expired. If the grant has a parent, the parent exists and is not revoked. A schedule grant, which lists `refresh_token`, is refused here.
5. Alice's upstream refresh token exists and its recorded expiry has not passed. If the re-check interval has passed, AS-1 refreshes it first ([upstream re-check](#upstream-re-check)).
@@ -582,6 +587,9 @@ ID-JAG makes a refresh token as subject token optional (§4.3: an IdP "MAY addit
"resource": "https://gateway.example.com/mcp",
"client_id": "mecatl",
"act": {"iss": "spiffe://agents.example.com", "sub": "spiffe://agents.example.com/agent/ag_7hq2x9"},
+ "authorization_details": [{"type": "https://toolhive.dev/mcp_tool_call",
+ "server": "github", "tool": "github.pull_request_read",
+ "arguments_sha256": "", "operation_id": "op-pr42-001"}],
"jti": "jag-pr42-001",
"iat": 1800000001,
"exp": 1800000121
@@ -593,6 +601,7 @@ ID-JAG makes a refresh token as subject token optional (§4.3: an IdP "MAY addit
- `act.sub` is the instance's SPIFFE ID, the SVID's `sub`, which names the instance only by its `ag_` identifier: no definition name and no creation ancestry. It stays the same across SVID renewals, so the vMCP can bind a session to the instance and audit can correlate its calls. The SVID itself stops at AS-1.
- `act` has one level and names the current actor only (RFC 8693 §4.1). RFC 8693 treats prior actors in a nested `act` as informational, so leaving them out removes nothing the gateway enforces. That main delegated `D42` to the reviewer is recorded in Mecatl's harness and broker records, not in the token. A nested `act` naming main comes later, from a [chained exchange](mcp-authorization.md#chained-exchange) at delegation time.
- `resource` is signed by AS-1, so AS-2 checks the redemption's `resource` against a claim, not only against a broker parameter.
+- `authorization_details` is the call entry the broker sent on this request, copied unchanged after AS-1's shape check. AS-1 signs the granted entry, as the same JSON value, so the call that `V` may make is fixed in a token AS-1 issued. AS-2 may only narrow it, so the redeemer cannot widen it or change it. The field checks belong to the type's hook, not to AS-1.
- `aud_sub` and `email`, recommended by the draft, are deliberately omitted: AS-1 does not know AS-2's subject, and an email address is not an identity link.
- The ID-JAG also carries the user's company IdP identity as `upstream_subject`, which AS-2 uses to find the local user in both modes ([identifying claim](#identifying-claim); [#6898](https://github.com/stacklok/toolhive/issues/6898)).
@@ -602,6 +611,8 @@ ID-JAG makes a refresh token as subject token optional (§4.3: an IdP "MAY addit
| --- | --- | --- |
| 1 | 401 `invalid_client` | Call fails; not retryable. |
| 2 | 400 `invalid_request` | Call fails; a broker bug. |
+| 2, `authorization_details` not a JSON array of objects, or an entry with no string `type` or a type not registered for token exchange | 400 `invalid_authorization_details` (RFC 9396 §5) | Call fails; a broker bug or a configuration fault. Not retried. |
+| 2, the call type's hook refuses an entry at minting | 400 `invalid_authorization_details` with `single_entry_required`, `invalid_arguments_hash`, `invalid_method`, or `malformed_entry` | Call fails; a broker bug or a configuration fault. Not retried. |
| 3 | 400 `invalid_target` | Call fails; a configuration fault. |
| 4, revoked | 400 `invalid_request` with `revoked` or `parent_revoked` | See [error reasons](#error-reasons). |
| 4, unknown, expired, or another client's | 400 `invalid_request` with `grant_invalid` | Call fails. The broker checks the stored expiry in step (6), so this is a broker bug or clock skew. |
@@ -629,11 +640,11 @@ AS-1 and AS-2 are separate issuers with separate keys, also in embedded mode. Th
**Does not prove.** That the reviewer, rather than other code in the harness process, asked for the call: the SVID is asserted, not attested. Nor delegation or run context: those are mecak8s reports the broker checked in step (6). Nor that the agent belongs to the session independently of the broker: check 8 runs in Mecatl's validator against the broker's own registry.
-**Evidence.** AS-1 records the ID-JAG issuance: user, the validated instance's SPIFFE ID and its `ag_` identifier, target, `jti`, and the reported operation. The broker records the ID-JAG's `jti` with session `A42`, the run, the instance, and the operation. Joining the two on the `jti` shows which session's grant was paired with which agent.
+**Evidence.** AS-1 records the ID-JAG issuance: user, the validated instance's SPIFFE ID and its `ag_` identifier, target, `(iss, jti)`, the call entry it signed (with the operation ID inside it). The broker records the ID-JAG's `jti` with session `A42`, the run, the instance, and the operation. Joining the two on the `jti` shows which session's grant was paired with which agent.
### (8) AS-2 access token
-**Input.** The broker redeems the ID-JAG at AS-2 with the [RFC 7523 JWT-bearer grant](https://www.rfc-editor.org/rfc/rfc7523.html#section-2.1), naming the vMCP with an RFC 8707 `resource`. The parameter comes from RFC 8707, not the ID-JAG profile; without it, AS-2 uses the ID-JAG's `resource` claim. It restricts `V` to the one call it authorized with an RFC 9396 `authorization_details` entry: the server, the tool, the argument hash, and the operation ID. Form encoding is shown decoded.
+**Input.** The broker redeems the ID-JAG at AS-2 with the [RFC 7523 JWT-bearer grant](https://www.rfc-editor.org/rfc/rfc7523.html#section-2.1), naming the vMCP with an RFC 8707 `resource`. The parameter comes from RFC 8707, not the ID-JAG profile; without it, AS-2 uses the ID-JAG's `resource` claim. The call is not named in this request. AS-2 takes the call entry from the `authorization_details` claim that AS-1 signed into the ID-JAG at step (7), and copies it into `V`. That restricts `V` to one call: the server, the tool, the argument hash, and the operation ID. Form encoding is shown decoded.
**The argument hash** is the lowercase hex SHA-256 of the RFC 8785 (JCS) serialization of the `tools/call` request's `params.arguments` object, or of `{}` when `arguments` is absent. The `tool` is the name the vMCP routes by, as sent in `params.name`. The MCP client computes the hash over exactly the `arguments` value it sends, and the vMCP over the value it received, before any routing or rewriting. JCS needs I-JSON (RFC 7493), so the MCP client refuses, before asking for authorization, arguments it cannot represent that way, such as integers beyond ±2^53 or invalid Unicode, rather than letting the two sides disagree. Both sides are tested against one shared set of test vectors covering number formatting, large and negative numbers, Unicode escapes, key order, and nesting.
@@ -642,13 +653,14 @@ POST https://gateway.example.com/oauth/token
grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer
assertion=
resource=https://gateway.example.com/mcp
-authorization_details=[{"type": "https://toolhive.dev/mcp_tool_call",
- "server": "github", "tool": "github.pull_request_read",
- "arguments_sha256": "", "operation_id": "op-pr42-001"}]
client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer
client_assertion=
```
+The redemption carries no `authorization_details` parameter. The entry comes only from the signed claim, so the redeemer cannot choose the call. A redemption that still carries an `authorization_details` parameter is refused with `invalid_authorization_details`; AS-2 does not ignore it or narrow by it.
+
+**Standards position.** AS-2 processing the claim is required by §4.4.1, which also requires the claim to be parsed as a JSON array. Refusing an empty grant is our policy. Refusing the whole request on an unknown type follows RFC 9396 §5, applied to the claim through §4.4.1. The choice of `invalid_grant` with `invalid_assertion` for a bad claim is ours: AS-1 signed the claim, so a bad one points to version skew or a fault at AS-1.
+
**Checks, at AS-2:**
1. Client authentication as `mecatl`.
@@ -661,7 +673,7 @@ client_assertion=
- **6b.** AS-2's policy lets this client reach that resource.
- **6c.** The actor's issuer is one that AS-2 accepts from this AS-1, and AS-2's actor policy allows the actor. The actor is the top-level `act`, found as in check 9.
7. AS-2 maps the ID-JAG's `(iss, sub)` to a native user. It uses the subject mode configured for that issuer; see [how AS-2 resolves the user](mcp-gateway-modes.md#how-as-2-resolves-the-user). AS-2 never maps through `sub_id` alone, email, or display name.
-8. The `authorization_details` entry is well formed and names exactly one tool call. AS-2 can only narrow `V` with it, never widen it.
+8. The ID-JAG's `authorization_details` claim, if it carries one, is processed as §4.4.1 requires. It is a JSON array with no repeated member. Each entry has a type AS-2 knows, here the call type, and is well formed: one call entry (a tool call or a list call). Each entry goes to its type's hook, run by ToolHive's registry. AS-2 copies the granted entries into `V`. It may narrow them, never add to them or change one. An empty grant is refused. If the ID-JAG carries no claim, AS-2 issues `V` without an entry. The broker's output check ([step (8a)](#8a-broker-output-check)) refuses that `V`, and the vMCP refuses it, because it names no call.
9. In external mode, an unrevoked approval exists for this gateway, that native user, client `mecatl`, a source issuer equal to the ID-JAG's `iss`, and an `actor_iss` equal to the current actor's issuer. The actor is the top-level `act` only (RFC 8693 §4.1). If that `act` has no `iss`, the actor's issuer is the token's `iss` (a Mecatl rule). If there is no `act`, there is no actor, and an approval that names an actor issuer does not match. Mecatl's approvals name AS-1's issuer as the source and the agent trust domain as `actor_iss`, because `act.sub` changes with every agent instance and means nothing to AS-2. Trust domain names are not unique, so `actor_iss` alone could match another Mecatl deployment's agents; the source issuer ties the approval to one AS-1. See [how AS-2 resolves the user](mcp-gateway-modes.md#how-as-2-resolves-the-user).
**Output.** A short-lived access token and no refresh token (§4.4.4):
@@ -692,7 +704,7 @@ client_assertion=
}
```
-`V` is bound to one call and is single-use for it. The vMCP accepts it for exactly one `tools/call` whose server, tool, and argument hash match the entry, and records its `jti` so that a second `tools/call` with it is refused. `V`'s expiry limits only when the call can start. The session handshake before it is accepted during `V`'s lifetime, and messages that belong to the call, such as cancellation, progress, or an elicitation reply, are accepted for as long as the call is open, even after `V` expires, up to a configured maximum call duration. A user can take a minute to answer an elicitation, and a cancel can reach a long-running tool, without a new `V`. A `V` held by mecak8s can therefore make only the call the broker just approved, once. For why the binding lives in `V` rather than a second token, see [authorization, credentials, and dispatch](mcp-authorization.md#authorization-credentials-and-dispatch).
+`V` is bound to one call: the entry AS-1 signed into the ID-JAG, which AS-2 copied. The vMCP accepts it for exactly one `tools/call` whose server, tool, and argument hash match the entry. Single use: the vMCP records the token's `jti` and refuses a second `tools/call` with it. `V`'s expiry limits only when the call can start. The session handshake before it is accepted during `V`'s lifetime, and messages that belong to the call, such as cancellation, progress, or an elicitation reply, are accepted for as long as the call is open, even after `V` expires, up to a configured maximum call duration. A user can take a minute to answer an elicitation, and a cancel can reach a long-running tool, without a new `V`. A `V` held by mecak8s can therefore make only the call the broker just approved, and only once. For why the binding lives in `V` rather than a second token, see [authorization, credentials, and dispatch](mcp-authorization.md#authorization-credentials-and-dispatch).
`V` also carries a **delegated-access marker**. AS-2 emits this claim only after an approved redemption, on this grant or on RFC 8693 token exchange. A wildcard delegate client or `may_act` never earns it. `V` is terminal. In token exchange, AS-2 refuses a token that carries the marker, as subject token or as actor token. So `V` cannot be exchanged for a native-subject token, and it cannot act as native Alice for someone else. The vMCP reads provider credentials only for a token that carries the marker.
@@ -709,7 +721,10 @@ The approval-continuation profile is a convention that AS-2 advertises in its me
| 6a | 400 `invalid_target` | Call fails; a broker bug, because AS-1 copies the broker's `resource` into the claim. |
| 6b | 400 `access_denied` with `resource_denied` | Call fails; a configuration fault. Not retryable with a new ID-JAG. |
| 6c | 400 `access_denied` with `actor_denied` | Call denied. Not retryable with a new ID-JAG. |
-| 8 | 400 `invalid_authorization_details` | Call fails; a broker bug. |
+| 8, claim not a JSON array, or a member repeated | 400 `invalid_grant` with `invalid_assertion` | Call fails. Not retried, not even with a new ID-JAG. |
+| 8, unknown entry type, a second call entry, or no granted entry left | 400 `invalid_authorization_details` (RFC 9396 §5 for an unknown type) | Call fails; a broker or configuration fault. Not retryable with a new ID-JAG. |
+| 8, the redemption carries an `authorization_details` parameter | 400 `invalid_authorization_details` | Call fails; a broker bug. Not retried. |
+| 8, the call type's hook refuses an entry | 400 `invalid_authorization_details` with `single_entry_required`, `invalid_arguments_hash`, `invalid_method`, or `malformed_entry` | Call fails; a broker bug or a configuration fault. Not retried. |
| 7, 9, external | 400 `access_denied` with `consent_required` and an `error_uri` for a pending approval, under the approval-continuation profile | The existing `mcp_authorization_pending` outcome, with that link. The broker shows the `error_uri` only if the gateway advertises the profile and the `error_uri` is `https` on AS-2's issuer origin. Otherwise the call ends as pending with Mecatl's own text and no link. |
| 7, embedded | 400 `access_denied` with `subject_unknown` | Alice has no account at the gateway: she has never signed in there. The broker returns `FAILED_PRECONDITION`, and mecak8s returns the existing `mcp_authorization_pending` outcome with a link that Mecatl builds to its embedded gateway's sign-in. After Alice signs in, the call runs again with a new authorization. Not retryable with a new ID-JAG. |
| Any `invalid_grant` with no reason code | — | Retry once with a new ID-JAG, for gateways that send no reason codes. If AS-2 refuses again, fail the call as a configuration or gateway error. Show no prompt. |
@@ -721,11 +736,37 @@ Until [stacklok/toolhive#7030](https://github.com/stacklok/toolhive/issues/7030)
**Why.** AS-2 sends reason codes in `error_description`, as AS-1 does, so the broker can tell a missing approval from a bad assertion. The `error` code says whether a new ID-JAG can help (ID-JAG §4.4.3): `invalid_grant` means the ID-JAG failed a validation rule, and a new one may succeed; `access_denied` means the ID-JAG is valid but the user, client, or actor is not authorized at AS-2, and a new one will not help. The broker still does not retry `invalid_assertion`: it mints a new ID-JAG for every call, so a refused one points to a broker bug, a configuration fault, clock skew, or a replayed ID-JAG, and retrying a replay would hide a stolen ID-JAG. The broker never re-submits an ID-JAG; it mints a new one. Single use costs nothing, and it turns a stolen ID-JAG redeemed first by a holder of the broker key into a visible failure of the broker's own redemption. RFC 6749 §5.2 defines `error_uri` as human-readable error information, so it means a pending approval only together with `consent_required`, from a gateway that advertises the approval-continuation profile; outages and bugs then never train users to approve. Mapping and approval are separate facts, and the approval stops a compromised AS-1 from using the gateway credentials of a user who never chose Mecatl; see [gateway modes](mcp-gateway-modes.md#how-as-2-resolves-the-user) and the [implementation companion](implementation.md#external-consent-link).
-**Does not prove.** That the agent's ceiling allows the call: the broker checked that, and the binding only fixes which call `V` may make.
+**Does not prove.** That the agent's ceiling allows the call: the broker checked that. The signed claim fixes which call `V` may make, and step (8a) checks that `V` carries it. Neither shows that the gateway enforces the entry.
+
+**One `V` per call.** Neither the broker nor mecak8s caches `V`. Once step (8a) has passed, the broker returns it to mecak8s's MCP client, which sends the one call it is bound to and then discards it. On a 401 `invalid_token` from the vMCP, before the call ran, the MCP client reports the rejection to the broker, naming the rejected attempt. The broker allows one such retry per attempt it issued: it runs the step (6) checks again and repeats steps (7) and (8) once within the same call, with a new attempt ID. The retry's own attempt cannot be reported rejected again, and the allowance is used up when the retry starts, even if the retry then fails as a retryable error. The broker refuses a rejection report for an attempt it did not issue, has already retried, or issued for a retry, with `PERMISSION_DENIED` and `denied`. Authorizing the same operation again without a rejection report, as after an `svid_expired` renewal or a pause, is a new authorization, not this retry. A retry after the call may have run needs a new authorization and is not automatic; see [pauses and restart](#pauses-and-restart).
+
+**Evidence.** AS-2 records the redemption or denial: ID-JAG `(iss, jti)`, client `mecatl`, native user, actor, resource, the granted entries, and decision.
-**One `V` per call.** Neither the broker nor mecak8s caches `V`. The broker returns it to mecak8s's MCP client, which sends the one call it is bound to and then discards it. On a 401 `invalid_token` from the vMCP, before the call ran, the MCP client reports the rejection to the broker, naming the rejected attempt. The broker allows one such retry per attempt it issued: it runs the step (6) checks again and repeats steps (7) and (8) once within the same call, with a new attempt ID. The retry's own attempt cannot be reported rejected again, and the allowance is used up when the retry starts, even if the retry then fails as a retryable error. The broker refuses a rejection report for an attempt it did not issue, has already retried, or issued for a retry, with `PERMISSION_DENIED` and `denied`. Authorizing the same operation again without a rejection report, as after an `svid_expired` renewal or a pause, is a new authorization, not this retry. A retry after the call may have run needs a new authorization and is not automatic; see [pauses and restart](#pauses-and-restart).
+### (8a) Broker output check
-**Evidence.** AS-2 records the redemption or denial: ID-JAG `jti`, client `mecatl`, native user, actor, resource, and decision.
+**Input.** The token response from step (8), including its `authorization_details` member, and the entry the broker sent in step (7) for the same attempt. The broker builds that entry from the request that step (6) checked, and dispatch uses that request ([authorization, credentials, and dispatch](mcp-authorization.md#authorization-credentials-and-dispatch)).
+
+**Checks, at the broker,** before it returns `V`:
+
+1. The token response has an `authorization_details` member.
+2. The member equals the entry sent in step (7). The two are compared as decoded JSON values, so key order and whitespace do not matter. The broker treats `V` as opaque.
+
+A gateway call with no entry never reaches AS-1: the broker sends one on every gateway call, tool calls and tool listings alike.
+
+**Output.** `V`, returned to the MCP client. The check result, pass or fail with its reason, is recorded in the decision record first.
+
+**Failures.**
+
+| Check | Response | Broker outcome and retry |
+| --- | --- | --- |
+| 1, member absent | `INTERNAL` with `call_entry_missing` | `V` is discarded and the call fails before it reaches the gateway. A fault: not retried. |
+| 2, member differs from the entry sent | `INTERNAL` with `call_entry_mismatch` | As for check 1. Not retried. |
+
+**Why.** AS-1 signs the entry the broker sends, and AS-2 can only narrow it. So the broker can test what AS-2 returned against the call it approved in step (6). It is the only check in this design that compares AS-2's response with what the broker sent. A `V` that drops or changes the entry on the way is refused here, and the gateway never receives it.
+
+**Does not prove.** That the gateway enforces the entry. The vMCP enforces that a `V` serves only the call its entry names, and only once; this check does not replace the vMCP's own check. Nor that the call is allowed: step (6) checked that. The check runs before the token is used, so it does not show what a token already sent to the gateway did.
+
+**Evidence.** The decision record holds the check result (absent, differs, or equal), the ID-JAG `(iss, jti)`, and the `V` `jti`.
### (9) vMCP decision and provider credential
@@ -765,7 +806,7 @@ A JSON-RPC error that rejects the request itself (-32700, -32600, -32601, or -32
**Evidence.** vMCP records its decision with the access-token reference `(iss, jti)`, user, actor, tool, outcome, and the reported operation and attempt.
-**Correlation.** `V-reviewer` serves one call, so its `(iss, jti)` leads back through AS-2's redemption record and the ID-JAG `jti` to AS-1's issuance record and to the operation ID the broker put in its `authorization_details`. The operation ID in `_meta`, logged by vMCP as reported, unverified trace context, must match it. Because `act` names only the reviewer, it is also what lets an investigator reach delegation `D42` from a gateway log. Each recipient records only what it verifies or observes.
+**Correlation.** `V-reviewer` serves one call, so its `(iss, jti)` leads back through AS-2's redemption record and the ID-JAG `(iss, jti)` to AS-1's issuance record. The ID-JAG carries the call entry that AS-1 signed, and `V` copies it, so the operation ID in `V`'s entry is the one AS-1 signed. The operation ID in `_meta`, logged by vMCP as reported, unverified trace context, must match it. Because `act` names only the reviewer, it is also what lets an investigator reach delegation `D42` from a gateway log. Each recipient records only what it verifies or observes.
## Scheduled runs
@@ -878,6 +919,7 @@ The failures each step can return: where each is detected, what the user sees, a
| ID-JAG reused where the issuer requires single use | AS-2 | `invalid_grant` with `invalid_assertion` | Call fails; a broker bug or a stolen ID-JAG | Nothing |
| `V` rejected by vMCP | vMCP | 401 `invalid_token` | None: mecak8s reports it, and the call is retried once with a new `V` | Nothing |
| Call does not match `V`'s binding, or `V` already used for a call | vMCP | 403 `insufficient_scope` | Call fails; a broker or MCP client bug, or a stolen `V` | Nothing |
+| `V` lacks the entry the broker sent, or its entry differs ([step (8a)](#8a-broker-output-check)) | Broker | `INTERNAL` with `call_entry_missing` or `call_entry_mismatch` | Call fails before the gateway; a broker, AS-1, or AS-2 fault | Nothing |
| vMCP session rejected | vMCP | 404 | None: one retry with a new session | Stored session ID dropped |
| vMCP policy denies the tool | vMCP | Tool error | Call denied | Nothing |
| No provider credential | vMCP | MCP URL-mode elicitation with the connect link | `mcp_authorization_pending`; Alice connects GitHub | Nothing |
@@ -935,7 +977,7 @@ An agent instance keeps its identity across runs. Each credential's lifetime is
| Schedule grant | Its horizon, schedule deletion, sign out everywhere, or the upstream re-check. | Never extended. Renewal sets up a new grant while Alice is present; the old one runs out. Alice is notified before the horizon. | Alice |
| Upstream refresh token | IdP expiry or revocation. | At most once per re-check interval, at an ID-JAG exchange or scheduled-run open; one refresh per user at a time. | AS-1 |
| ID-JAG | Short lifetime. | Never renewed or re-submitted; one per `V`. | Broker |
-| `V` | Its one call, or a short lifetime of seconds. | Never renewed; a new `V` for every call, and one more within the same call after a 401. | Broker, through steps (7) and (8) |
+| `V` | One call, a short lifetime of seconds, and single use: the vMCP records `jti` and refuses a second. | Never renewed; a new `V` for every call, and one more within the same call after a 401. | Broker, through steps (7) and (8) |
| Key sets: AS-1's, AS-2's, the agent trust bundle, and the cluster JWKS | Operator rotation. | On an unknown `kid`, rate-limited, and periodically. | Each verifier |
| The broker client's configured key set (not `jwks_uri`) | Operator rotation. | Registered again at each server, which reads it only then; a hosted AS-1 registers it at process start. | Operator, or mecak8s at startup |
| Consent link | Revocation in the gateway UI or by Mecatl. | The user links again. | Alice |
@@ -1070,7 +1112,11 @@ These are not part of the identity work. Run grants and the agent ceiling at the
**Tighter approvals.** RFC 7662 introspection, with RFC 9701 signed responses, would let the vMCP ask AS-2 whether `V` is still active, so a revoked approval stops even an issued `V`; it puts AS-2 on every dispatch path. Carrying the approved connections in `V` as an RFC 9396 `authorization_details` entry would let the gateway refuse a provider Alice did not approve; every gateway must understand the entry first.
-**The agent ceiling at the gateway.** Until AS-1 carries the instance's effective ceiling in the ID-JAG as scope or RFC 9396 `authorization_details`, and AS-2 carries it into `V`, the broker alone enforces the ceiling; the gateway enforces user and connection.
+**The agent ceiling at the gateway.** The long-term plan is for AS-1 to write the instance's effective ceiling into the ID-JAG as scope or RFC 9396 `authorization_details`, for AS-2 to carry it into `V`, and for the gateway to enforce it as a second check. The broker enforces the ceiling; the gateway enforces user and connection.
+
+**A Cedar policy in the token.** The per-call entry could carry a Cedar policy in place of a fixed shape, as the Cedar profile of RFC 9396 in an expired individual draft (draft-cecchetti-oauth-rar-cedar) describes. That would let operators express per-call policy in the language the vMCP already evaluates. It is not part of this design. It would need the policy's signing, its trust model, and the evaluation point defined first. The argument hash and single use stay in code either way, because Cedar cannot compute the hash and holds no state.
+
+**The gateway checks the call entry.** The vMCP enforces that a `V` serves only the call its entry names, and only once, for clients of Mecatl; the widening to all clients is later behind an embedder setting.
## Reference
diff --git a/docs/drafts/agent-identity/implementation.md b/docs/drafts/agent-identity/implementation.md
index b27e6fb2c0..21b7723116 100644
--- a/docs/drafts/agent-identity/implementation.md
+++ b/docs/drafts/agent-identity/implementation.md
@@ -77,8 +77,10 @@ Test ID-JAG issuance:
- AS-1 rejects an expired, revoked, or foreign-client refresh token, a schedule grant, and a run's refresh token whose schedule grant is revoked.
- AS-1 rejects an untrusted or expired SVID, an SVID with an audience not accepted by both AS-1 and the broker, and an instance whose session is closed or owned by a user other than the grant's, with `denied` in both cases. The broker rejects an instance not registered to the session before it calls AS-1.
-- The broker records each ID-JAG `jti` with its session, run, instance, and operation.
+- The broker records each ID-JAG `(iss, jti)` with its session, run, instance, operation, and attempt.
- The issued ID-JAG has `typ=oauth-id-jag+jwt`, the `sub` from the refresh token record, `client_id=mecatl`, AS-2 `aud`, a fresh `jti`, and an `act` with exactly one level, whose `sub` is the validated actor's agent ID, `spiffe:///agent/`, and which has no nested `act` and has `act.iss` set to the agent trust domain. A caller cannot change `sub` or `act` through request parameters. The ID-JAG carries the requested `resource`.
+- AS-1 refuses a request whose `authorization_details` is not a JSON array of objects, or whose entry has no string `type` or a type not registered for token exchange, with `invalid_authorization_details`. AS-1 reads no field of a call entry; the type's hook checks the fields.
+- AS-1 signs the granted entry, as the same JSON value, into the ID-JAG's `authorization_details` claim. When the request carries no entry, AS-1 issues the ID-JAG without the claim and does not refuse it.
- Each refusal carries the reason code in `error_description` that [error reasons](credentials-and-lifecycle.md#error-reasons) assigns, and the broker maps it to the listed gRPC status and mecak8s outcome, including `mcp_owner_action_required`.
- An exchange after the upstream token's recorded expiry is refused without calling the IdP.
- A client assertion or ID-JAG replayed inside the clock-skew window after its `exp` is rejected; `jti` stores are shared across replicas.
@@ -106,11 +108,13 @@ Test AS-2 redemption:
Test the per-call `V`:
- Every allowed call gets its own `V`, bound to that call's server, tool, argument hash, and operation ID. Neither the broker nor mecak8s caches it, and mecak8s never logs or stores it.
-- AS-2 copies the `authorization_details` entry into `V` unchanged, refuses a malformed entry or one naming more than one call, and never widens `V` beyond it.
+- AS-2 copies the signed entry into `V` unchanged when it grants it, and never widens `V` beyond the claim. It refuses a claim that is not a JSON array, or repeats a member name, with `invalid_grant` and `invalid_assertion`. It refuses an unknown type, a second call entry (the same entry listed twice included), or an empty grant with `invalid_authorization_details`, and a type hook's refusal with `invalid_authorization_details`.
+- The broker sends a call entry on every gateway call, tool calls and tool listings alike. A gateway call with no entry never reaches AS-1.
+- After redemption and before it uses `V`, the broker compares `V`'s `authorization_details` with the entry it sent, as decoded JSON values. Test a dropped claim, a different hash, a different operation ID, a list entry where a tool-call entry was sent, and an additional entry. Each fails the call before it reaches the gateway, is recorded with its check result, and is not retried.
- On a 401 `invalid_token` from the vMCP, before the call ran, mecak8s reports the rejection, the broker repeats the exchange once within the same call, and a second 401 fails the call.
- The `ag_` identifier in `act` is unchanged after the instance's SVID is renewed.
-Test the binding at the vMCP:
+Test the binding at the vMCP. The vMCP enforces that a `V` serves only the call its entry names, and only once, for clients of Mecatl; the widening to all clients is later behind an embedder setting:
- A `tools/call` whose server, tool, or arguments differ from `V`'s entry is refused, including arguments that differ only after the vMCP rewrites the request; the vMCP hashes the request as received.
- A second `tools/call` with the same `V` is refused, including on another vMCP replica. The session handshake for the bound call is accepted during `V`'s lifetime, and its cancellation and elicitation replies while the call is open.
@@ -159,8 +163,11 @@ This table is the ledger of ToolHive changes the design needs. Rows link existin
| Refresh token as `subject_token`: a child grant from a grant that issues refresh tokens, listing one other output and expiring no later than its parent, which is checked on every use; and an ID-JAG from a grant that issues ID-JAGs | Yes; child grants from v0.62.0 ([#6897](https://github.com/stacklok/toolhive/issues/6897)), ID-JAGs from a grant from v0.66.0 ([#6898](https://github.com/stacklok/toolhive/issues/6898)) | None | Identity work |
| Single-level `act` from the registered actor input, with `act.iss` set to the agent trust domain and `act.sub` to the agent ID (nesting later, with the chained exchange) | Yes, from v0.66.0 ([#6899](https://github.com/stacklok/toolhive/issues/6899)): `act` is `{iss, sub}`, from the issuer registered with the validator and the validator's agent ID, one level | None | Identity work |
| ID-JAG redemption keeps `act`, including `act.iss` | Yes, copied unchanged | None; verify only | Identity work |
-| AS-2 accepts an `authorization_details` entry naming one tool call (server, tool, argument hash, operation ID) or one list call (server, list method) on the JWT-bearer grant, only to narrow `V`, and copies it into `V`, with a configurable `V` lifetime per client | No ([#7061](https://github.com/stacklok/toolhive/issues/7061); the granted entry in the response is [#6887](https://github.com/stacklok/toolhive/issues/6887); accepting and narrowing is not) | Medium | Identity work |
-| vMCP accepts a `V` for one `tools/call` matching its entry, computing the argument hash as specified in [step (8)](credentials-and-lifecycle.md#8-as-2-access-token), or for one list call matching it, answered with only that server's tools; refuses a second call with the same `jti`, recording each `jti` with the call it started until `exp` plus the clock skew or the end of that call, whichever is later, in storage shared by its replicas; accepts the session handshake during `V`'s lifetime, and messages that belong to the open call (cancellation, progress, elicitation replies) until it ends, up to a configured maximum call duration. Session binding for list methods is [#6779](https://github.com/stacklok/toolhive/issues/6779) | No ([#7062](https://github.com/stacklok/toolhive/issues/7062)) | Medium | Identity work |
+| AS-2 processes the `authorization_details` claim of a signed ID-JAG, as ID-JAG §4.4.1 and RFC 9396 require: it copies the granted entries into `V`, only narrows them, and refuses with the codes in [step (8)](credentials-and-lifecycle.md#8-as-2-access-token). Also a configurable `V` lifetime per client. Owner: Jakub (ToolHive side) | No ([#7061](https://github.com/stacklok/toolhive/issues/7061); returning the granted entries in the response, and processing the signed claim, are not done) | Medium | Identity work |
+| AS-1 accepts the call entry on the ID-JAG request (shape check and registered types only; the type's hook checks fields) and signs the granted entries into the ID-JAG's `authorization_details` claim. Owner: Jakub (ToolHive side) | No (covered by [#7061](https://github.com/stacklok/toolhive/issues/7061) once that issue covers AS-1 signing) | Small to medium | Identity work |
+| Broker output check ([step (8a)](credentials-and-lifecycle.md#8a-broker-output-check)): after redemption and before use, the broker compares `V`'s `authorization_details` with the entry it sent, and refuses the call on a missing or different claim. Owner: Chris (Mecatl side) | Not built | Small | Identity work |
+| Pin the ToolHive release that contains the AS-2 and AS-1 rows above in Mecatl, and send the call entry only after the pin, together with the broker check. Bind each gateway token to its call ([#2727](https://github.com/stacklok/mecatl/issues/2727)) merges with the pin bump; until both land, phase 1 keeps its current shortcut. Owner: Chris (Mecatl side) | Not built | Configuration | Identity work |
+| vMCP enforces that a `V` serves only the call its entry names, and only once, for clients of Mecatl first; the widening to all clients is later behind an embedder setting. Owner: Jakub (ToolHive side). It accepts a `V` for one `tools/call` matching its entry, computing the argument hash as specified in [step (8)](credentials-and-lifecycle.md#8-as-2-access-token), or for one list call matching it, answered with only that server's tools; refuses a second call with the same `jti`, recording each `jti` with the call it started until `exp` plus the clock skew or the end of that call, whichever is later, in storage shared by its replicas; accepts the session handshake during `V`'s lifetime, and messages that belong to the open call (cancellation, progress, elicitation replies) until it ends, up to a configured maximum call duration. Session binding for list methods is [#6779](https://github.com/stacklok/toolhive/issues/6779) | No ([#7062](https://github.com/stacklok/toolhive/issues/7062)) | Medium | Identity work, Mecatl first |
| **M1.** Subject mode per trusted source issuer: namespaced `iss#sub` (default), SSO identity with a configurable claim set (embedded), or approval record (external). One resolution function for both the JWT-bearer and token-exchange grants, failing closed. Per issuer also: `jti` reuse policy, allowed actor issuers per client, and implicit approval per (issuer, client, resource) | No; ID-JAG redemption always issues `iss#sub` (`id_jag_handler.go`), and token exchange passes self-issued subjects through (`tokenexchange/handler.go`); [#6887](https://github.com/stacklok/toolhive/issues/6887) | Medium | Identity work |
| **M2.** Delegated access approval (gateway, local user, client, source `iss`, `actor_iss`, revoked), checked at redemption; the approval link with `error_uri`, under an approval-continuation profile advertised in AS-2's metadata (RFC 8414); revocation by the owning client. AS-2 returns `server_error` when the store is unavailable | No; `ClientApproval` and remembered consent are the nearest records and lack these fields; [#7158](https://github.com/stacklok/toolhive/issues/7158), whose record has no source issuer yet | Medium, plus Large for the approval link | Identity work |
| **M3.** A delegated-access marker in `V` that only an approved redemption emits, on either grant; the gateway reads credentials only for tokens with it, from its own AS-2. | No; `isSessionlessGrant` accepts any `act` chain (`pkg/auth/token.go`); [#6404](https://github.com/stacklok/toolhive/issues/6404) | Medium | Identity work |
@@ -171,7 +178,7 @@ This table is the ledger of ToolHive changes the design needs. Rows link existin
| Revoke a broker refresh token and its record, by an RFC 7009 endpoint or, while the broker runs inside mecak8s, in process | No; no endpoint is wired ([#6966](https://github.com/stacklok/toolhive/issues/6966)); revoking a grant in storage is part of the grants in progress ([#6897](https://github.com/stacklok/toolhive/issues/6897)) | Small | Identity work |
| Record a user's revocation time and reason: AS-1 refuses her grants created before it, revokes her client refresh tokens, and ends her AS-1 login sessions; session open and schedule setup refuse a source token issued before it. Only the user's own fresh token, or AS-1 itself, may start it | No; there is no per-user revocation record and no `/oauth/revoke` route ([#6972](https://github.com/stacklok/toolhive/issues/6972)) | Medium | Identity work |
| Upstream re-check when issuing an ID-JAG, with the upstream token kept independent of client sign-out, its expiry recorded, and refreshes single-flight per user | No ([#6978](https://github.com/stacklok/toolhive/issues/6978)); the refresh grant never contacts the upstream IdP (checked at main `9adad0abb`). A grant records the user, not an upstream session, so AS-1 finds the upstream token by user; upstream tokens are stored per `tsid` today | Small to medium | Identity work |
-| AS-1 and the vMCP record the operation and attempt IDs, passed by the broker with each exchange and by mecak8s's MCP client with each MCP request, marked as reported | No ([#6979](https://github.com/stacklok/toolhive/issues/6979)) | Small | Identity work |
+| The vMCP records the operation and attempt IDs, passed by mecak8s's MCP client with each MCP request, marked as reported; AS-1 records the operation ID in the signed call entry | No ([#6979](https://github.com/stacklok/toolhive/issues/6979)) | Small | Identity work |
| A reason code in `error_description` for each refusal at AS-1 and AS-2, in the [error reasons](credentials-and-lifecycle.md#error-reasons) grammar | Partly; AS-1's session-open reasons from v0.60.0, AS-1's ID-JAG issuance and actor reasons from v0.66.0, AS-2's redemption reasons in [#7030](https://github.com/stacklok/toolhive/issues/7030) | Small | Identity work |
| On a reused source `jti`, revoke the grant that `jti` created when the same client reuses it, and refuse the request with `token_used` as before, so a resend after a lost response leaves no orphan | No; the `jti` marker already holds the grant ([#6973](https://github.com/stacklok/toolhive/issues/6973)) | Small | Identity work |
| AS-1 refuses a subject token (check 4) with `subject_token_invalid` when a fresh access token can pass and `subject_token_audience`, `subject_token_source_client`, or `subject_token_offline_access` for a configuration fault, and an unknown or expired grant with `grant_invalid` | Yes; subject-token reasons from v0.60.0 ([#7003](https://github.com/stacklok/toolhive/pull/7003)), `subject_token_offline_access` from v0.61.0 ([#7029](https://github.com/stacklok/toolhive/issues/7029)), and `grant_invalid` from v0.62.0 ([#7007](https://github.com/stacklok/toolhive/pull/7007)) | None | Identity work |
@@ -197,6 +204,8 @@ This table is the ledger of ToolHive changes the design needs. Rows link existin
| Scope or `authorization_details` (RFC 9396) narrowing enforced per tool at the gateway | Scope intersection only | Large | Later |
| Cedar at the gateway reading `act` | No | Part of the narrowing work | Later |
+**Rollout order.** ToolHive ships the AS-2 change before the AS-1 change. Mecatl sends call entries only once its pinned ToolHive release includes both, together with the change that uses them. Until then, phase 1 keeps its current shortcut.
+
M1–M4 are generic delegated client access, with Mecatl as the first client; the AS-1 side is [#6886](https://github.com/stacklok/toolhive/issues/6886).
The approval link needs the approval, a pending approval created at redemption and returned through `error_uri`, the approval screen with its identity comparison, and revocation. Its creation flow is under [external approval link](#external-consent-link); its requirement is in [MCP gateway modes](mcp-gateway-modes.md#how-as-2-resolves-the-user). Whether "Allow Mecatl" and the provider's consent screen can be one redirect chain is open.
diff --git a/docs/drafts/agent-identity/mcp-authorization.md b/docs/drafts/agent-identity/mcp-authorization.md
index 4176498216..3628e87968 100644
--- a/docs/drafts/agent-identity/mcp-authorization.md
+++ b/docs/drafts/agent-identity/mcp-authorization.md
@@ -30,7 +30,7 @@ For example, a read-only reviewer spawns a child from a `deployer` definition wh
The intersection narrows a child's definition but trusts the registered parent link: a compromised mecak8s that registers a child under a more privileged parent still inflates its effective ceiling (see [registering instances](agent-definitions.md#registering-instances)). Root eligibility bounds that inflation: every parent chain ends at a root the operator allows, so no child can exceed that root's ceiling, which the [definition loader](agent-definitions.md#loading-definitions) set. Task-specific limits, such as keeping the reviewer to PR 42 under `D42`, are dynamic delegation policy and remain deferred. An instance JWT-SVID identifies the agent; it does not prove those limits.
-The gateway sees delegation only as identity, not as authority. AS-1 writes only the acting instance into the ID-JAG's `act`, as its opaque SPIFFE ID, and AS-2 copies it into `V`. vMCP binds its session to `act.sub`. The instance that delegated the task does not appear in the token; Mecatl's harness and broker records keep the delegation, and a later chained exchange may add it as a nested `act`. `act` does not carry the agent's ceiling, so the broker alone enforces the effective ceiling, and the gateway enforces only user and connection. The long-term plan is for AS-1 to write the instance's effective ceiling into the ID-JAG as scope or RFC 9396 `authorization_details`, for AS-2 to carry it into `V`, and for the gateway to enforce it as a second check. The ID-JAG and `V` formats reserve that slot; until it is filled, a gateway allow says nothing about the agent ceiling. See the [ID-JAG step](credentials-and-lifecycle.md#7-id-jag-from-as-1).
+The gateway sees delegation only as identity, not as authority. AS-1 writes only the acting instance into the ID-JAG's `act`, as its opaque SPIFFE ID, and AS-2 copies it into `V`. vMCP binds its session to `act.sub`. The instance that delegated the task does not appear in the token; Mecatl's harness and broker records keep the delegation, and a later chained exchange may add it as a nested `act`. `act` does not carry the agent's ceiling, so the broker alone enforces the effective ceiling, and the gateway enforces only user and connection. The long-term plan is for AS-1 to write the instance's effective ceiling into the ID-JAG as scope or RFC 9396 `authorization_details`, for AS-2 to carry it into `V`, and for the gateway to enforce it as a second check. The ID-JAG and `V` formats reserve that slot, and a gateway allow says nothing about the agent ceiling. See the [ID-JAG step](credentials-and-lifecycle.md#7-id-jag-from-as-1).
### Chained exchange
@@ -96,13 +96,13 @@ Local permissions and hooks apply before invocation. mecak8s's MCP client then a
Missing, invalid, stale, or revoked identity, consent, connection, or authorization evidence fails closed, without fallback to a service credential, another user, or a more privileged agent.
-For each call, the broker authenticates to AS-1 as OAuth client `mecatl` with `private_key_jwt` and requests an ID-JAG by RFC 8693 token exchange, with the session's broker refresh token as `subject_token` and the actor SVID as `actor_token`. It redeems the ID-JAG at AS-2 with RFC 7523's JWT-bearer grant, authenticating again as `mecatl`, and restricts `V` to the call with an RFC 9396 `authorization_details` entry: the server, the tool, the [argument hash](credentials-and-lifecycle.md#8-as-2-access-token), and the operation ID. AS-2 resolves the native user and returns `V` naming that user, the acting agent in `act`, client `mecatl`, and that entry, with a lifetime of seconds and no refresh token. vMCP accepts `V` for exactly one `tools/call` that matches the entry and records its `jti`, so the same `V` cannot serve a second call; see [step (9)](credentials-and-lifecycle.md#9-vmcp-decision-and-provider-credential). AS-2 and vMCP make their own grant, identity, operation, and connection decisions; a downstream allow does not replace the broker's ceiling decision, and a broker allow does not replace theirs. See [credential roles](credentials-and-lifecycle.md#credential-roles) and the [interactive walkthrough](credentials-and-lifecycle.md#interactive-execution) for the full sequence.
+For each call, the broker authenticates to AS-1 as OAuth client `mecatl` with `private_key_jwt` and requests an ID-JAG by RFC 8693 token exchange, with the session's broker refresh token as `subject_token`, the actor SVID as `actor_token`, and an RFC 9396 `authorization_details` entry for the call: the server, the tool, the [argument hash](credentials-and-lifecycle.md#8-as-2-access-token), and the operation ID. AS-1 signs the entry into the ID-JAG. The broker redeems the ID-JAG at AS-2 with RFC 7523's JWT-bearer grant, authenticating again as `mecatl`, and AS-2 copies the signed entry into `V`. AS-2 resolves the native user and returns `V` naming that user, the acting agent in `act`, client `mecatl`, and that entry, with a lifetime of seconds and no refresh token. The broker then checks that `V` carries the entry it sent ([step (8a)](credentials-and-lifecycle.md#8a-broker-output-check)). vMCP accepts `V` for exactly one `tools/call` that matches the entry, and only once: it records `jti` and refuses a second call with the same `V`. See [step (9)](credentials-and-lifecycle.md#9-vmcp-decision-and-provider-credential). AS-2 and vMCP make their own grant, identity, operation, and connection decisions; a downstream allow does not replace the broker's ceiling decision, and a broker allow does not replace theirs. See [credential roles](credentials-and-lifecycle.md#credential-roles) and the [interactive walkthrough](credentials-and-lifecycle.md#interactive-execution) for the full sequence.
**Why mecak8s sends the call.** The broker decides and issues tokens; it does not proxy MCP. Sending a call needs the MCP protocol, vMCP sessions, streaming, cancellation, and server-initiated requests such as elicitation, and putting those in the broker would make the most trusted component large and tie it to every change in MCP. A `V` bound to one approved call gives the protection that sending from the broker would: mecak8s holds only a credential for the call the broker just approved, usable once. The harness holds no credential it can use for any other call.
-**Tool discovery.** mecak8s's MCP client also lists the gateway's tools, one server at a time, with a `V` the broker issues for that listing after the same session, workload, and actor checks; its entry names the server and the `tools/list` method instead of a tool and argument hash. The gateway answers with only that server's tools, so attributing a tool to its server is the gateway's job and the client never parses the gateway's routed tool names. Listing fails closed: if any configured server's listing fails or returns no tools, the session's tool catalogue is not frozen, rather than frozen without that server. Listing tools needs no sign-in beyond Alice's sign-in at AS-1.
+**Tool discovery.** mecak8s's MCP client also lists the gateway's tools, one server at a time, with a `V` the broker issues for that listing after the same session, workload, and actor checks; its entry, which AS-1 signs into the ID-JAG, names the server and the `tools/list` method instead of a tool and argument hash. The gateway answers with only that server's tools, so attributing a tool to its server is the gateway's job and the client never parses the gateway's routed tool names. Listing fails closed: if any configured server's listing fails or returns no tools, the session's tool catalogue is not frozen, rather than frozen without that server. Listing tools needs no sign-in beyond Alice's sign-in at AS-1.
-**Why the binding lives in `V`.** The alternative was two tokens: a `V` scoped to the acting instance's effective ceiling and cached by the broker, plus a per-call token the broker signs, valid for seconds, in the pattern of OAuth Transaction Tokens. That saves the AS-1 exchange and AS-2 redemption on each call, but the vMCP would have to trust the broker's signing key as well as AS-2's. An external gateway administers its own trust, and transaction tokens are meant for one trust domain. Binding `V` keeps every gateway trusting only its own AS-2.
+**Why the binding lives in `V`.** The alternative was two tokens: a `V` scoped to the acting instance's effective ceiling and cached by the broker, plus a per-call token the broker signs, valid for seconds, in the pattern of OAuth Transaction Tokens. That saves the AS-1 exchange and AS-2 redemption on each call, but the vMCP would have to trust the broker's signing key as well as AS-2's. An external gateway administers its own trust, and transaction tokens are meant for one trust domain. Binding `V` keeps every gateway trusting only its own AS-2. The entry reaches `V` through the ID-JAG that AS-1 signs, not as a redemption parameter, so the call is fixed before redemption and the gateway still trusts only its own AS-2.
**Cost, considered and accepted.** Where a cached `V` used to serve several calls, every call now costs an ID-JAG exchange at AS-1 and a redemption at AS-2, each authenticated with a `private_key_jwt` assertion the broker signs, plus a `jti` write at the vMCP. While AS-1 runs inside the broker, the exchange is in process; in embedded mode the redemption is too, and with an external gateway it is one network round trip to its AS-2 per call, and load on its rate limits. That is small next to model and tool latency, and it is the price of the harness never holding a reusable gateway credential.
diff --git a/docs/drafts/agent-identity/mcp-gateway-modes.md b/docs/drafts/agent-identity/mcp-gateway-modes.md
index 7c9229ca84..286c6a4f33 100644
--- a/docs/drafts/agent-identity/mcp-gateway-modes.md
+++ b/docs/drafts/agent-identity/mcp-gateway-modes.md
@@ -30,8 +30,8 @@ Mecatl uses two authorization servers so that it can work with an MCP gateway it
Between them, for each call, the broker runs two steps, detailed in [credentials and lifecycle](credentials-and-lifecycle.md#7-id-jag-from-as-1):
-1. It exchanges `RT-A42` at AS-1 (RFC 8693), with the agent-instance JWT-SVID as `actor_token`, and receives an **ID-JAG** ([draft-ietf-oauth-identity-assertion-authz-grant-06](https://datatracker.ietf.org/doc/draft-ietf-oauth-identity-assertion-authz-grant/)) addressed to AS-2.
-2. It redeems the ID-JAG at AS-2 with the RFC 7523 JWT-bearer grant and receives the AS-2 access token `V`.
+1. It exchanges `RT-A42` at AS-1 (RFC 8693), with the agent-instance JWT-SVID as `actor_token`, and receives an **ID-JAG** ([draft-ietf-oauth-identity-assertion-authz-grant-06](https://datatracker.ietf.org/doc/draft-ietf-oauth-identity-assertion-authz-grant/)) addressed to AS-2. The request also carries the call's entry, which AS-1 signs into the ID-JAG.
+2. It redeems the ID-JAG at AS-2 with the RFC 7523 JWT-bearer grant and receives the AS-2 access token `V`, which carries the signed entry. It checks that `V` carries the entry it sent before it uses `V`.
The broker authenticates at both servers as one OAuth client, `mecatl`, with `private_key_jwt`. ID-JAG §4.4.1 requires the ID-JAG's `client_id` to match the client that redeems it, so one client ID is used at both. `mecatl` is the broker's client registration, not an identity of the acting agent. The [broker client authentication step](credentials-and-lifecycle.md#5-broker-client-authentication) shows the client assertion.