Skip to content

feat: migrate to the MCP Toolkit 1.0 preview - #2567

Draft
HugoRCD wants to merge 18 commits into
mainfrom
feat/mcp-toolkit-beta
Draft

HugoRCD wants to merge 18 commits into
mainfrom
feat/mcp-toolkit-beta

Conversation

@HugoRCD

@HugoRCD HugoRCD commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Written by an AI agent on behalf of @HugoRCD, who shaped the solution. @HugoRCD has reviewed it.

The admin MCP at /mcp/admin used to open with one shared NUXT_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/admin and to the scopes the admin approved. nuxt.com's existing Better Auth setup is the authorization server, through its oauth-provider (mcp()), jwt() and cimd() 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 its betterAuth() 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 with private_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.

claude mcp add --transport http nuxt-admin https://nuxt-git-feat-mcp-toolkit-beta-nuxt-js.vercel.app/mcp/admin

Or run it locally:

NUXT_ADMIN_GITHUB_LOGINS=<your-github-login> pnpm dev
claude mcp add --transport http nuxt-admin http://localhost:3000/mcp/admin

The server file only declares where tokens come from and who may use them:

export default defineMcpServer({
  name: 'admin',
  // ...
  oauth: betterAuth({
    resource: mcpAdminResource(),
    issuer: mcpOAuthIssuer(),
    jwks: `${mcpOAuthIssuer()}/api/auth/jwks`,
    scopesSupported: ['offline_access', ...MCP_OAUTH_SCOPE_LIST]
  }),
  // The role is set at sign-in, and an admin can leave the team after approving a client.
  authorize: ({ sub }) => isMcpAdmin(sub)
})

Every admin tool and prompt declares its scope: admin:chats for chat transcripts and votes, admin:templates for reading and starting template checks (starting one spends Vercel Sandbox time), admin:analytics for 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_access isn'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":

Consent page, desktop

After Allow, the line between the two marks fills in and a check lands on the Nuxt mark before the redirect:

Consent page right after Allow

Consent page, mobile

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:

Consent page for a non-admin

Before and after

Production today answers a request without a token with a bare 401 and has no discovery metadata:

$ curl -si -X POST https://nuxt.com/mcp/admin (no token)
HTTP/2 401 
$ curl -s -o /dev/null -w "%{http_code}" https://nuxt.com/.well-known/oauth-protected-resource/mcp/admin
404

With this branch, the 401 points MCP clients at the protected-resource metadata, and from there at nuxt.com as the authorization server:

$ curl -si -X POST http://localhost:3000/mcp/admin (no token)
HTTP/1.1 401 Unauthorized
www-authenticate: Bearer realm="mcp", resource_metadata="http://localhost:3000/.well-known/oauth-protected-resource/mcp/admin", scope="offline_access admin:analytics admin:chats admin:templates"
$ curl -s http://localhost:3000/.well-known/oauth-protected-resource/mcp/admin
{
  "resource": "http://localhost:3000/mcp/admin",
  "authorization_servers": [
    "http://localhost:3000"
  ],
  "bearer_methods_supported": [
    "header"
  ],
  "scopes_supported": [
    "offline_access",
    "admin:analytics",
    "admin:chats",
    "admin:templates"
  ]
}

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:

$ oauth-e2e.sh oauth-admin
== register (DCR)
{"client_id":"OgVKEWingidgNdFJYXYdFYlcdsidWeuJ","scope":"offline_access admin:analytics admin:chats admin:templates","token_endpoint_auth_method":"none","client_secret":null}
== consent page
200
== accept consent
{"redirect":true,"url":"http://127.0.0.1:33418/callback?code=…&state=st4te&iss=http%3A%2F%2Flocalhost%3A3000"}
== token
{"token_type":"Bearer","expires_in":900,"scope":"offline_access admin:analytics admin:chats admin:templates","has_refresh":true}
{"iss":"http://localhost:3000","aud":"http://localhost:3000/mcp/admin","azp":"OgVKEWingidgNdFJYXYdFYlcdsidWeuJ","scope":"offline_access admin:analytics admin:chats admin:templates","exp_in":900}
== MCP initialize + tools/list
initialize 200
13
== refresh
{"token_type":"Bearer","expires_in":900,"scope":"offline_access admin:analytics admin:chats admin:templates","rotated":true}

The same run as a non-admin stops at the consent step:

$ oauth-e2e.sh not-an-admin
== accept consent
{"message":"Admin access required"}

A token approved for admin:analytics only can call analytics tools but not template checks:

