OAuth 2.1 MCP Server

OAuth 2.1 MCP Server is an MCP server and Next.js starter template that implements OAuth 2.1 authentication to secure Model Context Protocol endpoints. It connects AI clients to authenticated application resources using Drizzle ORM on PostgreSQL for session and token persistence, alongside Redis for Server-Sent Events coordination. Software developers building multi-user agent integrations use this template to issue access tokens, manage dynamic client registrations, and verify authorization scopes before exposing MCP tools. It enables host applications to support both Streamable HTTP and SSE transports via the Vercel MCP adapter, allowing client-facing platforms like Claude Desktop, Cursor, and VS Code to interact safely with user-specific APIs. With built-in authentication support using Better Auth alongside external providers like Google, developers can guard resources without breaking standard MCP communication patterns.

Category: AI & LLM Tooling

Tags: authentication, nextjs, oauth, postgresql, redis

Visit OAuth 2.1 MCP Server

How to install and configure OAuth 2.1 MCP Server

  1. Clone the repository and install dependencies by running pnpm install. 2. Configure your .env file with DATABASE_URL, REDIS_URL, BETTER_AUTH_SECRET, and your OAuth credentials (such as GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET). 3. Generate and push database schemas using pnpm run db:generate and pnpm run db:push. 4. Start the local server with pnpm run dev or deploy the app to Vercel. 5. To connect Claude Desktop, add an integration using your hosted URL ending in /mcp/sse. 6. For Cursor, add the following to mcp.json: json { "mcpServers": { "MyServer": { "name": "MCP OAuth Demo", "url": "https://example.com/mcp/mcp", "transport": "http-stream" } } }

What you can do with OAuth 2.1 MCP Server

  • Securing custom MCP endpoints with OAuth 2.1 authorization code grant flows and dynamic client registration. - Persisting user sessions, OAuth access tokens, and registered client IDs using PostgreSQL and Drizzle ORM. - Exposing Model Context Protocol tools over Server-Sent Events specifically to support Claude Desktop and Web integrations. - Connecting coding assistants like Cursor and VS Code over Streamable HTTP transports using secure bearer tokens. - Handling user sign-in flows with Google, GitHub, or Discord prior to granting MCP tool permissions.

Key facts

  • Open Source
  • https://github.com/DTeam-Top/mcp-oauth
  • AI & LLM Tooling, Developer Tools & Code Intelligence
  • authentication, nextjs, oauth, postgresql, redis

Part of MCP Servers

Related MCP servers

  • MCP LaTeX Server — MCP LaTeX Server is an MCP server that provides tools for creating, editing, validating, and compiling LaTeX documents directly through…
  • MCP JSON — MCP JSON is an MCP server collection that bundles tools for file system operations, Google search, browser-based web automation, and…
  • MCP Jupyter Complete — MCP Jupyter Complete is an MCP server that provides tools for manipulating Jupyter notebook files through position-based cell operations and…
  • MCP LSP Go — MCP LSP Go is an MCP server that connects AI assistants to the official Go Language Server Protocol implementation, gopls,…
  • MCP Memory Dashboard — MCP Memory Dashboard is an MCP server desktop interface that connects to the MCP Memory Service to provide visual semantic…
  • MCP Manager — MCP Manager is an MCP server management tool that connects directly to your Claude Desktop environment, enabling users to discover,…

How do I install OAuth 2.1 MCP Server?

Clone the repository from GitHub and install packages using pnpm install. Define the required environment variables in your env file, including DATABASE_URL and BETTER_AUTH_SECRET. Generate and push database tables with pnpm run db:generate and pnpm run db:push, then launch the development server using pnpm run dev.

Which MCP clients work with OAuth 2.1 MCP Server?

It works with Claude Desktop and Claude Web using the SSE transport path. It also supports Cursor, Visual Studio Code, and the official MCP Inspector using the Streamable HTTP transport endpoint.

Why does OAuth 2.1 MCP Server require Redis?

Redis is required when serving traffic via the Server-Sent Events transport. This enables real-time message broadcasting and compatibility with MCP clients like Claude Desktop that rely on SSE rather than standard streamable HTTP.

Is OAuth 2.1 MCP Server open source?

Yes, OAuth 2.1 MCP Server is an open source template hosted on GitHub. It was forked from run-llama/mcp-nextjs and updated to use Drizzle ORM and Better Auth for persistence and authentication.

Can I host this server on any platform?

The server currently requires deployment to Vercel due to its dependency on the @vercel/mcp-adapter package, which handles protocol routing for both SSE and Streamable HTTP transports.

  • AI Tools
  • Categories
  • Industries
  • CLI Coding Agents
  • MCP Servers
  • MCP Categories