Repository navigation
feat(mcp): people answer an agent's request on a consent page - #882
Conversation
Review: GPT-6.1-Sol (xhigh), four roundsRound 1, at ffcb451. Nothing blocking. Two should-fix findings:
Round 2, at b54557e.
Round 3, at b9c12a6. One should-fix:
Round 4, at 7d0ec12. No blocking or should-fix findings. Sol confirmed every earlier fix, and the full diff against all six threat-model items:
One nit:
|
Acceptance: PASS with notesChecked Done means
Golden journeys
Other risks checked Direct checks against the same local server: Targeted suites: Rollback answers: match the diff. No migrations, descriptor, infrastructure or new stored shape. Allow uses #881's existing consent rows; reverting removes the POST route, so an old open form must restart. The green rollback-rehearsal job explicitly skipped the rehearsal because no migration or descriptor changed; it did not perform a live rollback. No Surfaces: served pages/shared shell, limits registry, consent vocabulary/product docs, dev-loop docs and skill apply and are updated. The API package, CLI contract, migrations, company-resource locking and repo layout are unchanged. The agent disconnect surface is the remaining stack work noted below. Not run
Notes
|
aeb26fd to
9fa5e38
Compare
2e101dc to
fa4c831
Compare
9fa5e38 to
d994ee4
Compare
The consent door from #739: the agent's mark, name and site meet the person's avatar, name and email; what the agent will and won't be able to do; a warning when the answer returns to this computer; Allow and Deny. POST /oauth/authorize answers from the same origin only, re-checks the request, counts only for the account the page showed and for ten minutes after it was shown. Agent access off names the admins and gives admins the way to turn it on; Back to the agent denies. Use another account signs out and back in to the same request. The page is limited to 10 a minute per address once signed in (oauth.consent.perMinute), and a persona switch another site sends the browser to is refused on dev instances. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nother account carries any request The answer fetches the client's document again, and its connection keeps the name from that fetch. An Allow whose page showed another name now asks again with the name it would record. Logout's body takes up to 64 KiB, so a long authorization request survives Use another account. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t name Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign-in and Use another account carry the request's address in their own, encoded again at each hop, and a long enough one outgrew Node's 16 KiB of headers after the person was signed out. A query over 4,096 characters is now refused on the page before sign-in, and logout's body cap is sized to that bound. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A browser carries the consent page's address as Referer through the redirect after Use another account, so one hop can hold two encoded copies of the request. The bound drops to 2,048 characters of query, which keeps the worst hop near 12 KiB inside Node's 16 KiB of headers, and the socket test now sends a browser's headers on both hops. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The bound counted the query's leading `?`, refusing a query one short of it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
fa4c831 to
cb370f4
Compare
… its limits (#883) Stacked on #882 (ticket #850); merges with the rest of #833's stack, not alone. ## What changed People's agents get one MCP door at `<instance>/mcp`. This PR builds the door itself: it serves MCP 2026-07-28, 2025-11-25 and 2025-06-18, refuses requests it shouldn't trust before reading a token, opens only for an agent connection's `work` token, and holds each person to their requests a minute. It lists the four tools; each answers "not built yet" until #852, #854 and #855 land. Closes #851 ## Look at 1. **Request trust, in this order:** the host a request was addressed to must be the instance's own, port included (421, no challenge). That is an absolute-form target's authority with its port or its scheme's default, else its one `Host` field; two `Host` fields are refused. The door never believes a forwarded host. **One infrastructure change, which needs your eyes:** by default the ALB drops any port from `Host` on its 443 listener, so `apps/infra` now turns on `preserveHostHeader`, an in-place attribute change that ships with the stack's deploy and stays on after a rollback (see Release impact). Nothing else on the server reads `Host` (Clerk's session check sets its own), and the duplicates preservation lets through are refused by the door. Next, a malformed or duplicated `Origin` gets 403 (a dev instance also refuses anyone else's), then GET/HEAD/DELETE get 405, then the bearer. The door never reads cookies; `apps/server/src/McpDoor.test.ts` signs a persona in and shows the cookie opens `/machines` but gets 401 at `/mcp`. 2. **Revisions follow the official SDK's dual-era rules,** body first (`packages/mcp/src/Revisions.ts`). One choice the spec doesn't spell out: a per-request `_meta` naming a *legacy* version gets `-32022`, because legacy versions are served only through `initialize`. A legacy client hears an unknown method over HTTP 200 (`-32601`), since a 404 means "session ended" to it; modern gets 404. 3. **Limits.** Failed checks spend `mcp.bearer.failures.perMinute` (60 per address) only after they fail. A working token is never refused, even after its address is limited. `mcp.requests.perMinute` (600, burst 600, per person, company override) is a token bucket: on `tools/call` it is the tool's `rate_limited` refusal over 200, otherwise 429 with `Retry-After`. `mcp.body.bytes` answers 413 before parsing, with `Connection: close`, and an oversized request still spends the person's minute. A declared length over the cap is refused unread. A chunked body is read to its end, keeping only the cap, so its 413 arrives however long the body runs (Node's 5-minute request timeout bounds it); the socket test sends 6 MiB chunked and 2 MB declared and gets each 413. 4. **Real clients against a dev instance** (details below): Codex lists the four tools on both revisions it speaks, and Claude Code goes from the 401 to the protected resource metadata and the authorization server metadata. <details><summary>Real clients and the Done-means refusals, transcripts</summary> ### Codex 0.163.0 at its default revision (2025-06-18) A throwaway `CODEX_HOME` holding only `[mcp_servers.patchy]` (`url` and `bearer_token_env_var`), a token from `pnpm dev mcp-token [email protected] --client Codex`, run from a temp dir outside `$HOME`: `codex exec --skip-git-repo-check --json "<prompt>"`. ~~~text agent: I’ll find Patchy’s tools, then call `find_patches` with no arguments. mcp_tool_call patchy.find_patches({}) -> failed: find_patches isn't built on this instance yet, so nothing was read or changed. Tell the person Patchy's MCP isn't ready here. agent: mcp__patchy__change_patch mcp__patchy__find_patches mcp__patchy__open_patch mcp__patchy__read_patch > find_patches isn't built on this instance yet, so nothing was read or changed. Tell the person Patchy's MCP isn't ready here. ~~~ The door's request events for that run: | Request | Status | Era / version | Method | Client | Tool | Code | | --- | ---: | --- | --- | --- | --- | --- | | POST /mcp | 200 | legacy 2025-06-18 | initialize | codex-mcp-client | — | — | | POST /mcp | 202 | legacy 2025-06-18 | notifications/initialized | — | — | — | | POST /mcp | 200 | legacy 2025-06-18 | tools/list | — | — | — | | POST /mcp | 200 | legacy 2025-06-18 | tools/call | — | find_patches | not_built | ### Codex 0.163.0 with `--enable mcp_2026_07_28` ~~~text agent: I’ll find the Patchy tools, list their exact names, then call `find_patches` with no arguments. mcp_tool_call patchy.find_patches({}) -> failed: find_patches isn't built on this instance yet, so nothing was read or changed. Tell the person Patchy's MCP isn't ready here. agent: ```text mcp__patchy__change_patch mcp__patchy__find_patches mcp__patchy__open_patch mcp__patchy__read_patch ``` `find_patches({})` returned: > find_patches isn't built on this instance yet, so nothing was read or changed. Tell the person Patchy's MCP isn't ready here. ~~~ | Request | Status | Era / version | Method | Client | Tool | Code | | --- | ---: | --- | --- | --- | --- | --- | | POST /mcp | 200 | modern 2026-07-28 | server/discover | codex-mcp-client | — | — | | POST /mcp | 200 | modern 2026-07-28 | tools/list | codex-mcp-client | — | — | | POST /mcp | 200 | modern 2026-07-28 | tools/call | codex-mcp-client | find_patches | not_built | ### Claude Code 2.1.308 finds the protected resource metadata from the 401 No token: `claude --setting-sources project --strict-mcp-config --mcp-config ./mcp.json --debug-file … -p "…"` from a temp dir, with the server at `http://127.0.0.1:<port>/mcp`. This run was against 60bf7d6. It isn't repeated on the head, because each run leaves discovery state in the user's Claude Code store. The 401 it reads is unchanged since: ~~~text HTTP/1.1 401 Unauthorized www-authenticate: Bearer resource_metadata="http://127.0.0.1:<port>/.well-known/oauth-protected-resource/mcp", scope="patches" ~~~ | Request | Status | Era / version | Method | Client | Tool | Code | | --- | ---: | --- | --- | --- | --- | --- | | POST /mcp | 401 | — | — | — | — | missing_token | | GET /.well-known/oauth-protected-resource/mcp | 200 | — | — | — | — | — | | GET /.well-known/oauth-authorization-server | 200 | — | — | — | — | — | ~~~text [DEBUG] MCP server "patchy": Initializing HTTP transport to http://127.0.0.1:<port>/mcp [DEBUG] MCP server "patchy": No token data found [DEBUG] MCP server "patchy": Saving discovery state (authServer: http://127.0.0.1:<port>/) [DEBUG] MCP server "patchy": No client info found; deferring client registration to authentication time [DEBUG] MCP server "patchy": Authentication required for HTTP server ~~~ With a minted token in `headers`, on the head, Claude Code speaks 2026-07-28 and lists the four tools: ~~~text The patchy-door-851 MCP server gives me these tools: ``` mcp__patchy-door-851__change_patch mcp__patchy-door-851__find_patches mcp__patchy-door-851__open_patch mcp__patchy-door-851__read_patch ``` I called `find_patches` with no arguments. It returned an error instead of a list of patches. Its exact answer: > find_patches isn't built on this instance yet, so nothing was read or changed. Tell the person Patchy's MCP isn't ready here. So Patchy's MCP isn't ready on this instance yet. Nothing was read or changed. ~~~ | Request | Status | Era / version | Method | Client | Tool | Code | | --- | ---: | --- | --- | --- | --- | --- | | POST /mcp | 200 | modern 2026-07-28 | server/discover | claude-code | — | — | | POST /mcp | 200 | modern 2026-07-28 | tools/list | claude-code | — | — | | POST /mcp | 200 | modern 2026-07-28 | tools/call | claude-code | find_patches | not_built | ### The refusals Done means names, against the same dev instance ~~~text $ POST /mcp Host: evil.example:<port> (a rebinding page's name for this address) HTTP/1.1 421 Misdirected Request {"error":"invalid_host","error_description":"Patchy's MCP answers only at http://127.0.0.1:<port>/mcp."} $ POST /mcp Origin: https://evil.example (a dev instance takes only its own) HTTP/1.1 403 Forbidden {"error":"invalid_origin","error_description":"A dev instance's MCP answers only its own origin, http://127.0.0.1:<port>, or none."} $ POST /mcp Origin: evil (malformed) HTTP/1.1 403 Forbidden {"error":"invalid_origin","error_description":"A dev instance's MCP answers only its own origin, http://127.0.0.1:<port>, or none."} $ POST /mcp Origin: http://127.0.0.1:<port> (its own) HTTP/1.1 200 OK {"jsonrpc":"2.0","id":0,"result":{"protocolVersion":"2025-06-18","capabilities":{"tools":{"listChanged":false}},"serverInfo":{"name":"patchy","title":"Patchy","version":"0.15.0"},"instructions":"You act for Patchy Dev at Patchy Dev through Patchy, where the company's internal tools are patches. find $ GET /api/patches Bearer <build token> (the CLI's machine token is live) HTTP 200 $ POST /mcp Bearer <build token> HTTP/1.1 401 Unauthorized www-authenticate: Bearer resource_metadata="http://127.0.0.1:<port>/.well-known/oauth-protected-resource/mcp", scope="patches", error="invalid_token" {"error":"invalid_token","error_description":"This token is unknown or its agent connection has ended. Connect the agent to Patchy again."} $ Revoke all machines on Your machines, signed in as [email protected] HTTP 303 $ POST /mcp Bearer <work token> (its connection has ended) HTTP/1.1 401 Unauthorized www-authenticate: Bearer resource_metadata="http://127.0.0.1:<port>/.well-known/oauth-protected-resource/mcp", scope="patches", error="invalid_token" {"error":"invalid_token","error_description":"This token is unknown or its agent connection has ended. Connect the agent to Patchy again."} ~~~ </details> ## How it was verified - `packages/mcp`: request trust (Host case, trailing dot, default port, DNS-rebinding hosts; Origin shapes, duplicates, dev), the revision classifier against the status table, and the door over a migrated database: 401s and the challenge, `build` vs `work`, an ended connection, the failed-check limit counted after failure, the 413 boundary at exactly 1,114,112 bytes, initialize negotiation, discover and tools/list cache hints, the four tools' annotations, the per-person bucket shared across a person's clients, and one wide event per request that never holds the token, arguments, change key or instructions. - `apps/server/src/McpDoor.test.ts`, the whole server over a raw socket: the request event under `/mcp`, rebinding hosts, an absolute-form target, two `Host` fields, duplicated `Origin`, a real session cookie, HEAD, and the 413 on the wire for chunked and declared bodies over the cap. - Codex 0.163.0 (both revisions) and Claude Code 2.1.308 against `pnpm dev`, with per-invocation config only: a throwaway `CODEX_HOME`, `--mcp-config` from a temp dir outside `$HOME`. - Rollback rehearsal, `pnpm test:rollback-rehearsal --live e4243ff` (main, which has #837 and #838): "Exercised rollback paths passed: e4243ff → 60bf7d6 → e4243ff → 60bf7d6". The CI check runs against production's commit and passes here only because this PR adds no migration. - `pnpm verify` runs on the final head before READY. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — a new route, new registry rows, new wide event fields and one ALB attribute that only the door reads; no migration, and nothing existing changes shape - **What does a revert leave behind?** No stored data: the door keeps its buckets in memory and writes no rows. **The ALB keeps host header preservation on:** CloudFormation leaves a load balancer attribute alone when a template stops listing it, so redeploying the template from before this PR doesn't turn it off. Turning it off takes an explicit `loadBalancer.setAttribute("routing.http.preserve_host_header.enabled", "false")` in `apps/infra/src/AppStack.ts` and a deploy; `preserveHostHeader: false` writes nothing, so it wouldn't. Agents connected to `/mcp` would get the page fallback's 404 until the door returns. - **Does the release before it still work with that?** Yes. Nothing in it reads `Host`: Clerk's session check sets its own, and pages use the configured public origin. A preserved `Host`, with its port or a second `Host` field, changes nothing for it. The stack ships as one release, and nothing below it reads anything this PR writes, so it isn't `one-way`. Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code; reviewed and accepted by GPT-6.1-Sol (xhigh).
## What changed This PR adds release 17's What's new entry, written from `5dd94f3`. It covers everything merged since release 16's `through` (`dd3f41f`), and it sets the `patchy` release to `0.17.0` in `packages/patchy/package.json` and `CURRENT_RELEASE`. With this release, people's agents can use their company's patches through Patchy MCP (#833). | Change | PRs | | --- | --- | | New: Your AI agent can use your company's tools | #873, #878, #880, #881, #882, #883, #884, #886, #887 | | New: Admins choose whether agents can use the company's tools | #871 | | Improved: Your machines shows your agents too (Revoke all machines is now Disconnect everything) | #885, #879 | | New: See what agents can do with a tool | #876 | | New: The log says when an agent made a change | #888 | | New: Your agent can make a tool ready for agents | #869, #870, #872, #875, #896 | | Behind the scenes: agents' calls have their own limits, and a server only an agent uses rests a minute after its last call | #889, #892 | | Behind the scenes: New and Improved changes are public, for patchyhq.com | #893 | | Behind the scenes: library updates | #899 | Five merged PRs get no line: - #874 is release 16's own entry. - #894 is dev tooling: worker agent launchers and scenario data. Its one CLI fix lets a `patchy` installed outside a tier 2 repo publish it. The skills have agents use the repo's pinned `pnpm patchy` instead, so that path is off the documented one. - #900 is CI. - #901 rewords an internal skill. ## Look at - **The entry**, at the top of `releases` in `packages/core/src/whatsNew.ts`. - It names only Claude Code and Codex. Both have connected through real consent against dev instances. Hosted clients (Claude.ai, ChatGPT) are checked in production only (`docs/product.md` › Patchy MCP › Acceptance). - Its labels are the pages' own: Agent access on Company, Your machines, What agents can do, Disconnect everything, and "Jordan Lee via Claude". - **Rollback safety, from the live commit `e4243ff` to `5dd94f3`.** - No PR in the range is labelled `one-way`, and every PR answers both Release impact questions with "Yes". - Migrations 0020–0025 are all additive: - three defaulted or nullable columns on `companies`; - `agent_name` on the runtime log, with a widened `credential_kind` check; - the agent connection tables, `agent_consents` and `change_keys`; - two columns on execution bindings. The new tables reference `users` without a cascade, but no release deletes users or companies. Release 16 reads the runtime log only for credential kinds it knows, so rows from agents can't break it. - `rollback-rehearsal` on #892 rehearsed the whole stack, since #892 adds the last migration and the rest of the stack sits below it: `Exercised rollback paths passed: e4243ff → c8bede4 → e4243ff → c8bede4, in 238s.` #896's run skipped, because it changes no migration or handler descriptor. - #883 turns on the load balancer's host header preservation, which the Deploy workflow's app stack deploy applies. A rollback leaves it on. That's harmless, because release 16's server never reads `Host`. - A rollback takes `/mcp` and `/whats-new.json` away. Connected agents get a 404 until this release returns, and then their connections work again, unless one ended in between. Agent tools published in between stay refused to pages, because #837 already shipped in release 16. ## How it was verified - `pnpm check` on `2d528b1`: format, lint, typecheck and synth passed. In the test step, 2,300 of 2,301 tests passed. The one failure was `packages/sdk/src/install.test.ts` › "says how to reach patchy when the prefix's bin is not on PATH", which timed out at 180 s while the shared machine was loaded. Rerun alone, that file passes all 7 tests in 62 s. The release's own tests pass too: `whatsNew.test.ts`, `schemas.test.ts` and `WhatsNewPages.test.ts`. - The live commit was pinned from `/healthz/deep`: `e4243ff`, release 16. The Deploy run updated last succeeded, and none is unfinished. - Each PR in the range was read with `gh pr view`, including its Release impact answers. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required This PR changes only the changelog text and the `patchy` version. As with every release, a CLI installed before this deploy is told to upgrade. - **What does a revert leave behind?** Nothing. People whose seen marker reached 17 would just see no new release. - **Does the release before it still work with that?** Yes. If this release misbehaves, roll back to `e4243ff54d2acbbc88b60eeb0cf9b82a26dc9d5d` (release 16). Prepared by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code. Co-authored-by: Claude Opus 5.5 <[email protected]>
## What changed Patchy MCP has been live in production since release 17, but the product doc, the glossary map and the MCP glossary still called it specified or being built. They now describe what runs, and where the build settled a detail differently from the spec, the spec now says what the code does. Production acceptance (#861) hasn't run: the section says so, and claims about particular clients are framed as what the build was designed for. Part of #862. This is everything in #862's "What to do" except "What remains takes acceptance's findings", which waits for #861. ## Look at **Status and pointers.** Each of these now reads as built: - `docs/product.md`: the "Built and live" intro line names Patchy MCP; the Patchy MCP section opens "Built, and live since release 17", links #833 and says #861 hasn't run. - The same file's tier 2 sentence, `agent/` pointer, Companies (admins, deactivation), Who's who and Bounds' admission rule. - `GLOSSARY-MAP.md`: Auth and Patchy MCP. - `packages/mcp/GLOSSARY.md`. - `README.md`: the layout, plus one sentence on tier 2. - `AGENTS.md`'s tier 2 line. - `docs/OPERATIONS.md`: request events. **Spec details the build settled differently.** Each claim was checked against main: | Claim in the doc | What main does | Where | | --- | --- | --- | | A forwarded host is trusted from Patchy's proxy | The door never believes a forwarded host and refuses two `Host` fields | `packages/mcp/src/RequestTrust.ts:7-10` | | `Host` gates the OAuth endpoints too | Only `/mcp` is Host-gated; a dev instance serves every route on `127.0.0.1` | `packages/mcp/src/Door.ts:372`, `packages/auth/src/OAuthEndpoints.ts:19-20` | | An unknown method is `404` | `404` on 2026-07-28, `200` on legacy, where 404 means session ended | `packages/mcp/src/Door.ts:356-363` | | An `unknown_outcome` always resolves on retry | Only until a few minutes before 24 h; then `key_expired` | `packages/mcp/src/ChangeKeys.ts:116-123`, `Calls.ts:339-347` | | An action's key never runs again | Unless Runtime refused the first try before it started | `packages/mcp/src/ChangeKeys.ts:60-64`, `Calls.ts:409-419` | | `resource` is bound through exchange and refresh | Optional; must name the door wherever sent | `packages/auth/src/Consents.ts:203-205, 345-348` | | Consent re-asks after an account switch | Also re-asks an Allow after the client's name changes | `packages/auth/src/OAuthEndpoints.ts:423-436` | | With agent access off, consent names the admins | To members; an admin is told to turn it on | `packages/auth/src/OAuthEndpoints.ts:182-185` | | "logged as Jordan via Claude" | The person's full name: "Jordan Lee via Claude" | `packages/auth/src/OAuthEndpoints.ts:151-162` | | The docs say how to reconnect by hand | Not written; Connect an app gives first-time steps only | no such doc in `docs/`, `skills/`, `packages/sdk/skills` | | Publish's warning points at `<instance>/company` | `<instance>/company/agent-access` | `packages/patches/src/PatchesApi.ts:454` | | The instance names a duplicated tool | It can't: inspection drops the bundle's message; only the CLI names it | `packages/execution/src/inspection.ts:12-16` | | A read-only action's writes are type errors | Table and file writes are; Pidgeon writes typecheck and the callback gate refuses them | `packages/patchy/src/server.ts:247-262`, `packages/runtime/src/CallbackGateway.ts:107-111` | | `dev.log` names the person | It writes their id: `usr_dev via patchy dev …` | `packages/patchy/src/devLog.ts:23-27` | | New repos include `agent` | Tier 1 and 2 repos do | `packages/patchy/src/initProject.ts:207` | | The MCP request event says whether its binding is agent-only | Only the binding event carries `agentOnly` | `packages/analytics/src/WideEvents.ts:228` | | An in-flight slot is held after the client disconnects | A client gone before dispatch gives it back | `packages/mcp/src/Admission.ts:13-17` | | The week-unused note opens "Not used since 2 Oct." | It opens "If you reconnected …" | `packages/auth/src/MachinesPage.ts:178` | | "today a person types everything into them" | Agents now find, read and change patches too | the section itself | | Pages "get phone checks when built" | They were checked at 390 px in their PRs' screenshots (#871 #876 #882 #885 #931 #932) | — | ## How it was verified - Four read-only passes went claim by claim through the Patchy MCP section against main at 2f9f7c1. I re-read the code for every finding before changing a line. The table lists each change. - **Findings left as they are:** - "the one secret Patchy keeps recoverable": the context is the connection's tokens. - "each change gets a fresh change key" in `patchy dev agent`: the code's own comment says the same. - The lists of which outside clients can connect: these are facts about those clients, and the code offers no dynamic registration. - `pnpm check`: format, lint, typecheck and synth passed. Two test files failed under load average 19, a 5 s timeout in `PgliteCompanyDatabases.test.ts` and a worker SIGKILL in `devExecution.test.ts`. Both passed when rerun alone. Neither touches docs. - **Not done here:** `packages/sdk/skills/patchy-server/SKILL.md:415` and `packages/sdk/src/sdkCapabilities.ts:107` say a patch's tools fit in 64 KiB, but the check allows 60 KiB of that answer. Those files belong to another lane, so they're left for a follow-up. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required Docs only. - **What does a revert leave behind?** Nothing; the docs go back to calling Patchy MCP specified. - **Does the release before it still work with that?** Yes. Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code; reviewed and accepted by GPT-6.1-Sol (xhigh). --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
















Stacked on #881 (ticket #849); merges with the rest of #833's stack, not alone.
What changed
An MCP client asking to connect got #849's placeholder heading and nothing to answer with. Now the person gets the consent door picked on #739. It shows who is asking to act as whom, and what the agent will and won't be able to do. The person answers Allow or Deny, and only that answer goes back to the client.
Closes #850
Look at
1. The answer's guards (
packages/auth/src/OAuthEndpoints.ts).POST /oauth/authorizeposts back the request's own query and runsConsents.checkon it again, then calls #849'sapproveordeny. Each item below is a test inOAuthEndpoints.test.tsorDevPersonas.test.ts. I removed each guard in turn and its test went red.RequireSession.sameOrigin, the same check as every first-party POST. AnotherOrigin,Origin: null, or noOriginwithoutSec-Fetch-Site: same-origingets a 403 before the body is read. Nothing is recorded.frame-ancestors 'none'.userIdthe page was rendered for. If someone else is signed in when the answer arrives, the page is drawn again for them with the warning, as a 409, and nothing goes back to the client.GET /dev/sign-in?as=is refused with a 403 forSec-Fetch-Site: cross-siteorsame-site, and sets no cookie.none,same-originand no header all still switch.redirect_urithe document doesn't list gets the "can't connect" page as a 400, with noLocation. A signed-out answer is sent back to the page (303 toGET /oauth/authorize?…) and answers nothing.workcredential and its tokens #846'sclientName. The site is a host Patchy fetched from, so DNS bounds it. Both are escaped with everything else. The test document's name is<img src=x onerror=alert(1)>plus U+202E and 80as. It renders escaped, without the bidi control, and cut to 64 characters.form-action. Browsers hold a form's redirect toform-action, so the page adds the redirect's origin, for exampleform-action 'self' https://claude.ai. A host CSP can't name exactly, such as[::1]or one with other characters, adds only its scheme. A stranger's document can never write into the header.Referer. The bound is 2,048 characters of query (real clients send under 1 KiB). The socket test carries the longest allowed request through sign-out and back to the sign-in door, with a browser's headers.2. For Allison: four calls the ticket didn't settle.
/logoutnow takes areturn, so it signs out and lands on the sign-in door for the same request. The off page has it too, for someone signed in to the wrong company.oauth.consent.perMinutein the registry anddocs/limits.md.Before and after
Before, #849's placeholder:
After, as Jordan Lee (member) at Brightline Studio on a
pnpm dev up brightlineinstance. The real Claude and Claude Code documents were fetched from claude.ai.Claude (hosted redirect)
Claude Code (answer returns to this computer)
The account changed while the page was open (Priya signed in from another tab, then Jordan's page pressed Allow)
Agent access off, as a member, then as an admin
The request ran out (
shownset an hour back, then Allow)Deactivated (today's page) and no company yet (create-or-join, then back to consent, where the new company's access is off and its creator is the admin)
Use another account lands on the sign-in door, returning to the same request
Phones (390 px)
How it was verified
brightlineenvironment, with the real claude.ai documents):127.0.0.1port where the script listened. The callback gotcode,state=client-stateandiss=<instance>. The code exchanged at/oauth/tokenfor200 {access_token, expires_in, refresh_token, scope: "patches", token_type: "Bearer"}.error=access_denied,stateandiss, and no code.OAuthEndpoints.test.tsgains 13 consent tests. They cover:[::1]);DevPersonas.test.tscovers the persona refusal.AuthPages.test.tscovers logout'sreturn, which stays local.AuthPages.socket.test.tscovers the longest request through sign-out to the door.apps/server/src/AgentConsent.test.tsnow approves through the page's POST instead of a service call.tsc -p tsconfig.test.jsonand the builds of auth, portal and server are clean.pnpm verifyon 2e101dc. 8 of 9 steps pass: format, lint, typecheck, synth, postgres-concurrency, cli-smoke, tier2-smoke and browser (81). The test step passed 2,183 of 2,184. The one failure waspackages/patchy/src/cliRepoPublish.test.ts: tar readtypescript/lib/_tsc.jsas another checkout on this machine rewrote that shared, hard-linked file (File shrank by 10893220 bytes). The suite passes rerun alone (3/3), and passes in CI's three test jobs on this head.pnpm test:rollback-rehearsal --live e4243ffpassed e4243ff → 2e101dc → e4243ff → 2e101dc in 185 s. CI'srollback-rehearsaljob skips, since nothing here migrates.Surfaces:
agent-mark(with core'sagentMarkandagentIcon, now shared with the guide),consent-stripandcan-list, andui-consistencynames all three. The consent door joins its list of doors.oauth.consent.perMinute, rendered intodocs/limits.md.docs/product.md› Consent gains the ten minutes and how Use another account behaves. The Auth glossary's Consent gains the ten minutes.docs/DEVELOPMENT.mdgains the persona refusal, "Connecting through consent" (the walkthrough The authorization flow: authorize, the code exchange and refresh #849 left for this page) and a Consent entry under What to exercise.patchy-dev-loopsays the same.Untouched:
packages/api, sodocs/API.mdstands.noneor noSec-Fetch-Site.Release impact
One new route (
POST /oauth/authorize), a registry row and shell CSS./logouttakes an optionalreturn. No schema change.agent_consentsrows, which expire in a minute.Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code; reviewed and accepted by GPT-6.1-Sol (xhigh).