Skip to main content
Glama

使用 Next.js 的无头 MCP(来自注册表)

使用@vercel/mcp-adapter和可配置的 MCP 注册表

部署 URL

此应用程序部署于: https://nextjs-mcp-use.vercel.app

Related MCP server: Example Next.js MCP Server

特征

  • MCP 注册表:在单个 JSON 文件中配置多个 MCP 服务器

  • GitHub Actions :使用计划和手动工作流程测试和监控您的 API 端点

  • 错误处理:优雅地处理超时和连接失败

  • 环境变量:为每个 MCP 服务器配置环境变量

MCP 注册

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 服务器。

按照MCP TypeScript SDK 文档,使用您的工具、提示和资源更新app/[transport]/route.ts

API 端点

  • 聊天 API/api/chat - 流聊天端点

  • 完成 API/api/completions - 非流式聊天完成端点

测试 API

您可以使用提供的测试脚本测试 API 端点:

# Test the chat endpoint
npm run test:chat -- --message "Your message here"

# Test the completions endpoint
npm run test:completions -- --message "Your message here"

# Test with a custom URL
npm run test:chat -- --url http://localhost:3000/api/chat --message "Your message here"

GitHub Actions

本项目包含用于测试和监控 API 端点的 GitHub Actions 工作流程。更多信息请参阅.github/workflows/README.md文件。

在 Vercel 上运行的注意事项

  • 要使用 SSE 传输,需要在process.env.REDIS_URL下将 Redis 附加到项目

  • 确保已启用Fluid Compute以实现高效执行

  • 启用 Fluid compute 后,打开app/route.ts并将maxDuration调整为 800(如果您使用 Vercel Pro 或 Enterprise 帐户)

  • 部署 Next.js MCP 模板

示例客户端

  • scripts/test-client.mjs包含一个用于尝试调用的示例客户端。

node scripts/test-client.mjs https://nextjs-mcp-use.vercel.app

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

No tool schema history has been recorded yet.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cameronking4/nextjs-mcp-use'

If you have feedback or need assistance with the MCP directory API, please join our Discord server