Skip to content

feat(mcp): people answer an agent's request on a consent page - #882

Merged
allisonmahmood merged 6 commits into
mainfrom
mcp/850-consent-page
Oct 23, 2026
Merged

allisonmahmood merged 6 commits into
mainfrom
mcp/850-consent-page

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

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/authorize posts back the request's own query and runs Consents.check on it again, then calls #849's approve or deny. Each item below is a test in OAuthEndpoints.test.ts or DevPersonas.test.ts. I removed each guard in turn and its test went red.

  • CSRF. The answer goes through RequireSession.sameOrigin, the same check as every first-party POST. Another Origin, Origin: null, or no Origin without Sec-Fetch-Site: same-origin gets a 403 before the body is read. Nothing is recorded.
  • Clickjacking. Every consent page sends frame-ancestors 'none'.
  • Account switch. The form carries the userId the 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.
  • Persona switch mid-consent (dev only). GET /dev/sign-in?as= is refused with a 403 for Sec-Fetch-Site: cross-site or same-site, and sets no cookie. none, same-origin and no header all still switch.
  • Open redirect through Deny. Deny runs the same check as Allow. A query whose redirect_uri the document doesn't list gets the "can't connect" page as a 400, with no Location. A signed-out answer is sent back to the page (303 to GET /oauth/authorize?…) and answers nothing.
  • What the page echoes. The client's name is already cleaned and cut to 64 characters by Agent connections: the work credential and its tokens #846's clientName. 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 80 as. It renders escaped, without the bidi control, and cut to 64 characters.
  • form-action. Browsers hold a form's redirect to form-action, so the page adds the redirect's origin, for example form-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.
  • The name the connection keeps is the one the page showed. The answer fetches the client's document again, so the form carries the shown name. An Allow whose document now names the client differently asks again (409), and approves nothing.
  • A request too long to carry through sign-in is refused before it (414). Sign-in and Use another account carry the request's address in their own addresses, encoded again at each hop, and a browser adds the page it came from as 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.

  • The page lasts ten minutes. "A request that ran out" needs a lifetime, and nothing server-side expires before Allow. The form carries when it was shown. An answer more than ten minutes later gets "This request has run out" (410), and nothing goes back to the client. Ten minutes matches a device login's code. The time isn't signed: only a same-origin POST from the person's own browser can send it, so changing it helps no one but themselves.
  • "Logged as Jordan Lee via Claude", with the full name. The mock says "Jordan via Claude", but the log will write "Jordan Lee via Claude" (Prototype: the worker pipeline's pages as static mocks #739), and the page promises what the log says.
  • Use another account is today's "Not you?" sign-out block under the footer, with a new label. The mock puts it inline in the footer sentence, but a sign-out needs a POST, and the shell has no inline link-button style. /logout now takes a return, 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.
  • The limit counts signed-in loads and answers. Signed-out loads only reach the sign-in door, fetch nothing and spend nothing. A connect costs two (page and answer). This is oauth.consent.perMinute in the registry and docs/limits.md.

Before and after

Before, #849's placeholder:

Desktop Phone

After, as Jordan Lee (member) at Brightline Studio on a pnpm dev up brightline instance. 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 (shown set 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)

Claude Claude Code Account changed
Off, member Off, admin Ran out
Deactivated Create-or-join Back to consent Use another account

How it was verified

  • Done means, on a dev instance in a browser (Playwright as dev personas against the brightline environment, with the real claude.ai documents):
    • Allow. Claude Code's request, with the redirect on a random 127.0.0.1 port where the script listened. The callback got code, state=client-state and iss=<instance>. The code exchanged at /oauth/token for 200 {access_token, expires_in, refresh_token, scope: "patches", token_type: "Bearer"}.
    • Deny. The callback got error=access_denied, state and iss, and no code.
    • Account switch. Priya signed in from another tab, then Jordan's page answered. Patchy asked again as Priya and sent nothing back.
    • Every state above, at 1280 px and 390 px.
  • Tests.
    • OAuthEndpoints.test.ts gains 13 consent tests. They cover:
      • the page's content and headers;
      • the loopback warning with its CSP source (IPv4 and [::1]);
      • escaping and the cut;
      • Allow then exchange, and Deny recording nothing;
      • cross-site answers;
      • the account switch and the renamed client;
      • the ten-minute boundary (TestClock at 10:00 passes, 10:01 runs out);
      • access off for a member and an admin, including Allow from a page shown while it was on;
      • a signed-out answer, and Deny to an unlisted redirect;
      • the 2,048-character bound, exactly at it and over it;
      • the per-address limit.
    • DevPersonas.test.ts covers the persona refusal. AuthPages.test.ts covers logout's return, which stays local. AuthPages.socket.test.ts covers the longest request through sign-out to the door.
    • apps/server/src/AgentConsent.test.ts now approves through the page's POST instead of a service call.
    • Each guard in "Look at" was removed in turn, and its test went red.
  • Review. GPT-6.1-Sol (xhigh), four rounds; the rounds and their outcomes. Round 4 found nothing blocking or should-fix.
  • Suites. CI's 14 checks pass on the head. Locally: auth (216), core (81), portal (98), limits (25) and the server's AgentConsent test pass. eslint, prettier, tsc -p tsconfig.test.json and the builds of auth, portal and server are clean.
  • pnpm verify on 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 was packages/patchy/src/cliRepoPublish.test.ts: tar read typescript/lib/_tsc.js as 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.
  • Rollback rehearsal against production's commit, which has Tier 2 readers accept handler descriptions, read-only actions and agent tools, and enforce them #837 and Deactivation and Disconnect everything end pending device logins and record when a person's credentials ended #838: pnpm test:rollback-rehearsal --live e4243ff passed e4243ff → 2e101dc → e4243ff → 2e101dc in 185 s. CI's rollback-rehearsal job skips, since nothing here migrates.
  • Acceptance: PASS with notes on 2e101dc, by GPT-6.1-Sol (xhigh).

Surfaces:

  • The shell gains agent-mark (with core's agentMark and agentIcon, now shared with the guide), consent-strip and can-list, and ui-consistency names all three. The consent door joins its list of doors.
  • The limits registry gains oauth.consent.perMinute, rendered into docs/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.md gains 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-loop says the same.

Untouched:

  • packages/api, so docs/API.md stands.
  • The CLI.
  • Migrations.
  • The dev runner's code: its tools already send none or no Sec-Fetch-Site.

Release impact

  • Breaking — requires action from anyone already running this
  • Not breaking — no action required

One new route (POST /oauth/authorize), a registry row and shell CSS. /logout takes an optional return. No schema change.

Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code; reviewed and accepted by GPT-6.1-Sol (xhigh).

@github-actions github-actions Bot added area:server Touches the server area area:core Touches the core area area:docs Touches the docs area area:ui Portal and first-party browser pages, shared rendering and styles size:l 501-1,000 changed lines labels Oct 22, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review: GPT-6.1-Sol (xhigh), four rounds

Round 1, at ffcb451. Nothing blocking. Two should-fix findings:

  • The recorded client name could differ from the one shown. The answer fetches the client's document again, and approval records that fetch's name. If a document isn't cached, or its cache expires while the page is open, the page could promise "via Agent A" while Allow records "Agent B". Fixed in b54557e. The form carries the name it showed (a hidden client field). An Allow whose fresh document names the client differently asks again (409) with "The agent changed its name while this page was open". It approves nothing. Test: asks again when the client renamed itself since the page was shown.
  • Use another account broke for long requests. It carries the whole authorization request in /logout's return, past logout's 4 KiB body cap. Fixed in b54557e, then b9c12a6 and 7d0ec12 (see rounds 2 and 3).
  • Note: the unsigned shown time only lets an untouched form run out; it's no security guarantee. Agreed, and the PR says so.

Round 2, at b54557e.

  • Blocking: apps/server/src/AgentConsent.test.ts didn't send the new client field. Fixed in c4aa2c0, which I pushed before the round reported. CI's test jobs on c4aa2c0 pass.
  • Should-fix: a long request outgrows Node's 16 KiB of headers once nested in /login?return=, leaving a signed-out person at a 431. The authorization flow: authorize, the code exchange and refresh #849's own signed-out sign-in link nests the same address. Fixed in b9c12a6: GET and POST /oauth/authorize refuse a query over a bound with the "can't connect" page (414), before sign-in, the limit or any document fetch. Logout's cap is sized to that bound. Tests: the refusal, signed out and signed in, with nothing fetched; and AuthPages.socket.test.ts, which carries the longest allowed request through POST /logout to the /login door over a real socket.

Round 3, at b9c12a6. One should-fix:

  • A browser also sends the consent URL as Referer through logout's redirect, so one hop can hold two encoded copies of the request. At 4,096 characters that still overflowed (431 reproduced in Chromium). Fixed in 7d0ec12. The bound is now 2,048 characters of query (real clients' requests are under 1 KiB), and logout's cap is 8 KiB. The socket test now sends a browser's headers on both hops: the redirect's, with the consent URL as Referer, and the worst dev-persona hop's. It returns 431 when put back to the old size.

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:

  • CSRF and the same-origin check;
  • framing;
  • the account and client-name binding;
  • the cross-site persona switch;
  • open redirects through Deny, Back, signed-out answers, Use another account and error paths;
  • escaping, CSP and caps for what the client's document says.

One nit:

  • The bound counted the query's leading ?, so a query of exactly 2,048 characters got 414. Fixed in 2e101dc, with an exact-boundary assertion, which fails against the old count.

@github-actions github-actions Bot added size:xl Over 1,000 changed lines; review in multiple passes and removed size:l 501-1,000 changed lines labels Oct 22, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance: PASS with notes

Checked 2e101dcd709cd023ed9d94c8d948f271d6900a78 (base aeb26fd0c93e012cf201a477254e3d54799cc06a, #881) on a fresh brightline dev environment, by GPT-6.1-Sol (xhigh) in Codex through T3 Code. No production access or source changes.

Done means

  • Approve and deny in a browser: passed. The instance fetched the real Claude and Claude Code metadata documents. Jordan pressed Allow; the scripted loopback client received a code, the original state and the correct issuer, then exchanged it using S256 PKCE: 200, scope=patches, token_type=Bearer, with access and refresh tokens. Deny returned access_denied, the original state and issuer, with no code. The off page's Back to Claude Code also denied.
  • Each state on desktop and phone: passed. Inspected screenshots at 1280 px and 390 px: hosted and loopback clients, account changed, access off as member/admin, deactivated, create-or-join, and expired. Consent actions have 44 px targets and the consent/off pages fit without horizontal overflow. A new person created a company and returned to the original request as its admin, with access off.
  • Answer after an account switch: passed. Jordan's form stayed open while another browser window signed in as Priya. Allow returned 409, showed Priya and the warning, and asked again. The client's callback count did not change.

Golden journeys

  • Sign in: passed. After browser sign-out, the company kickoff page returned 401 and the sign-in door. Choosing Jordan returned to that exact page, which returned 200 and rendered its frame. Use another account preserved the consent request through logout and sign-in.
  • Log a machine in and out: passed. The environment's isolated CLI requested login; Allison confirmed the code in the browser and named the machine Acceptance 882. whoami named Allison, Brightline Studio and that machine. CLI logout reported revoked: true; it disappeared from Your machines.
  • Find and open a tool: passed. Jordan's Home listed the scenario patches; searching kudos produced one match and opening it rendered the Kudos frame and its seeded entries.
  • Enrollment and access lifecycle: passed. Create-company returned to consent. Deactivating an already signed-in Marcus made consent return 403, “Your account is deactivated”; reactivation restored consent. Turning agent access off after a form loaded made Allow return 409, showing the off page without a client callback.

Other risks checked

Direct checks against the same local server:

Consent page:                  200; private, no-store; frame-ancestors 'none'
Foreign Origin / Origin:null:  403; no Location
Deny to an unlisted redirect:  400; no Location
Signed-out answer:             303 back to the local consent GET
Cross-site/same-site persona:  403; no Set-Cookie
Oversized signed-out request:  414; no Location
Consent loads from one address: 10 × 200, then 429; Retry-After: 60
Expired form answer:           410; nothing connected; no client callback

Targeted suites: OAuthEndpoints.test.ts, AuthPages.test.ts, AuthPages.socket.test.ts, DevPersonas.test.ts, and server AgentConsent.test.ts: 5 files, 47 tests passed. These also exercise hostile metadata escaping, changed client names, exact query limits, the ten-minute boundary, and logout's longest allowed return path. All 14 CI checks pass on this head, including live Clerk and browser coverage.

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 one-way label is needed for this diff.

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

Desktop and phone evidence (fresh scenario data)
State Desktop, 1280 px Phone, 390 px
Claude, hosted answer Claude desktop Claude phone
Claude Code, local answer Claude Code desktop Claude Code phone
Account changed Account changed desktop Account changed phone
Access off, member Off member desktop Off member phone
Access off, admin Off admin desktop Off admin phone
Request ran out Expired desktop Expired phone
Deactivated Deactivated desktop Deactivated phone
No company yet Create or join desktop Create or join phone

@allisonmahmood
allisonmahmood force-pushed the mcp/849-authorization-flow branch from aeb26fd to 9fa5e38 Compare October 23, 2026 02:09
@allisonmahmood allisonmahmood mentioned this pull request Oct 23, 2026
@allisonmahmood
allisonmahmood force-pushed the mcp/849-authorization-flow branch from 9fa5e38 to d994ee4 Compare October 23, 2026 14:08
Base automatically changed from mcp/849-authorization-flow to main October 23, 2026 14:42
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]>
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]>
@allisonmahmood
allisonmahmood merged commit 1b04d59 into main Oct 23, 2026
14 checks passed
@allisonmahmood
allisonmahmood deleted the mcp/850-consent-page branch October 23, 2026 15:00
allisonmahmood added a commit that referenced this pull request Oct 23, 2026
… 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).
allisonmahmood added a commit that referenced this pull request Oct 23, 2026
## 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]>
@allisonmahmood allisonmahmood mentioned this pull request Oct 28, 2026
1 of 2 tasks
allisonmahmood added a commit that referenced this pull request Oct 29, 2026
## 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core Touches the core area area:docs Touches the docs area area:server Touches the server area area:ui Portal and first-party browser pages, shared rendering and styles size:xl Over 1,000 changed lines; review in multiple passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

People answer an agent's request on a consent page

1 participant