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 #404
The Claude app and Grok can now attach to /mcp through OAuth. The person signs in with their forge session and picks Watch (ro) or Watch and act (rw), a name, and how long access lasts.
stopped closed without shipping deploy 66b37d0
Sign in to join this conversation.
new above
offline
The Claude app and Grok can now attach to
/mcpthrough OAuth. The person signs in with their forge session and picks Watch (ro) or Watch and act (rw), a name, and how long access lasts. What comes back is the sametokenrow that Settings → Access tokens mints, lists and revokes, and/mcpaccepts it with no changes on its side./.well-known/oauth-protected-resource(also served at/mcpunder that path) and/.well-known/oauth-authorization-server. An unauthenticated/mcpnow answers 401 withWWW-Authenticate: Bearer realm="forge", resource_metadata="…".src/core/oauth.ts,src/http/oauth.ts): RFC 7591 registration for public clients only, keeping the name and up to 5 redirect URIs. A client metadata document also works: aclient_idthat is an HTTPS URL is fetched with no redirects, a 5 s limit and a 16 KB cap. It must be on a named public host and must name the sameclient_id./oauth/authorizeneeds a session or edge sign-in, never a token, and the form post must come from the forge itself. The consent page adds only the registered redirect's origin to itsform-action, so the browser lets it send the person back./oauth/tokenaccepts PKCE S256 only. A code lasts two minutes and the first attempt to redeem it uses it up, whether or not that attempt succeeds. It must also come with the client and redirect it was issued for. If the person picked a lifetime, it becomesexpiresAtand the response carriesexpires_in.oauth_clientandoauth_code. Unused codes are deleted on the existing worker tick.createTokeninactions/users.tstakes an optional expiry, andvia: "oauth"is recorded on thetoken.createdevent.Not done:
localhostare refused, but a public name that resolves to a private address would still be fetched.docs/MCP.mdexplains how to attach from Claude (Settings → Connectors → Add custom connector, URLhttps://<forge>/mcp) and from Grok (grok.com/connectors → Custom).test/oauth.test.tsis new and added to theforge.jsoncheck, which passes in full. It covers the full PKCE flow with a fake client, using the RFC 7636 example verifier. It checks that anrwbearer minted this way callsappsand can act, and that anroone is refused writes. It also covers using a code twice, a wrong verifier or client, exact redirect matching, consent without a person at a browser, escaping on the consent page, and metadata documents.To try it on the preview:
curl -i -XPOST <preview>/mcpshows the hint. Adding the preview's/mcpas a custom connector in Claude should then go through consent and add a token to Settings → Access tokens.🤖 Generated with Claude Code
Closes #384