Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Production bundleComparing Initial page load
All client assets
Largest module increases
|
75977d0 to
805e9c8
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Bundle sizeClient 1.28 MB
And 331 more routes. Largest changes in the client
Largest changes in the server
And 89 more packages or files. Brotli sizes. Changes under 100 B are left out of the tables. Initial page load counts the JavaScript and CSS a route loads before it renders. Measured by nuxt-bundle-analyzer for |
Replace the hand-written OAuth server with Better Auth's oauth-provider and CIMD plugins, verify tokens with the toolkit's betterAuth adapter, and redesign the consent page. Amp-Thread-ID: https://ampcode.com/threads/T-01a21283-5633-77e4-b370-12bff392a0df
Written by an AI agent on behalf of @HugoRCD, who shaped the solution. @HugoRCD has reviewed it.
The admin MCP at
/mcp/adminused to open with one sharedNUXT_MCP_ADMIN_TOKEN. With this PR, each admin signs in with GitHub and approves the MCP client on a nuxt.com consent page, and the client gets a 15-minute token bound to/mcp/adminand to the scopes the admin approved. nuxt.com's existing Better Auth setup is the authorization server, through itsoauth-provider(mcp()),jwt()andcimd()plugins. The hand-written OAuth server this branch used to carry is gone: 621 lines of server OAuth code became 99. The MCP side runs on the MCP Toolkit 1.0 preview (https://pkg.pr.new/@nuxtjs/mcp-toolkit@947973a) and itsbetterAuth()adapter. Clients either register on the fly or identify themselves with a Client ID Metadata Document, which is how Nuxi signs in through Vercel Connect withprivate_key_jwt.To try it, add the branch preview as an MCP server and approve the client when it opens the consent page. Use the branch URL: the resource is pinned to it, so a commit URL fails the resource check.
Or run it locally:
The server file only declares where tokens come from and who may use them:
Every admin tool and prompt declares its scope:
admin:chatsfor chat transcripts and votes,admin:templatesfor reading and starting template checks (starting one spends Vercel Sandbox time),admin:analyticsfor everything else.The consent page
It says in plain words what the client will and won't be able to do. Each row opens to show the exact tool names.
offline_accessisn't listed as a permission; the note under the title says how long the client stays connected. Captured on a local dev server as a demo admin, with a dynamically registered client named "Claude Code":After Allow, the line between the two marks fills in and a check lands on the Nuxt mark before the redirect:
Someone who isn't a Nuxt admin can sign in but can't approve. The server refuses the consent with 403
Admin access required, so this page is only the friendly version of that refusal:Before and after
Production today answers a request without a token with a bare 401 and has no discovery metadata:
With this branch, the 401 points MCP clients at the protected-resource metadata, and from there at nuxt.com as the authorization server:
The whole flow for a dynamically registered client, run with curl against a local dev server. The authorization code is redacted, and the token lines print only non-secret fields:
The same run as a non-admin stops at the consent step:
A token approved for
admin:analyticsonly can call analytics tools but not template checks:The refusal came back as JSON-RPC error
-32003inside a 200 on both the2025-11-25and2026-07-28protocol versions, not as an HTTP 403 withinsufficient_scope.On the Vercel preview
Two things stopped Raycast's first sign-in against the branch preview.
Raycast identifies itself with a Client ID Metadata Document whose
redirect_urisincluderaycast://mcp-oauth-callback. Better Auth's CIMD plugin rejects a custom-scheme URI without a path, and with it the whole document, so Raycast couldn't sign in with any of its redirects. nuxt.com now wraps the metadata fetch and drops only pathless custom-scheme URIs before Better Auth validates the document; the remaining redirects still go through Better Auth's own checks.The authorize endpoint then answered the browser with Better Auth's
{"redirect":true,"url":…}JSON instead of a 302, so Raycast opened a page of JSON and stopped there. Local dev, the node-server build and the Vercel build output all return a 302. On the preview, the Vercel Toolbar proxy causes it: the same request withx-vercel-skip-toolbar: 1gets the 302 back. Which request header the proxy changes wasn't found. Rather than turn the toolbar off, the auth handler now turns that JSON answer into a 302 for GET/api/auth/oauth2/authorize, keeping Better Auth's headers and cookies.The same signed-out browser request (
Accept: text/html, Raycast'sclient_id, its loopback redirect) sent to the deployment of each commit, with query strings cut from thelocationlines:f25303e5refuses Raycast's metadata document,eef01421accepts it but answers with JSON, and4c47fff3redirects to sign-in. With that deployed, @HugoRCD added the branch preview to Raycast, signed in, approved it on the consent page, and Raycast connected. Raycast had cached discovery from the branch's earlier hand-written server, so the server had to be removed and added again in Raycast first.Things a reviewer should know
offline_access, rotate on every use, and expire after 30 days without use. Removing a consent through/oauth2/delete-consentalso deletes that client's refresh tokens; Better Auth alone only deletes the consent.authorizechecks the role on every MCP request, so someone who leaves the admins loses access on their next call, not at the next refresh.NUXT_MCP_ADMIN_TOKENno longer opens/mcp/admin; the eve workflow trigger endpoints still accept it.appSecret. Better Auth encrypts the JWKS private key with a secret derived from Nuxt'sappSecret. IfNUXT_APP_SECRETchanges, the token endpoint returns 500 until theauth_jwksrow is deleted, and every issued token stops verifying. Locally, the generated dev secret in.nuxt/app-secretis regenerated when.nuxtis cleared, which hit me once while testing./tokenis off, because session JWTs would share the access tokens' signing key. The client-management/oauth2/*routes are off too: clients only register themselves.0016_admin_mcp_oauth_grantsmigration is gone, and0017_admin_mcp_oauthadds Better Auth's OAuth and JWKS tables. Earlier preview deploys of this branch createdadmin_mcp_oauth_grantsin the shared Preview database; nothing uses that table anymore.main, main's Better Auth migration and the old grants migration both claimed 0016, so the merge commit takes main's migrations and lockfile, and only the next commit is consistent. Don't bisect into the merge commit alone.https://nuxt.com/mcp/admin, now requestingoffline_accessso Connect can refresh. Local dev needs a Vercel OIDC token fromvercel env pull. Local MCP clients can still use a local/mcp/admin.The curl flows above were run by hand, on a local dev server and against the preview deployments; CI doesn't cover them. The CIMD path was also checked locally during the rewrite, with an HTTPS metadata document that uses
private_key_jwt: the token endpoint accepted assertions addressed to either the issuer or the token endpoint. That output wasn't kept, so it isn't shown here. Nobody has tested real Vercel Connect yet, because it needs production to serve this OAuth admin MCP. Raycast is the only MCP client tried against a deployed server, by @HugoRCD on the branch preview; Claude Code, Cursor and VS Code haven't been. Reduced-motion handling for the consent page's entrance animation isn't checked. After this reaches production, an admin installsnuxt.com/nuxionce in the Vercel Connect dashboard and approves it on the consent page.ELI5
The team's private AI tools on nuxt.com used to open with one shared password. Now each person signs in with GitHub, sees exactly what an app will and won't be able to do, and approves it. The app gets a pass that only opens those tools, stops working if the person leaves the team, and runs out if the app goes unused for a month.