Math Calculator MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Math Calculator MCP Servercalculate 15 plus 7"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
数学运算 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 stdio2. 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 buildOutput 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/mcp2. 集成到 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 stdioResources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
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/wxt2rr/mcp-server-test'
If you have feedback or need assistance with the MCP directory API, please join our Discord server