michaelguo1991/math-mcp-server-nodejs
3.2
If you are the rightful owner of math-mcp-server-nodejs and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A NodeJS-based Model Context Protocol (MCP) server providing mathematical computation capabilities.
Tools
1
Resources
0
Prompts
0
Math MCP Server (NodeJS)
一个基于 NodeJS 的 Model Context Protocol (MCP) 服务器,提供数学计算功能。
功能特性
- 加法工具: 提供两个数字的加法计算
- 服务器信息资源: 展示服务器的基本信息
- 计算提示模板: 用于数学计算的提示模板
安装
从 npm 安装(推荐)
npm install -g @michaelguo91/math-mcp-server-nodejs
从源码安装
- 克隆或下载项目到本地
- 安装依赖:
npm install
构建
npm run build
运行
开发模式
npm run dev
生产模式
npm start
监听模式(自动重新编译)
npm run watch
使用方法
这个 MCP 服务器通过 stdio 传输层与客户端通信。它提供以下功能:
工具 (Tools)
add
计算两个数字的和。
参数:
a
(number): 第一个数字b
(number): 第二个数字
示例:
{
"name": "add",
"arguments": {
"a": 5,
"b": 3
}
}
返回:
{
"content": [
{
"type": "text",
"text": "计算结果: 5 + 3 = 8"
}
]
}
资源 (Resources)
server-info
获取服务器的基本信息。
URI: info://server
提示 (Prompts)
calculate
用于数学计算的提示模板。
参数:
operation
(string): 要执行的数学操作numbers
(array): 参与计算的数字数组
与 MCP 客户端集成
全局安装后使用
如果你全局安装了这个包,可以直接使用命令:
{
"mcpServers": {
"math-server": {
"command": "math-mcp-server"
}
}
}
本地安装使用
要在 MCP 客户端中使用此服务器,请将以下配置添加到客户端的配置文件中:
{
"mcpServers": {
"math-server": {
"command": "node",
"args": ["path/to/math-mcp-server-nodejs/dist/index.js"]
}
}
}
使用 npx(无需安装)
{
"mcpServers": {
"math-server": {
"command": "npx",
"args": ["@michaelguo91/math-mcp-server-nodejs"]
}
}
}
测试
你可以使用 MCP Inspector 来测试这个服务器:
npx @modelcontextprotocol/inspector node dist/index.js
项目结构
math-mcp-server-nodejs/
├── src/
│ └── index.ts # 主服务器文件
├── dist/ # 编译后的 JavaScript 文件
├── package.json # 项目配置和依赖
├── tsconfig.json # TypeScript 配置
└── README.md # 项目说明
技术栈
- NodeJS: JavaScript 运行时
- TypeScript: 类型安全的 JavaScript
- MCP SDK: Model Context Protocol TypeScript SDK
- Zod: 运行时类型验证
许可证
MIT License
贡献
欢迎提交 Issue 和 Pull Request!
扩展功能
你可以轻松扩展这个服务器来添加更多数学功能:
- 减法、乘法、除法
- 高级数学函数(三角函数、对数等)
- 统计计算
- 矩阵运算
只需在 src/index.ts
中添加新的工具定义即可。