Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4a00c8d
feat: migrate to the MCP Toolkit 1.0 preview
HugoRCD Oct 28, 2026
d328596
test: remove MCP preview verification files
HugoRCD Nov 10, 2026
9edf9df
feat: adopt runtime MCP auth and latest preview
HugoRCD Nov 10, 2026
805e9c8
refactor: simplify MCP configuration and metadata
HugoRCD Nov 10, 2026
dfcb0ff
refactor: colocate MCP server configuration
HugoRCD Nov 10, 2026
03262c0
chore(deps): update mcp-toolkit preview to 987571d
HugoRCD Nov 25, 2026
9f26ae6
feat(mcp): sign in to the admin MCP with GitHub OAuth
HugoRCD Nov 25, 2026
55980e5
feat(nuxi): reach the admin MCP through Vercel Connect
HugoRCD Nov 25, 2026
90285fe
fix(mcp): rename admin MCP OAuth grants table
HugoRCD Nov 25, 2026
043865a
feat(mcp): accept client ID metadata documents in the admin MCP OAuth…
HugoRCD Nov 25, 2026
36d9f50
feat(nuxi): run the admin MCP connection in production only
HugoRCD Nov 25, 2026
1043b17
feat(nuxi): reach the production admin MCP from every environment
HugoRCD Nov 25, 2026
8f808dd
chore(deps): update mcp-toolkit preview to 947973a
HugoRCD Nov 25, 2026
605ed4b
chore: merge main into feat/mcp-toolkit-beta
HugoRCD Nov 25, 2026
502f473
chore: merge main into feat/mcp-toolkit-beta
HugoRCD Nov 27, 2026
f25303e
feat(mcp): run the admin MCP OAuth server on Better Auth
HugoRCD Nov 27, 2026
eef0142
fix(mcp): accept CIMD clients that list a pathless custom-scheme redi…
HugoRCD Nov 27, 2026
4c47fff
fix(mcp): redirect browsers from the OAuth authorize endpoint on Vercel
HugoRCD Nov 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ NUXT_NEWSLETTER_SECRET=
# Team / production only — not needed for local contributions
# ============================================================================

# Bearer token for /mcp/admin — web service (handler) + eve service (admin-mcp)
# Bearer token accepted by the eve service's workflow trigger endpoints (besides
# INTERNAL_API_SECRET). It no longer opens /mcp/admin: people and the Nuxi agent
# sign in with GitHub through OAuth there (needs NUXT_APP_SECRET).
NUXT_MCP_ADMIN_TOKEN=

# Google Search Console for the admin MCP `search-console-*` tools: a Google
Expand Down
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,28 @@ To regenerate the image, delete the generated one in `public/assets/templates`.
Build the application for production:

```bash
pnpm generate
pnpm build
```

### MCP Toolkit preview