$ token scope
{"scope":"offline_access admin:analytics"}
$ tools/call start-template-checks
{"jsonrpc":"2.0","id":4,"error":{"code":-32003,"message":"The tool \"start-template-checks\" requires admin:templates.","data":{"requiredScopes":["admin:templates"],"missingScopes":["admin:templates"]}}}
→ HTTP 200
$ tools/call feedback-stats
→ HTTP 200

The refusal came back as JSON-RPC error -32003 inside a 200 on both the 2025-11-25 and 2026-07-28 protocol versions, not as an HTTP 403 with insufficient_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_uris include raycast://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 with x-vercel-skip-toolbar: 1 gets 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's client_id, its loopback redirect) sent to the deployment of each commit, with query strings cut from the location lines:

### f25303e5
HTTP 400  content-type: application/json
location: 
body: {"error":"invalid_client","error_description":"redirect_uris must be a non-empty array of absolute HTTP(S) or private-use URIs"}

### eef01421
HTTP 200  content-type: application/json
location: 
body: {"redirect":true,"url":"/login?response_type=code&redirect_uri=http%3A%2F%2F127.0.0.1%3A53253%2Fcallback&scope=offline_access+admin%3Aanalytics&state=st&client_id=https%3A%2F%2Fwww.raycast.com%2F.well

### 4c47fff3
HTTP 302  content-type: text/html
location: https://nuxt-bpg356jo7-nuxt-js.vercel.app/login
body: <!doctype html>
<!-- https://vercel.app -->
<h1>Redirecting (302)</h1>
The document has moved
<a href="/login?response_type=code&client_id=https%253A%252F%252Fwww.raycast.com%252F.well-known%252Foauth

f25303e5 refuses Raycast's metadata document, eef01421 accepts it but answers with JSON, and 4c47fff3 redirects 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

  • Token lifetimes. Access tokens last 15 minutes, because revoking a client can't reach access tokens already issued. Refresh tokens are only issued with offline_access, rotate on every use, and expire after 30 days without use. Removing a consent through /oauth2/delete-consent also deletes that client's refresh tokens; Better Auth alone only deletes the consent.
  • Admin access. Only an admin can accept consent, and authorize checks 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_TOKEN no longer opens /mcp/admin; the eve workflow trigger endpoints still accept it.
  • Signing keys depend on appSecret. Better Auth encrypts the JWKS private key with a secret derived from Nuxt's appSecret. If NUXT_APP_SECRET changes, the token endpoint returns 500 until the auth_jwks row is deleted, and every issued token stops verifying. Locally, the generated dev secret in .nuxt/app-secret is regenerated when .nuxt is cleared, which hit me once while testing.
  • Disabled Better Auth routes. /token is off, because session JWTs would share the access tokens' signing key. The client-management /oauth2/* routes are off too: clients only register themselves.
  • Migrations. The branch's old 0016_admin_mcp_oauth_grants migration is gone, and 0017_admin_mcp_oauth adds Better Auth's OAuth and JWKS tables. Earlier preview deploys of this branch created admin_mcp_oauth_grants in the shared Preview database; nothing uses that table anymore.
  • Merge commit. In the latest merge of 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.
  • Nuxi always uses production. Vercel Connect runs in Vercel's cloud and must reach the server itself, so Nuxi always connects to https://nuxt.com/mcp/admin, now requesting offline_access so Connect can refresh. Local dev needs a Vercel OIDC token from vercel env pull. Local MCP clients can still use a local /mcp/admin.
  • Preview package. The toolkit stays pinned to a pkg.pr.new preview. Switch to the published beta before merging.

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 installs nuxt.com/nuxi once 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.

@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nuxt Ready Ready Preview Nov 27, 2026 5:09pm UTC

Request Review

@nuxt-com-bundle-report

Copy link
Copy Markdown

Production bundle

Comparing ad5aa0cf with 4a00c8d7. Compressed sizes are calculated from the emitted production assets.

Initial page load

Page Base JS (Brotli) PR JS (Brotli) Δ JS Δ CSS Δ files
/ 555.0 KiB 555.0 KiB +9 B (+0.0%) — —
/docs/4.x/getting-started/introduction 613.3 KiB 613.3 KiB +24 B (+0.0%) — —
/modules/ui 545.4 KiB 545.5 KiB +62 B (+0.0%) — —
/updates 450.2 KiB 450.2 KiB +19 B (+0.0%) — —
/blog/v4-6 573.7 KiB 573.7 KiB +19 B (+0.0%) — —
/templates 431.0 KiB 431.0 KiB +16 B (+0.0%) — —

Entry script, modulepreload chunks and stylesheets referenced by the prerendered HTML. Lazy and prefetched chunks are excluded.

All client assets

Metric Base (Brotli) PR (Brotli) Δ Brotli Δ gzip
Client JavaScript 2.20 MiB 2.20 MiB +54 B (+0.0%) -5 B (-0.0%)
Client CSS 34.3 KiB 34.3 KiB — —
Other client assets 339.3 KiB 339.3 KiB -2 B (-0.0%) -1 B (-0.0%)
Total client assets 2.56 MiB 2.56 MiB +52 B (+0.0%) -6 B (-0.0%)

Largest module increases

Module Base (Brotli) PR (Brotli) Δ Brotli
virtual:nuxt-workers.mjs?source=%2Fhome%2Frunner%2Fwork%2Fnuxt.com%2Fnuxt.com%2Fapp%2Fworkers%2Fsearch.ts 0 B 408 B +408 B
/app/pages/nuxters/async-data-chunk-5.js 0 B 237 B +237 B
/app/pages/modules/[slug]/async-data-chunk-8.js 0 B 213 B +213 B
/app/async-data-chunk-25.js 0 B 187 B +187 B
/app/pages/docs/async-data-chunk-6.js 0 B 161 B +161 B
/app/pages/modules/[slug]/async-data-chunk-9.js 0 B 135 B +135 B
/app/pages/blog/async-data-chunk-16.js 0 B 121 B +121 B
/app/pages/async-data-chunk-11.js 0 B 120 B +120 B
/app/pages/enterprise/async-data-chunk-0.js 0 B 118 B +118 B
/app/pages/modules/async-data-chunk-23.js 0 B 118 B +118 B

Module values come from Nuxt’s analyzer and are attribution estimates. This workflow is currently report-only.

Workflow run

@socket-security

socket-security Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​better-auth/​cimd@​1.7.281001007697100
Added@​better-auth/​oauth-provider@​1.7.28881008097100
Added@​better-auth/​mcp@​1.7.281001008397100

View full report

@nuxt-com-bundle-report

nuxt-com-bundle-report Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Bundle size

Explore the comparison →

Client 1.28 MB $\color{red}\textsf{(+3.63 kB, +0.3}\%\textsf{)}$ · Server 9.09 MB $\color{red}\textsf{(+42.4 kB, +0.5}\%\textsf{)}$

Initial page load PR Δ
/oauth/authorize 301.0 kB added
/dashboard/chat/:id() 566.8 kB +402 B (+0.1%)
/admin/analytics 423.9 kB +322 B (+0.1%)
/sponsors 260.1 kB +300 B (+0.1%)
/modules 339.2 kB +298 B (+0.1%)
/design-kit 329.1 kB +291 B (+0.1%)
/enterprise/jobs 259.0 kB +289 B (+0.1%)
/modules/:slug()/:path(.) 340.1 kB +289 B (+0.1%)
/deploy/:slug() 337.1 kB +288 B (+0.1%)
/docs/:slug(.) 386.5 kB +287 B (+0.1%)

And 331 more routes.

Largest changes in the client
Package or file Base PR Δ
app/pages/oauth/authorize.vue n/a 2.11 kB +2.11 kB
[unassigned] 109.2 kB 110.2 kB +1.02 kB (+0.9%)
shared/utils/mcp-admin.ts n/a 257 B +257 B
Largest changes in the server
Package or file Base PR Δ
node_modules/h3-mcp n/a 17.1 kB +17.1 kB
node_modules/@nuxtjs/mcp-toolkit 17.5 kB 2.29 kB −15.2 kB (−86.9%)
node_modules/nitro-mcp-toolkit n/a 9.49 kB +9.49 kB
node_modules/jose n/a 8.47 kB +8.47 kB
node_modules/h3 8.17 kB 14.8 kB +6.65 kB (+81.4%)
[unassigned] 7.81 MB 7.82 MB +4.10 kB (+0.1%)
server/mcp/prompts/admin/seo-opportunities.ts 3.87 kB n/a −3.87 kB (−100.0%)
workflow/workflows.mjs 113.5 kB 117.3 kB +3.80 kB (+3.3%)
server/mcp-admin/prompts/seo-opportunities.ts n/a 3.44 kB +3.44 kB
workflow/steps.mjs 91.6 kB 94.7 kB +3.09 kB (+3.4%)

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 4c47fff.

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

This branch was successfully deployed

1 active deployment
Preview — 4c47fff3 Deployed Nov 27, 2026 by vercel[bot] via lighthouse #10479
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant