diff --git a/docs/plans/hosted-mcp-connection-scope.md b/docs/plans/hosted-mcp-connection-scope.md index bef7dfe54b..2420df75b7 100644 --- a/docs/plans/hosted-mcp-connection-scope.md +++ b/docs/plans/hosted-mcp-connection-scope.md @@ -54,10 +54,10 @@ Entries live in this repo, one module per vendor, and change only by PR. An entr - `issuer`: the authorization server its protected-resource metadata names, checked at intake; - `client`: `pre-registered`, `cimd` or `dcr` (§4); - `scopes`: requested at authorization; -- `revoke`: exactly one of an `endpoint`, the RFC 7009 revocation endpoint the AS's metadata advertises, or a `page`, where a person revokes by hand (§9); +- `revoke`: a `page`, where a person revokes by hand, and also an `endpoint` when the AS's metadata advertises an RFC 7009 revocation endpoint (§9); - `tools`: each with the name and description an agent sees, the upstream name, a class (`read` or `write`), `irreversible`, a pinned `inputSchema`, and the upstream annotations as seen when the tool was pinned. -**`revoke` names its kind because the URL cannot.** Both kinds are https URLs, and the kind alone decides whether removal calls the vendor (§9). A page that answered that call with 200 would read as a revoke that never happened. A 200 proves no more at a real endpoint, which answers 200 "if the token has been revoked successfully or if the client submitted an invalid token" (RFC 7009 §2.2). So the entry load refuses an entry that names neither kind or both, or a URL that is not https, and step 7 (§10) shows the revoke took by something other than its status. +**`revoke` names its kind because the URL cannot.** Both are https URLs, and only the `endpoint` key decides whether removal calls the vendor (§9). A page that answered that call with 200 would read as a revoke that never happened. A 200 proves no more at a real endpoint, which answers 200 "if the token has been revoked successfully or if the client submitted an invalid token" (RFC 7009 §2.2). Every entry names a page, an entry with an endpoint included, because a removal that cannot revoke at the vendor hands the person that page (§9). So the entry load refuses an entry with no page, a key other than those two, or a URL that is not https, and step 7 (§10) shows the revoke took by something other than its status. **The entry is the only source for everything an agent sees and everything a grant is checked against.** Upstream can take a tool away or refuse a call. It cannot add a tool, loosen a schema, rename a tool, reword a description or reclassify a tool. The MCP spec (2026-07-28, tools) says "clients MUST consider tool annotations to be untrusted unless they come from trusted servers", and a vendor's server is not one we run. A tool description is also prompt text that reaches every seat holding a grant. An edit made upstream would change every seat's prompt with no review; pinned here, the same change is a PR a gate reads. @@ -233,8 +233,11 @@ The refusal must also hold where the tool runs, not only where the entry is offe **Removal** is §10.5 unchanged in order: 1. Grants: `revokeConnectionGrants`, which matches a grant by the row's `_id`, the id every hosted grant is stored under. -2. The row goes to `disconnected`, and `isActive` stays true: step 3 needs the refresh token, and the orphan sweep revokes the material of a row that is not active. -3. The provider, by the kind the entry's `revoke` names (§3), never by its URL. An `endpoint` gets RFC 7009 revocation of the refresh token (Linear's is `https://mcp.linear.app/token`). Unlike §10.5's GitHub grant-deletion call, which takes an access token, this sends the refresh token itself, so it needs no refresh first. A `page` gets no provider call, and the removal response carries it as `revokeAt`, as §10.5 does for a pasted token. +2. The row goes to `disconnected`, and `isActive` stays true: step 3 needs the token, and the orphan sweep revokes the material of a row that is not active. +3. The provider, by whether the entry's `revoke` names an `endpoint` (§3), never by a URL. A revoke that took ends with §10.5's mark, and a retry that finds the mark skips this step. + - With an endpoint, the call sends the refresh token when the row names one, and otherwise the access token, each with its RFC 7009 `token_type_hint` (Linear's endpoint is `https://mcp.linear.app/token`). Unlike §10.5's GitHub grant-deletion call, which takes an access token, this sends the token itself, so it needs no refresh first. No call sends an empty token. + - Only a 2xx counts as revoked. Any other answer, `invalid_grant` included, is a refusal: the row stays with its references, and the response is `502 provider_revoke_failed` with the page as `revokeAt`. RFC 7009 answers a token that is already gone with 200. RFC 6749 §5.2 also gives `invalid_grant` for a token "issued to another client", and a `cimd` client id is a URL on the instance's API host (§4), so after a host move a revoke can answer that way while the authorization stays live. + - Nothing is sent when the entry has no endpoint, or when that token's secret is not found. Nothing we hold can revoke then, and a kept row only waits for a retry that can never succeed, so the removal finishes and the response carries the page as `revokeAt`, as §10.5 does for a pasted token. A secret that cannot be read for any other reason is a 502 with the row kept, since it may be readable later. 4. The material. 5. The delete. @@ -273,10 +276,14 @@ Each step can be tested without the vendor, except the live measurements in step - `every tool call records whose credential ran` - `the trail names the credential owner after the Connection is removed` 6. **Removal, and an owner who leaves.** - - §10.5's named tests, run over a hosted row, except `removal refreshes before it revokes at the provider`, which is GitHub's grant-deletion case + - §10.5's named tests, run over a hosted row, except `removal refreshes before it revokes at the provider`, which is GitHub's grant-deletion case, and `an authorization already gone at the provider counts as revoked`, which is GitHub's refresh answer and here would count a live token as revoked (§9) - `the provider revoke sends the refresh token to the entry's revocation endpoint` + - `a row with no refresh token revokes its access token, and no removal sends an empty token` + - `a provider answer other than 2xx is a refusal, invalid_grant included, and returns the page as revokeAt` + - `a removal whose token secret is not found sends nothing, finishes, and returns the page as revokeAt` + - `a token secret that cannot be read refuses the removal and keeps the row` - `a page entry's removal calls no provider and returns the page as revokeAt` - - `an entry whose revoke names neither kind or both, or a URL that is not https, is refused at load` + - `an entry whose revoke names no page, a key other than endpoint and page, or a URL that is not https, is refused at load` - TASK-147's witness per removal path (§7), before the first entry ships - `deleting a member who owns a hosted row is refused with the rows named, and the row, its grants and its material are unchanged` - TASK-181's three, each made by banning or deleting a member who owns the row and then calling through the broker, not by calling the check: @@ -287,6 +294,7 @@ Each step can be tested without the vendor, except the live measurements in step - Read first: whether the list's read tools carry `readOnlyHint: true` (§3). If they do not, stop for §11's question before the rest of the step. - `the page's call to start is credentialed`, before the walk (§4) - Measured live: that a removal's revoke took at Linear, shown by something other than its 200 (§3). Linear advertises one URL as both its `token_endpoint` and its `revocation_endpoint` (fetched 2026-09-29), so only a live removal shows which request that URL treats as a revoke. + - The entry's `page`: Linear's Security & access settings, whose "Authorized applications" list has "Revoke access" on each app (Linear docs, *Security & Access*, fetched 2026-09-30). Its URL is pinned from the signed-in walk. ## 11. What this corrects, and what stays open diff --git a/docs/plans/tools-catalogue-room-grants.md b/docs/plans/tools-catalogue-room-grants.md index 1d3f553e98..af20bca4aa 100644 --- a/docs/plans/tools-catalogue-room-grants.md +++ b/docs/plans/tools-catalogue-room-grants.md @@ -274,11 +274,11 @@ A grant on a per-person Connection is the same `RoomGrant` as on the App row: `c 1. **Grants.** `revokeConnectionGrants` (`services/roomGrantService.ts`, on `main`) revokes every grant on the row through `revokeGrant`, which runs `revokeCascade`, so every child dies at the same boundary #1661 built for a room revoke. 2. **Row.** `status: 'disconnected'`, `revokedAt` — the broker refuses from this instant even if the steps below are slow. `isActive` stays `true`: `sweepOrphanedConnectorSecrets` revokes the material of a row that is not active, and a row still waiting on step 3 needs its material. -3. **Provider, while the material is still there.** `DELETE /applications/{client_id}/grant` takes the user's access token in its body (Vera 67894), so the provider revoke reads the material one last time and runs **before** anything is revoked locally; it kills the whole authorization, refresh token included. The stored access token is almost always expired by the time anyone removes a Connection (an 8-hour token, a removal days later), and GitHub refuses the revoke with an expired one, so a removal that sent the stored token would `502` on every retry (Vera 67900). Removal therefore calls `credentialFor(connection)` first, on the row it already holds and regardless of the `disconnected` status step 2 just set, and gets a live token through the same fenced refresh in 10.3; only that token goes in the revoke body. An `invalid_grant` from that refresh means the authorization is already gone at the provider (revoked from GitHub's side, or the refresh token ran out its 6 months): removal counts it as revoked, skips to step 4, and the response carries the `revokeAt` URL (the person's GitHub *Applications* settings) so they can confirm it themselves. Google is the token-revocation endpoint, same order and same refresh-first rule. A pasted token has no revocation API, so the removal response carries a `revokeAt` URL for the person and the page shows it once. +3. **Provider, while the material is still there.** `DELETE /applications/{client_id}/grant` takes the user's access token in its body (Vera 67894), so the provider revoke reads the material one last time and runs **before** anything is revoked locally; it kills the whole authorization, refresh token included. The stored access token is almost always expired by the time anyone removes a Connection (an 8-hour token, a removal days later), and GitHub refuses the revoke with an expired one, so a removal that sent the stored token would `502` on every retry (Vera 67900). Removal therefore calls `credentialFor(connection)` first, on the row it already holds and regardless of the `disconnected` status step 2 just set, and gets a live token through the same fenced refresh in 10.3; only that token goes in the revoke body. An `invalid_grant` from that refresh means the authorization is already gone at the provider (revoked from GitHub's side, or the refresh token ran out its 6 months): removal counts it as revoked, skips to step 4, and the response carries the `revokeAt` URL (the person's GitHub *Applications* settings) so they can confirm it themselves. Google is the token-revocation endpoint, same order and same refresh-first rule. A pasted token has no revocation API, so the removal response carries a `revokeAt` URL for the person and the page shows it once. A provider revoke that took, or is counted as taken, ends this step with the **mark**: the row records it before any material goes, and a retry that finds the mark skips this step. Without it, a failure in step 4 or 5 leaves a row whose retry has no material to revoke with, so every retry refuses (Vera 75638). The mark is a server-owned key, which a PATCH cannot write (Vera 75651, Kai 75658). 4. **Material.** `connectorSecrets.revoke` on both references — only after step 3 succeeded, or the provider revoke reported the authorization already gone. -5. **Delete** the row — only after step 4. If step 3 or 4 fails, the row stays at `disconnected` with its references intact and the removal returns `502 provider_revoke_failed`; the person retries from the page. The retry still has the material because step 2 left `isActive` true: the sweep keeps a secret while its row is active and references it, and it never reads `status`. +5. **Delete** the row — only after step 4. If step 3 fails, the row stays at `disconnected` with its references intact and the removal returns `502 provider_revoke_failed`; the person retries from the page. The retry still has the material because step 2 left `isActive` true: the sweep keeps a secret while its row is active and references it, and it never reads `status`. A failure after the mark returns a code of its own, which says the provider revoke took, and the retry finishes steps 4 and 5 without the provider. -Named tests: `removing a Connection revokes every grant on it`, `the provider revoke runs before the material is gone`, `removal refreshes before it revokes at the provider`, `an authorization already gone at the provider counts as revoked`, `a failed provider revoke leaves the row and its references for a retry`, `the orphan sweep keeps the material of a row waiting on its provider revoke`, `a removed Connection's secret is gone by reference`. +Named tests: `removing a Connection revokes every grant on it`, `the provider revoke runs before the material is gone`, `removal refreshes before it revokes at the provider`, `an authorization already gone at the provider counts as revoked`, `a failed provider revoke leaves the row and its references for a retry`, `the orphan sweep keeps the material of a row waiting on its provider revoke`, `a removed Connection's secret is gone by reference`, `a retry after the mark skips the provider and finishes`, `a PATCH that supplies the mark does not write it`. ### 10.6 Open, for Sam's read