MCP OAuth Sample

MCP OAuth Sample is an MCP server that provides a reference implementation of OAuth 2.1 authorization for Model Context Protocol clients. Built with Next.js 15, Prisma, and PostgreSQL, the project implements specification-compliant authentication and identity management for remote tool interactions. It connects to identity providers such as Google via NextAuth.js and persists token states, sessions, and client registrations directly inside a PostgreSQL database. Software engineers and AI platform developers use this implementation to establish secure authentication boundaries for AI workflows, preventing unauthorized access across distributed agent systems. The server enables full lifecycle token operations, including PKCE verification, automatic refresh token flows, and strict audience validation. It exposes standard discovery endpoints alongside both Server-Sent Events and HTTP streaming transports. In addition to core OAuth functionality, it incorporates dynamic client registration, real-time security monitoring, and an administrative analytics dashboard to track client tool usage and potential threat indicators across connected agent sessions.

Category: Databases & Data Stores

Tags: authentication, identity, nextjs, oauth, postgresql

Visit MCP OAuth Sample

How to install and configure MCP OAuth Sample

  1. Clone the repository and install project dependencies using pnpm install. 2. Configure your environment variables by running cp .env.example .env and setting your database and Google OAuth parameters. 3. Initialize the PostgreSQL schema by executing pnpm prisma generate followed by pnpm prisma db push. 4. Start the development server locally with pnpm dev. 5. Register the server in your MCP client configuration file. For Claude Desktop, add an SSE connection under mcpServers: json { "mcpServers": { "raxIT-oauth": { "url": "https://your-domain.com/mcp/sse", "transport": "sse" } } } For Cursor, configure the HTTP stream transport: json { "mcpServers": { "raxIT-oauth": { "url": "https://your-domain.com/mcp/mcp", "transport": "http-stream" } } }

What you can do with MCP OAuth Sample

  • Securing AI client connections to custom tools using OAuth 2.1 authorization with PKCE protection and automated refresh token flows. - Authenticating enterprise users through Google accounts via NextAuth.js before granting access to Model Context Protocol endpoints. - Monitoring client tool utilization and analyzing real-time security events using the built-in Next.js analytics dashboard. - Managing dynamic client registration and authorization server discovery compliant with RFC 8414 and RFC 7591 standards. - Persisting user authentication sessions and client token records in a PostgreSQL database with automated cleanup and TTL management.

Key facts

  • Open Source
  • https://github.com/raxITai/mcp-oauth-sample
  • Databases & Data Stores, Developer Tools & Code Intelligence
  • authentication, identity, nextjs, oauth, postgresql

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 Manager — MCP Manager is an MCP server management tool that connects directly to your Claude Desktop environment, enabling users to discover,…
  • MCP Lab — MCP Lab is an MCP server development environment designed for building, testing, and debugging custom Model Context Protocol servers integrated…

What is MCP OAuth Sample?

MCP OAuth Sample is an open-source reference server built with Next.js 15 that implements OAuth 2.1 authentication for the Model Context Protocol. It connects AI clients to protected tools and resources while integrating Google authentication through NextAuth.js, session management in PostgreSQL, and real-time security analytics.

Which MCP clients work with MCP OAuth Sample?

The server works with any Model Context Protocol client supporting remote transports. It includes native configurations for Claude Desktop and Claude Web via Server-Sent Events at the /mcp/sse endpoint, as well as Cursor through HTTP streaming at the /mcp/mcp endpoint.

How do I install and run MCP OAuth Sample?

Clone the repository and install packages using pnpm install. Copy .env.example to .env to configure your database and authentication variables, then run pnpm prisma generate and pnpm prisma db push to initialize PostgreSQL. Start the local server with pnpm dev.

What authentication standards does MCP OAuth Sample support?

The server supports OAuth 2.1 specifications along with PKCE, refresh token rotation, RFC 8414 and RFC 9728 discovery endpoints, RFC 8707 resource parameters, RFC 7591 dynamic client registration, and strict token audience validation.

Is MCP OAuth Sample open source?

Yes, MCP OAuth Sample is open source software released under the Apache License 2.0. Developers can inspect, fork, modify, and host the code independently from its GitHub repository at raxITai/mcp-oauth-sample.

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