使用可配置MCP注册表的@vercel/mcp-adapter
该应用程序部署在:https://nextjs-mcp-use.vercel.app
MCP注册表是一个JSON配置文件,存储有关所有可用MCP服务器的信息。每个服务器可以启用或禁用,并且可以有自己的环境变量。
注册表位于config/mcp-registry.json,具有以下结构:
{
"server-name": {
"url": "http://localhost:3002/sse",
"enabled": true,
"env": {
"API_KEY": "your-api-key"
}
},
"another-server": {
"url": "https://example.com/sse",
"enabled": false
}
}
此示例应用使用Vercel MCP适配器,允许您在任何Next.js项目的一组路由中插入一个MCP服务器。
更新app/[transport]/route.ts,添加您的工具、提示和资源,参考MCP TypeScript SDK文档。
/api/chat - 流式聊天端点/api/completions - 非流式聊天完成端点您可以使用提供的测试脚本测试API端点:
# 测试聊天端点
npm run test:chat -- --message "您的消息在这里"
# 测试完成端点
npm run test:completions -- --message "您的消息在这里"
# 使用自定义URL测试
npm run test:chat -- --url http://localhost:3000/api/chat --message "您的消息在这里"
该项目包括用于测试和监控API端点的GitHub Actions工作流。参见.github/workflows/README.md文件获取更多信息。
process.env.REDIS_URLapp/route.ts并调整maxDuration为800,如果您使用的是Vercel Pro或Enterprise账户scripts/test-client.mjs 包含一个示例客户端,用于尝试调用。node scripts/test-client.mjs https://nextjs-mcp-use.vercel.app