LABSCO SUMMARY
Start here if you are building a server other people log into.
The value is in what is already done: OAuth client registration, consent and token storage are where a hand-rolled MCP server usually goes wrong, and here they are working against a real database. The constraint to accept up front is Vercel — SSE support comes from the Vercel adapter, so hosting elsewhere means giving up the transport Claude needs.
What it is
A template rather than a product: a Next.js application that is a complete OAuth 2.1 MCP server, meant to be forked. It handles the parts that are tedious to get right — dynamic client registration, the consent screen, token exchange, and persisting clients and tokens — and leaves one file for you to define tools in. Forked from run-llama/mcp-nextjs, with Drizzle in place of Prisma and better-auth in place of next-auth.
What you get
- Both transports through
@vercel/mcp-adapter— Streamable HTTP at/mcp/mcpand SSE at/mcp/sse, which is what Claude Desktop and Claude.ai still need - OAuth client registration and token exchange under
/src/app/api/oauth/*, with a consent screen at/src/app/oauth/authorize/page.tsx - User authentication separate from the OAuth server — wired to Google, GitHub and Discord, and swappable without breaking the OAuth flow
- A Drizzle schema covering users, sessions, accounts, registered OAuth clients, issued access tokens and authorization codes
- One place to write your own server:
/src/mcp/[transport]/route.tsis where tools and resources go
Requirements
A PostgreSQL database — DATABASE_URL is where sessions and tokens live, and OAuth does not work without it. Also BETTER_AUTH_SECRET, provider credentials such as GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET, and NEXT_PUBLIC_BASE_URL. REDIS_URL is only needed if you want SSE, which means it is needed if you want Claude Desktop or Claude.ai to connect. Run pnpm install, pnpm run db:generate, pnpm run db:push the first time, then pnpm run dev. Deployment is Vercel-only, because the SSE support comes from @vercel/mcp-adapter. Note that Claude will not accept a localhost URL.
Setup effort
Build from source — git clone https://github.com/DTeam-Top/mcp-oauth.git
USE CASES
01
Standing up an MCP server real users authenticate to
Fork it, write your tools in the transport route, and inherit a working OAuth flow instead of implementing one.
02
Supporting Claude and Cursor from one deployment
Give Claude the SSE URL and everything else the streamable HTTP URL — both are already served.
03
Signing users in with your own identity provider
Swap the auth provider in the app's own auth layer; the OAuth server keeps working regardless.
BEFORE YOU INSTALL
What to know first
Requires
- Node.js with pnpm
- A PostgreSQL database (DATABASE_URL)
- A Google OAuth client (GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET)
- A Vercel account to deploy it
- Redis (REDIS_URL) for the SSE transport Claude Desktop and Claude.ai use
INSTALLATION
Connect your client
This one is built from source rather than installed with a single command.
Server setup
TERMINAL
git clone https://github.com/DTeam-Top/mcp-oauth.git
cd mcp-oauthCreate a .env file with DATABASE_URL (a PostgreSQL database), BETTER_AUTH_SECRET (any random string), GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET (a Google OAuth client), NEXT_PUBLIC_BASE_URL, and REDIS_URL if Claude Desktop or Claude.ai will connect over SSE
TERMINAL
pnpm install
pnpm run db:generate
pnpm run db:push
pnpm run devDeploy the app to Vercel (the only supported host), with pnpm run db:generate added to the build command and the same environment variables set there. In the client configurations, <YOUR_DOMAIN> is your deployment's domain: /mcp/mcp for Cursor and VS Code, /mcp/sse for Claude Desktop and Claude.ai
MCP Clients
Cursor
CURSOR · JSON
{
"mcpServers": {
"MyServer": {
"name": "MCP OAuth Demo",
"url": "<YOUR_SERVER_URL>/mcp/mcp"
}
}
}<YOUR_SERVER_URL> is the https:// address of your own Vercel deployment of this app.
VS Code
VS CODE · JSON
{
"servers": {
"My Server": {
"url": "<YOUR_SERVER_URL>/mcp/mcp"
}
}
}<YOUR_SERVER_URL> is the https:// address of your own Vercel deployment of this app.