Next.js MCP Server is an open-source template and implementation for hosting Model Context Protocol servers inside a Next.js web application deployed on Vercel. Developed by Run-Llama, it connects MCP clients to custom application endpoints using OAuth 2.1 authentication, backing user sessions and client registrations with PostgreSQL and Prisma. Developers building AI-enabled web services use this server to expose custom tools, resources, and API integrations securely to remote AI agents. The project utilizes the Vercel MCP adapter to support both Server-Sent Events and Streamable HTTP transports. A Redis instance is supported to handle session persistence for SSE connections. It also integrates Auth.js with Google as a default login provider for the host application consent screens, enabling builders to scaffold custom authenticated endpoints for Claude Desktop, Cursor, Visual Studio Code, and MCP Inspector without writing authentication and transport protocols from scratch.
Category: Databases & Data Stores
Tags: authentication, nextjs, oauth, postgresql, redis
Follow these steps to install and run the Next.js MCP Server locally and configure it in your client: 1. Clone the repository and install dependencies using npm install. 2. Set up your .env file with DATABASE_URL, AUTH_SECRET, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and optionally REDIS_URL. 3. Generate the database client and push the initial schema using prisma generate and prisma db push. 4. Start the development server by executing npm run dev. 5. For Cursor, add the server to your mcp.json file: json { "mcpServers": { "MyServer": { "name": "LlamaIndex MCP Demo", "url": "https://example.com/mcp/mcp", "transport": "http-stream" } } } 6. For Claude Desktop or Claude.ai, connect via the SSE transport by providing the full URL ending in /mcp/sse.
Part of MCP Servers
Next.js MCP Server is an open-source reference implementation by Run-Llama for running an MCP server inside a Next.js application on Vercel. It provides OAuth 2.1 authentication handling, Prisma-based PostgreSQL storage, and dual transport support.
The server works with Claude Desktop, Claude.ai, Cursor, Visual Studio Code, and the official MCP Inspector. Claude requires connecting via the SSE transport route, while Cursor and VSCode connect via Streamable HTTP.
A PostgreSQL database is required to store OAuth clients, tokens, and session details using Prisma. If you plan to support Claude via SSE transport, a Redis database connection is also required.
Yes, Next.js MCP Server is open source and hosted on GitHub under the run-llama organization. Note that the repository is currently archived and serves primarily as an architectural template for developers.