Skip to main content
Glama

在 Vercel 上运行 MCP 服务器

使用方法

按照 MCP TypeScript SDK 文档 更新 api/server.ts 中的工具、提示词和资源。

此模板还有一个 Next.js 版本

Related MCP server: Next.js MCP Server Template

MCP 客户端集成

将此服务器添加到 MCP 客户端应用程序时,请使用您的部署 URL 后跟 /mcp:

https://your-deployment-url.vercel.app/mcp

示例工具

该模板包含两个示例工具,帮助您快速上手:

  • roll_dice - 掷一个 N 面骰子(最少 2 面)

  • get_weather - 使用纬度、经度和城市名称获取某个地点的当前天气数据(通过 API)

这些工具演示了基本功能和 API 集成模式。请用您自己的工具替换它们。

在 Vercel 上运行的注意事项

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

  • 启用 Fluid compute 后,打开 vercel.json 并将最大持续时间调整为 800(如果您使用的是 Vercel Pro 或 Enterprise 账户)

  • 部署 MCP 模板

本地开发

  • 运行 vercel dev 进行本地开发

  • 或者,将系统集成到您选择的服务器框架中。

示例客户端

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

node scripts/test-streamable-http-client.mjs https://mcp-on-vercel.vercel.app

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    A template for running Model Context Protocol servers on Vercel with Redis support, allowing developers to deploy their custom tools, prompts, and resources using the MCP TypeScript SDK.
    -
  • -
    license
    Not graded
    quality
    Not graded
    maintenance
    A template for building MCP servers in Next.js applications using the Vercel MCP Adapter. Provides a foundation for adding custom tools, prompts, and resources to any Next.js project with deployment support on Vercel.
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    A template for deploying MCP servers on Vercel with example tools for rolling dice and getting weather data. Provides a foundation for building custom MCP servers with tools, prompts, and resources that can be deployed to Vercel's serverless platform.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A template for deploying Model Context Protocol servers as Next.js routes using the mcp-handler adapter, enabling easy integration of MCP tools, prompts, and resources into any Next.js application.
    MIT