nfs-add-mcplisted
Install: claude install-skill juncoding/nextjs-fullstack-starter
# Add an MCP route to an existing scaffold
Use when a project from `nextjs-fullstack-starter` needs an MCP entry point so AI clients can call services over OAuth.
## Pre-flight checks
1. **Refuse if Better Auth isn't wired.** MCP uses Better Auth's `mcp` plugin as its OAuth provider. If `src/server/auth/index.ts` doesn't exist, tell the user to run `/nfs-add-auth` first.
2. **Refuse if `src/server/mcp/` already exists.** Suggest auditing what's there instead.
3. **Refuse if `src/app/(mcp)/mcp/route.ts` already exists.**
## Plan
1. Update `src/server/auth/index.ts` to add the `mcp` plugin alongside `nextCookies`.
2. Add `src/app/(mcp)/mcp/route.ts` — the POST handler that consumes the MCP transport, wrapped with `withMcpAuth`.
3. Add `src/app/.well-known/oauth-authorization-server/route.ts` + `oauth-protected-resource/route.ts` for OAuth discovery.
4. Add `src/server/mcp/registry.ts` — central tool registry.
5. Add `src/server/mcp/tools/_example.ts` — one example tool that wraps the example service.
6. Add the three Better Auth OAuth tables (`OauthApplication`, `OauthAccessToken`, `OauthConsent`) to `schema.prisma`.
7. Run `pnpm prisma migrate dev --name add_mcp_oauth`.
8. Update `CLAUDE.md`.
## File templates
### `src/server/auth/index.ts` (updated)
```ts
import "server-only";
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { nextCookies } from "better-auth/next-js";
import { mcp } from "better-auth/plugins