Next.js MCP服务器

一个基于Next.js的Model Context Protocol(MCP)服务器示例,用于在Vercel上快速部署和调用AI工具、提示词与资源。

  • by ee380
  • JavaScript
  • 混合部署
  • 更新于
在 GitHub 查看 ee380/model-context-protocol-mcp-with-next-js

使用说明

Example Next.js MCP Server

Uses mcp-handler

Usage

This sample app uses the Vercel MCP Adapter that allows you to drop in an MCP server on a group of routes in any Next.js project.

Update app/[transport]/route.ts with your tools, prompts, and resources following the MCP TypeScript SDK documentation.

Notes for running on Vercel

  • To use the SSE transport, requires a Redis attached to the project under process.env.REDIS_URL and toggling the disableSse flag to false in app/mcp/route.ts
  • Make sure you have Fluid compute enabled for efficient execution
  • After enabling Fluid compute, open app/route.ts and adjust maxDuration to 800 if you using a Vercel Pro or Enterprise account
  • Deploy the Next.js MCP template

Sample Client

script/test-client.mjs contains a sample client to try invocations.

node scripts/test-client.mjs https://mcp-for-next-js.vercel.app