← ClaudeAtlas

nfs-add-mcplisted

Add an MCP (Model Context Protocol) entry point to an existing project scaffolded with nextjs-fullstack-starter. Use when the user wants AI clients (Claude Desktop, Cursor) to query the project's data over OAuth, mentions MCP, wants to expose tools to AI, or invokes /nfs-add-mcp. Wires up /api/mcp/route.ts inside an (mcp) route group, the MCP plugin in Better Auth (the project's OAuth provider), the .well-known OAuth discovery endpoints, a tool registry at src/server/mcp/registry.ts, one example tool, and the migration for the three OAuth tables. Requires Better Auth to be wired — if not, prompts to run /nfs-add-auth first.
juncoding/nextjs-fullstack-starter · ★ 0 · API & Backend · score 70
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