
MCP for Next.js
https://github.com/vercel-labs/mcp-for-next.js- Category
- AI Agents
- Rank
- No. 1335Tools index
Previous survey · No. 1341 ·
- Pricing
- Open Source
- Type
- TOOL
- Builder
- vercel-labs
- GitHub
- 369 stars
- Date
About
Next.js template for serving an MCP (Model Context Protocol) server from your app.
What it does
It adds a stateless protocol endpoint to an existing Next.js App Router application. You define tools, prompts, and resources through the MCP TypeScript SDK. The included example validates a short message, returns text plus structured output, and demonstrates connection from a Streamable HTTP client.
Why it's ranked here
This is a focused, credible starting point because it combines current native protocol support, compatibility for older Streamable HTTP clients, strict TypeScript configuration, and a working client example. Its narrow scope is also clear: this is starter code, not a complete production service.
What's good
The example teaches several useful details instead of merely proving connectivity. It validates input and output shapes, supplies behavioral annotations, returns both human-readable and structured results, and exposes the endpoint through both supported HTTP methods. Redis is unnecessary for the stateless design.
Tradeoffs
Only one echo tool is implemented, so authentication, authorization, persistence, observability, and domain behavior remain your responsibility. Deprecated HTTP plus SSE clients cannot connect. The application requires Node.js 20 or later, and efficient Vercel execution depends on enabling Fluid compute.
How to use it well
Use it when a Next.js team wants to prototype or host a small stateless MCP service inside an App Router application. Replace the echo example with narrowly scoped tools, then exercise them with the supplied client. Choose another foundation when legacy HTTP plus SSE compatibility is mandatory.
Technical notes+
app/mcp/route.ts builds one echo tool with createMcpHandler, strict Zod input and output schemas, MCP annotations, and shared GET/POST exports. scripts/test-client.mjs uses StreamableHTTPClientTransport, lists tools, invokes echo, and closes the connection. package.json defines pnpm scripts for development, builds, linting, type checks, and client testing; it depends on Next.js 15, React 19, mcp-handler 2, the MCP server package, and Zod 4. tsconfig.json enables strict checking with no emitted output. next.config.ts contains no custom Next.js configuration.
Observed
- License
- MIT license terms permit use, modification, distribution, sublicensing, and sale.
- Primary language
- TypeScript, with a JavaScript sample client and configuration files.
- Packaging
- Private pnpm-managed Next.js application template, not a published library package.
- Interface
- Stateless MCP service over Streamable HTTP, exposed through GET and POST.
- Runtime support
- Node.js 20 or later is required.
- Protocol compatibility
- Native current MCP support plus compatibility for older Streamable HTTP clients; deprecated HTTP plus SSE is unsupported.
- Included validation
- Strict Zod schemas validate the example tool input and structured output.
Read from README.md, package.json, next.config.ts, eslint.config.mjs, scripts/test-client.mjs, app/mcp/route.ts, LICENSE, tsconfig.json, public/index.html.
What it can do
Serve MCP server endpoints
HTTP requests to MCP routes → MCP protocol responses
Initialize MCP server configuration
Next.js application setup → Configured MCP server instance
Handle MCP protocol messages
MCP client requests and commands → Structured MCP response data
Integrate AI model context sharing
Context data and model requests → Shared context between AI models
Deploy MCP server as web application
Next.js deployment configuration → Live MCP server accessible via URL
Tags
Tech Stack
Media
Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.