mcp-oauth-sample
OAuth 2.1 authorization and MCP server on Vercel for MCP clients with real-time analytics and threat detection
claude mcp add --transport stdio raxitlabs-mcp-oauth-sample node server.js \ --env REDIS_URL="redis://localhost:6379" \ --env JWT_SECRET="your-jwt-secret" \ --env DATABASE_URL="PostgreSQL connection string" \ --env NEXTAUTH_URL="https://your-domain.com" \ --env OAUTH_CLIENT_ID="your-oauth-client-id" \ --env OAUTH_CLIENT_SECRET="your-oauth-client-secret"
How to use
This MCP server provides a production-ready OAuth 2.1 authorization server with MCP-specific capabilities and an analytics dashboard. It supports the MCP authorization flow, including PKCE and refresh tokens, and exposes endpoints for discovery, token exchange, and resource indicators in accordance with the MCP specification. The server also includes a real-time analytics dashboard and security monitoring, accessible under the /analytics path. Clients can integrate via the MCP endpoints at /mcp/mcp and subscribe to server-sent events at /mcp/sse. Documentation and quick-start examples illustrate how to register clients dynamically, perform OAuth flows, and register MCP clients for seamless onboarding. For client integration, you can use the provided sample configurations to connect tools like Claude or Cursor by pointing them to the appropriate MCP endpoints and transport (SSE or HTTP-stream).
How to install
Prerequisites:
- Node.js (LTS version) and a package manager (pnpm recommended)
- PostgreSQL database
- Basic environment for OAuth (client credentials, redirect URIs) and an accessible domain for NEXTAUTH_URL
Steps:
-
Clone the repository: git clone https://github.com/raxITai/mcp-oauth-sample.git cd mcp-oauth-sample
-
Install dependencies: pnpm install
-
Copy and adjust environment variables: cp .env.example .env
Edit .env and set DATABASE_URL, NEXTAUTH_URL, OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET, JWT_SECRET, etc.
-
Set up the database with Prisma: pnpm prisma generate pnpm prisma db push
-
Run the development server: pnpm dev
Notes:
- The server uses Next.js with MCP-specific enhancements. In production, you would run the built server via your hosting platform (Vercel, etc.), ensuring the environment variables are securely provided.
- The mcp_config sample uses a Node.js path to server.js; adjust if your build process uses a different entry point (e.g., starting with pnpm start in production).
Additional notes
Tips and common considerations:
- Ensure NEXTAUTH_URL and OAUTH redirect URIs match your deployed domain to avoid redirect failures.
- If you rotate client secrets or JWT keys, restart the server so new keys take effect.
- The analytics dashboard relies on real-time data; ensure Redis or any required in-memory store is available and properly configured.
- For local development, you can run Prisma locally and use a local PostgreSQL instance; for production, consider managed PostgreSQL and separate analytics data storage.
- The MCP endpoints include discovery at /.well-known/oauth-authorization-server and client-facing endpoints at /mcp/mcp and /mcp/sse. Use these in your client integrations.
- If you encounter CORS or authentication errors, verify NEXTAUTH_URL, allowed origins, and the OAuth client configuration in the provider settings.
Related MCP Servers
mcp-memory
🔥🖥️ MCP Memory is a MCP Server that gives MCP Clients (Cursor, Claude, Windsurf and more) the ability to remember information about users (preferences, behaviors) across conversations.
mcp -echart
基于 mcp-go 框架构建的 mcp 服务,它提供了一个能动态生成 ECharts 图表页面的工具。
justcall
JustCall's Official MCP Server
mcp-doc-forge
MCP server that provides doc forge capabilities
mcp-install-instructions-generator
Generate MCP Server Installation Instructions for Cursor, Visual Studio Code, Claude Code, Claude Desktop, Windsurf, ChatGPT, Gemini CLI and more
AI-web mode
一个基于 MCP (Model Context Protocol) 的智能对话助手Web应用,支持实时聊天、工具调用和对话历史管理。