The toolkit dependency is pinned to [the 1.0 preview from `947973a`](https://github.com/nuxt-modules/mcp-toolkit/pull/423), the tip of the beta stack. Its matching Nitro runtime preview is pinned by the package itself. This branch tests that preview before switching to a published beta.

```bash
pnpm install --frozen-lockfile
pnpm dev
```

The public server card at `/.well-known/mcp/server-card.json` contains only the public catalog. Admin tools and prompts live separately in `server/mcp-admin` and are discovered by the `admin` server configured in `nuxt.config.ts`. Each server keeps its metadata and instructions in its own `index.ts`. The admin index also defines authentication.

### Admin MCP OAuth

People connect to `/mcp/admin` with their GitHub login. Better Auth's OAuth provider (`mcp()`, `cimd()` and `jwt()` in `server/utils/auth.ts`) is the authorization server, with nuxt.com as its issuer. The toolkit's Better Auth adapter verifies its tokens on `/mcp/admin`. An MCP client discovers the server from the `401` challenge, registers itself, and sends you to `/api/auth/oauth2/authorize`. Signed out, you go through `/login` first. Signed in, you approve the client on `/oauth/authorize`, and only admins can approve. The client then exchanges the code with PKCE and gets a 15-minute access token for `/mcp/admin`. It also gets a rotating 30-day refresh token when it asks for `offline_access`, which the `401` challenge lists. Every request re-checks that you're still an admin. Deleting a consent (`/api/auth/oauth2/delete-consent`) also deletes that client's refresh tokens.

Tools and prompts declare `scopes`: `admin:chats` for chat transcripts and votes, `admin:templates` for template checks, `admin:analytics` for everything else. Clients, consents and tokens live in the `auth_oauth_*` tables. The signing keys live in `auth_jwks`, encrypted with a secret derived from `NUXT_APP_SECRET`, which must be set. MCP clients either register dynamically or use an HTTPS client ID metadata document (CIMD), which may authenticate with `private_key_jwt`. The Nuxi agent signs in the same way through Vercel Connect, always against `https://nuxt.com/mcp/admin` (also from local dev, with a Vercel OIDC token from `vercel env pull`): the `nuxt.com/nuxi` connector is created on first use, and an admin installs it once from the Connect dashboard and approves it on nuxt.com's consent page; the grant then follows that admin's access. Locally, run `pnpm dev` and connect a client to `http://localhost:3000/mcp/admin`; set `NUXT_ADMIN_GITHUB_LOGINS` to your login.

Public tools and resources use native Nitro cached functions with their existing 10-minute, 30-minute or 1-hour lifetimes. Cache keys include the request origin and parsed arguments. No MCP client credentials are needed for the public endpoint.

### Running Evals for the MCP Server

To run the evals for the MCP server, follow these steps:
Expand Down
12 changes: 6 additions & 6 deletions app/components/AdminMcpInstall.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ const { copy: copyJson, copied: jsonCopied } = useClipboard()
</div>

<div class="space-y-1.5">
<label class="text-xs font-medium text-muted uppercase tracking-wide">Bearer token</label>
<UInputCopy :value="data.token" size="lg" :tracked="false" />
<label class="text-xs font-medium text-muted uppercase tracking-wide">Claude Code</label>
<UInputCopy :value="data.claudeCode" size="lg" :tracked="false" />
</div>

<div class="space-y-1.5">
Expand All @@ -108,11 +108,11 @@ const { copy: copyJson, copied: jsonCopied } = useClipboard()
</div>

<UAlert
color="warning"
color="neutral"
variant="subtle"
icon="i-lucide-shield-alert"
title="Keep this token private"
description="Anyone with this token has full read access to feedback and agent data. Do not share it or commit it to a public repository."
icon="i-simple-icons-github"
title="Sign in with GitHub when your client asks"
description="No token to copy: the client opens nuxt.com, you approve access with your admin GitHub account, and it refreshes access on its own. Access ends within an hour of leaving the Nuxt admins."
/>
</div>
</UCard>
Expand Down
298 changes: 298 additions & 0 deletions app/pages/oauth/authorize.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,298 @@
<script setup lang="ts">
import { AnimatePresence, motion } from 'motion-v'
import { MCP_OAUTH_SCOPES, MCP_OAUTH_SCOPE_TOOLS } from '#shared/utils/mcp-admin'
import type { McpOAuthScope } from '#shared/utils/mcp-admin'

// Better Auth's OAuth provider (`mcp()` in `server/utils/auth.ts`) sends people here with the client's
// signed authorization request in the query, once they are signed in.
definePageMeta({
layout: false,
colorMode: 'dark'
})

useSeoMeta({
title: 'Authorize MCP client',
robots: 'noindex, nofollow'
})

const route = useRoute()
const { user, ready } = useUserSession()

/** What each scope lets the client do, in plain words. */
const CAN: Record<McpOAuthScope, string> = {
'admin:analytics': 'Read docs feedback, Nuxi usage, Search Console and Core Web Vitals',
'admin:chats': 'Read Nuxi chats that were shared with admins or made public',
'admin:templates': 'See template check results and start new checks on Vercel Sandbox'
}

/** Limits that hold whatever scopes are granted. */
const CANNOT = [
'Read private chats',
'Change site content or anyone\'s account',
'Access your GitHub account'
]

const request = computed(() => new URL(route.fullPath, 'http://localhost').searchParams)
const clientId = computed(() => request.value.get('client_id'))

const { data: client, error } = await useFetch<{ client_name?: string, logo_uri?: string }>('/api/auth/oauth2/public-client', {
query: { client_id: clientId },
server: false,
immediate: Boolean(clientId.value)
})

const errorMessage = computed(() => {
const body = (error.value as { data?: { error_description?: string, message?: string } } | undefined)?.data
return body?.error_description || body?.message || error.value?.message
})

// Without a session, Better Auth's `/login` resumes the request after GitHub sign-in.
watch(ready, (isReady) => {
if (isReady && !user.value) navigateTo({ path: '/login', query: route.query })
}, { immediate: true })

const data = computed(() => {
if (!clientId.value || !request.value.get('sig')) return { status: 'error' as const, error: 'This authorization request is incomplete. Start again from your MCP client.' }
if (!ready.value || !user.value || !client.value) return null
if (user.value.role !== 'admin') return { status: 'error' as const, error: 'The admin MCP server is only available to Nuxt admins.' }
const redirect = new URL(request.value.get('redirect_uri')!)
const requested = (request.value.get('scope') ?? '').split(' ')
const name = client.value.client_name || 'This app'
return {
status: 'consent' as const,
client: {
name,
logo: client.value.logo_uri,
initials: name.split(/\s+/).map(word => word[0]).join('').slice(0, 2).toUpperCase(),
redirectHost: redirect.host || redirect.protocol
},
user: { username: user.value.username, avatar: user.value.avatar },
// `offline_access` only lets the client renew its access, so it's explained in the footnote, not listed.
scopes: requested.filter((scope): scope is McpOAuthScope => scope in MCP_OAUTH_SCOPES)
.map(scope => ({ scope, text: CAN[scope], tools: MCP_OAUTH_SCOPE_TOOLS[scope] })),
staysConnected: requested.includes('offline_access')
}
})

const openScope = ref<McpOAuthScope | null>(null)
const submitting = ref<'approve' | 'deny' | null>(null)
const approved = ref(false)
const submitError = ref<string | null>(null)

async function decide(approve: boolean) {
submitting.value = approve ? 'approve' : 'deny'
submitError.value = null
try {
const { url } = await $fetch<{ url: string }>('/api/auth/oauth2/consent', {
method: 'POST',
body: { accept: approve, oauth_query: request.value.toString() }
})
if (approve) {
// Let the connection mark settle before leaving the page.
approved.value = true
await new Promise(resolve => setTimeout(resolve, 600))
}
window.location.href = url
} catch (err) {
const body = (err as { data?: { message?: string, error_description?: string } }).data
submitError.value = body?.error_description || body?.message || 'Could not complete the authorization.'
submitting.value = null
}
}

const ease = [0.22, 1, 0.36, 1] as const
</script>

<template>
<div class="min-h-dvh bg-default flex flex-col items-center justify-center px-5 py-12 antialiased">
<div v-if="error || data?.status === 'error'" class="w-full max-w-sm flex flex-col gap-3 text-center">
<h1 class="text-lg font-semibold text-highlighted">
{{ error ? 'Something went wrong' : 'Cannot authorize this app' }}
</h1>
<p class="text-sm/6 text-muted">
{{ error ? errorMessage : data?.status === 'error' && data.error }}
</p>
<UButton
v-if="!error && clientId && user"
label="Return to the app"
color="neutral"
variant="outline"
block
class="mt-3"
:loading="submitting === 'deny'"
@click="decide(false)"
/>
</div>

<motion.div
v-else-if="data?.status === 'consent'"
:initial="{ opacity: 0, y: 8 }"
:animate="{ opacity: 1, y: 0 }"
:transition="{ duration: 0.5, ease }"
class="w-full max-w-[400px] md:max-w-[52rem] grid gap-8 md:grid-cols-[18rem_minmax(0,1fr)] md:grid-rows-[auto_1fr] md:gap-x-14 md:gap-y-0"
>
<div class="flex flex-col items-center text-center md:items-start md:text-left md:col-start-1 md:row-start-1">
<div class="flex items-center" aria-hidden="true">
<UAvatar :src="data.client.logo" :text="data.client.initials" size="xl" class="rounded-xl ring ring-default bg-elevated" />
<div class="relative w-16 h-px mx-1 bg-accented overflow-hidden">
<span v-if="!approved" class="connector-pulse absolute inset-y-0 w-6 bg-linear-to-r from-transparent via-primary to-transparent" />
<motion.span
v-else
:initial="{ scaleX: 0 }"
:animate="{ scaleX: 1 }"
:transition="{ duration: 0.35, ease }"
class="absolute inset-0 bg-primary origin-left"
/>
</div>
<div class="relative">
<div class="size-12 rounded-xl ring ring-default bg-elevated flex items-center justify-center">
<UIcon name="i-custom-nuxt" class="size-6 text-primary" />
</div>
<AnimatePresence>
<motion.div
v-if="approved"
:initial="{ scale: 0 }"
:animate="{ scale: 1 }"
:transition="{ type: 'spring', stiffness: 500, damping: 22, delay: 0.25 }"
class="absolute -right-1.5 -bottom-1.5 size-5 rounded-full bg-primary ring-2 ring-(--ui-bg) flex items-center justify-center"
>
<UIcon name="i-lucide-check" class="size-3 text-inverted" />
</motion.div>
</AnimatePresence>
</div>
</div>

<h1 class="mt-6 text-xl md:text-2xl font-semibold text-highlighted text-balance tracking-[-0.01em]">
{{ data.client.name }} wants to access the Nuxt admin MCP
</h1>
<p class="mt-2 flex items-center gap-1.5 text-sm text-muted">
<UAvatar :src="data.user.avatar" :alt="data.user.username" size="3xs" />
as <span class="text-highlighted font-medium">@{{ data.user.username }}</span>
</p>
</div>

<div class="w-full md:col-start-2 md:row-start-1 md:row-span-2">
<div class="w-full rounded-xl ring ring-default bg-elevated/40 divide-y divide-default">
<div class="p-4">
<p class="text-xs font-medium text-muted">
It will be able to
</p>
<ul role="list" class="mt-2.5 flex flex-col gap-1">
<motion.li
v-for="(item, i) in data.scopes"
:key="item.scope"
:initial="{ opacity: 0, y: 4 }"
:animate="{ opacity: 1, y: 0 }"
:transition="{ duration: 0.35, delay: 0.15 + i * 0.06, ease }"
>
<button
type="button"
class="group w-full flex items-start gap-2.5 rounded-md -mx-1.5 px-1.5 py-1 text-left hover:bg-elevated focus-visible:outline-2 focus-visible:outline-primary"
:aria-expanded="openScope === item.scope"
@click="openScope = openScope === item.scope ? null : item.scope"
>
<UIcon name="i-lucide-check" class="size-4 mt-0.5 shrink-0 text-primary" />
<span class="flex-1 min-w-0 text-sm/5 text-default">{{ item.text }}</span>
<UIcon
name="i-lucide-chevron-down"
class="size-3.5 mt-1 shrink-0 text-dimmed transition-transform duration-200"
:class="openScope === item.scope && 'rotate-180'"
/>
</button>
<AnimatePresence>
<motion.div
v-if="openScope === item.scope"
:initial="{ height: 0, opacity: 0 }"
:animate="{ height: 'auto', opacity: 1 }"
:exit="{ height: 0, opacity: 0 }"
:transition="{ duration: 0.2, ease }"
class="overflow-hidden"
>
<p class="pl-6.5 pt-1 pb-1.5 font-mono text-[0.6875rem]/5 text-dimmed">
<template v-for="(tool, t) in item.tools" :key="tool">
<span v-if="t" aria-hidden="true"> · </span><span class="whitespace-nowrap">{{ tool }}</span>
</template>
</p>
</motion.div>
</AnimatePresence>
</motion.li>
</ul>
</div>

<div class="p-4">
<p class="text-xs font-medium text-muted">
It won't be able to
</p>
<ul role="list" class="mt-2.5 flex flex-col gap-2">
<li v-for="item in CANNOT" :key="item" class="flex items-start gap-2.5 text-sm/5 text-muted">
<UIcon name="i-lucide-x" class="size-4 mt-0.5 shrink-0 text-dimmed" />
{{ item }}
</li>
</ul>
</div>
</div>

<UAlert
v-if="submitError"
class="mt-4"
color="error"
variant="subtle"
icon="i-lucide-triangle-alert"
:title="submitError"
/>
</div>

<div class="w-full flex flex-col md:col-start-1 md:row-start-2 md:justify-end md:pt-8">
<div class="flex flex-col gap-1.5 md:flex-row md:gap-2">
<UButton
:label="approved ? 'Connected' : 'Allow access'"
:icon="approved ? 'i-lucide-check' : undefined"
color="primary"
size="lg"
block
class="md:flex-1"
:loading="submitting === 'approve' && !approved"
:disabled="submitting !== null"
@click="decide(true)"
/>
<UButton
label="Cancel"
color="neutral"
variant="ghost"
size="lg"
block
class="md:w-auto"
:loading="submitting === 'deny'"
:disabled="submitting !== null"
@click="decide(false)"
/>
</div>

<p class="mt-5 text-xs/5 text-dimmed text-center text-pretty md:order-first md:mt-0 md:mb-5 md:text-left">
You'll return to <span class="font-mono text-muted">{{ data.client.redirectHost }}</span>.
{{ data.staysConnected ? 'It stays connected while you use it, until 30 days without use or until you leave the Nuxt admins.' : 'Access ends when you leave the Nuxt admins.' }}
</p>
</div>
</motion.div>

<div v-else class="flex items-center gap-2 text-sm text-muted">
<UIcon name="i-lucide-loader-2" class="size-4 animate-spin" />
Loading…
</div>
</div>
</template>

<style scoped>
.connector-pulse {
animation: connector 1.8s ease-in-out infinite;
}

@keyframes connector {
from { transform: translateX(-24px); }
to { transform: translateX(64px); }
}

@media (prefers-reduced-motion: reduce) {
.connector-pulse { animation: none; opacity: 0; }
}
</style>
Loading
Loading