Math Calculator MCP Server
Provides basic mathematical operations (addition, subtraction, multiplication, division) through a calculate tool. Supports both stdio and HTTP/SSE transport modes.
README
数学运算 MCP 服务器
这是一个提供基本数学运算(加、减、乘、除)的 Model Context Protocol (MCP) 服务器。
该服务器支持两种运行模式:
- Stdio:标准输入/输出(默认)
- HTTP:支持 SSE 的 Streamable HTTP
前置要求
- Node.js (v18 或更高版本)
- npm
安装
- 克隆仓库
- 安装依赖:
npm install - 构建项目:
npx tsc
使用方法
1. Stdio 模式(默认)
当与通过子进程启动服务器的 MCP 客户端(如 Claude Desktop, Trae)集成时使用此模式。
node dist/index.js
# 或者
node dist/index.js stdio
2. HTTP 模式(Streamable HTTP & SSE)
此模式启动一个支持 Streamable HTTP 和 SSE (Server-Sent Events) 的 HTTP 服务器。
node dist/index.js http
服务器将在 3000 端口启动(默认)。
- 端点:
http://localhost:3000/mcp
部署
⚠️ 关于 Vercel 部署的重要警告
虽然本项目已配置了 vercel.json 以支持部署,但 强烈不推荐 将此 MCP 服务器部署到 Vercel Serverless Functions。
原因:
- 无状态问题:MCP 协议依赖内存状态来关联 SSE 连接和 POST 请求。Vercel 的 Serverless 环境可能会将请求分发到不同的实例,导致“找不到会话”的错误。
- 连接超时:MCP 需要长连接 (SSE)。Vercel 函数有执行时间限制(通常 10-60 秒),超时后会强制断开连接。
如果您执意尝试 Vercel:
- 本项目已包含
vercel.json配置。 - 在 Vercel 仪表盘中导入项目。
- 确保
Framework Preset设置为Other。 - Build Command:
npm run build - Output Directory:
dist(或者留空)
✅ 推荐部署方式:Docker / Render / Railway
推荐将服务器作为长运行的容器应用部署。
使用 Docker 运行
-
构建镜像:
docker build -t mcp-math-server . -
运行容器:
docker run -p 3000:3000 mcp-math-server
部署到 Render/Railway/Heroku
- 将代码推送到 GitHub。
- 在 Render/Railway 等平台上创建一个新的 "Web Service"。
- 平台会自动检测
package.json和Dockerfile。 - 确保启动命令为
npm start(默认已配置)。
部署后如何请求接口
部署完成后(假设域名为 https://your-app.vercel.app),您的 MCP Endpoint 地址将是:
https://your-app.vercel.app/mcp
1. 使用测试客户端
您可以使用本项目提供的测试客户端进行连接测试:
# 格式:node dist/test-client.js http <YOUR_DEPLOYED_URL>
node dist/test-client.js http https://your-app.vercel.app/mcp
2. 集成到 Claude Desktop / Trae
如果您的客户端支持 SSE 连接,配置如下:
{
"mcpServers": {
"math-server": {
"command": "node",
"args": ["path/to/dist/index.js", "http"],
"env": {
"PORT": "3000"
}
}
}
}
注意:目前大多数 MCP 客户端(如 Claude Desktop)主要支持 Stdio 模式,对 HTTP/SSE 的支持可能需要特定的配置或适配器。
工具 (Tools)
服务器提供一个名为 calculate 的工具,包含以下参数:
operation:操作类型,可选 "add"(加), "subtract"(减), "multiply"(乘), "divide"(除)a:第一个数字b:第二个数字
测试
项目中包含一个测试客户端,用于验证两种模式。
测试 HTTP 模式(请先确保服务器已启动):
# 终端 1:启动服务器
node dist/index.js http
# 终端 2:运行客户端
node dist/test-client.js http
测试 Stdio 模式:
node dist/test-client.js stdio
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Neon Database
MCP server for interacting with Neon Management API and databases