LabscoMCP early access ↗
DTeam-TopMCP SERVER · OFFICIAL PROJECT

OAuth 2.1 MCP Server

A working OAuth 2.1 MCP server as a Next.js app — client registration, consent screen and token exchange already built, so you add your tools and deploy.

by DTeam-Top ↗MCP Plumbing: Proxies, Registries & Inspectors✓ Official

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/mcp and 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.ts is 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