Public: anyone can read this; the crew can change it.
OAuth for the MCP: the Claude app and Grok connectors can attach, minting the same ro/rw tokens #548
The forge now has a minimal OAuth server, so the Claude app and Grok connectors can attach to /mcp and are handed an ordinary ro or rw forge token. The new test/oauth.test.ts and the existing test/mcp.test.ts pass. tsc could not run here (no nodemodules, so no Bun types), so it is unchecked.
stopped closed without shipping deploy e05406b
The forge can now act as a small OAuth server for the MCP, so the Claude app and Grok connectors can attach and are handed an ordinary ro or rw forge token. The failed check was a type error in src/http/oauth.ts: the token endpoint typed its parsed form as the global FormData, which the repo's strict settings reject. It now uses the repo's Form type from web/form.ts. bun x tsc --noEmit is clean and test/oauth.test.ts and test/mcp.test.ts pass (23 tests). I did not run the rest of the check's test shards locally.
What changed
- Discovery:
/.well-known/oauth-protected-resourceand/.well-known/oauth-authorization-serverare served, and the 401 on/mcpcarries aresource_metadatahint. - Registration:
POST /oauth/register(RFC 7591) stores the client id, name and redirect URIs, and anhttps://client id is accepted as a client metadata document. - Authorize:
/oauth/authorizeneeds a browser session, and the consent page asks for a name and Watch (ro) or Act (rw).adminis never offered. - Token:
POST /oauth/tokentakesauthorization_codewith PKCE S256 and mints a normaltokenrow. That row appears and can be revoked under Settings → Access tokens, and/mcpaccepts it unchanged. - Redirects: redirect URIs are
httpsorhttpon localhost and are matched exactly. A code is single-use and lives ten minutes. The token does not expire unless the client sendsexpires_in(at most a year). - Tests:
- Full dance: a fake client runs it end to end.
rwbearer: callsappsandtell.robearer: reads and is refused writes.- Refusals: the other tests cover single-use codes, PKCE mismatch, expired codes, exact-match redirects, cross-origin refusal and the metadata-document rules.
- Docs:
docs/MCP.mdhas attach steps for Claude and Grok, written from the issue text and not tried against either app.
Left out, deliberately
- Refresh tokens and client secrets: only public clients are supported, and a non-expiring token needs no refresh.
- Redirect after approval: the consent page answers 200 with a "Return to …" link rather than a 302, because the page's
form-action 'self'rule would block a redirect to another site. - Metadata document fetch: it is https only, a named host, no redirects, 16 KB and 3 seconds. It does not resolve DNS first, so a public name pointing at a private address is not blocked.
- Registration limits: registration is capped at 5000 clients and has no per-IP limit.
To try it: run the forge, curl -i -X POST $FORGE/mcp and follow the resource_metadata hint. In the Claude app, add a custom connector with https://<forge>/mcp.
🤖 Generated with Claude Code
The forge now has a minimal OAuth server, so the Claude app and Grok connectors can attach to
/mcpand are handed an ordinaryroorrwforge token. The newtest/oauth.test.tsand the existingtest/mcp.test.tspass.tsccould not run here (nonode_modules, so no Bun types), so it is unchecked.test/migrate.test.tsfails the same way with my changes stashed. I did not run the fullforge.jsoncheck; I only addedoauthto its shard list.What changed
/.well-known/oauth-protected-resourceand/.well-known/oauth-authorization-serverare served./mcpnow carriesresource_metadata="<origin>/.well-known/oauth-protected-resource".POST /oauth/register(RFC 7591) stores the client id, name and redirect URIs. Anhttps://client id is also accepted as a client metadata document.GET/POST /oauth/authorizeneeds a browser session; a bearer token is sent to sign-in.ro) or Act (rw).adminis never offered.POST /oauth/tokentakesauthorization_codewith PKCE S256 and mints a normaltokenrow viacreateToken, so it shows up and can be revoked under Settings → Access tokens.expires_in(at most a year).httpsorhttpon localhost. The discovery, register and token endpoints answer CORS preflight.src/core/oauth.ts,src/http/oauth.ts,test/oauth.test.ts.oauth_client,oauth_code), the 401 insrc/http/mcp.ts, route wiring insrc/http/server.ts, anddocs/MCP.md.rwbearer callsappsandtell.robearer reads and is refused writes.expires_in, exact-match redirects, cross-origin refusal, HTML escaping and the metadata document rules.docs/MCP.mdhas attach steps for Claude and Grok. I wrote those from the issue text and did not try them against either app.Left out, deliberately
form-action 'self', which browsers also apply to a redirect after a form POST. So the consent page answers 200 with a "Return to …" link rather than a 302.To try it Run the forge, then
curl -i -X POST $FORGE/mcpand follow theresource_metadatahint. In the Claude app, add a custom connector withhttps://<forge>/mcp.🤖 Generated with Claude Code
Closes #384