mcp_math_server
v1.0.1
Published
MCP 服务 - 计算函数
Maintainers
Readme
mcp_math_server
一个基于 Model Context Protocol (MCP) 的数学计算服务器,提供加法、减法、乘法和除法功能。
功能
该 MCP 服务器提供以下工具:
- local_sum: 计算多个数字的和
- local_multiply: 计算多个数字的积
- local_subtract: 计算两个数字的差
- local_divide: 计算两个数字的商
安装
方式一:全局安装(推荐)
npm install -g mcp_math_server方式二:本地安装
npm install mcp_math_server配置
在 Cursor 中使用
- 打开 Cursor 设置
- 找到 MCP 服务器配置(通常在设置文件中)
- 添加以下配置:
{
"mcpServers": {
"math-server": {
"command": "mcp-math-server",
"args": []
}
}
}如果使用本地安装,需要指定完整路径:
{
"mcpServers": {
"math-server": {
"command": "node",
"args": ["/path/to/node_modules/mcp_math_server/index.js"]
}
}
}在 Claude Desktop 中使用
找到 Claude Desktop 的配置文件:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
- macOS:
在配置文件中添加:
{
"mcpServers": {
"math-server": {
"command": "mcp-math-server",
"args": []
}
}
}如果使用本地安装,使用完整路径:
{
"mcpServers": {
"math-server": {
"command": "node",
"args": ["/path/to/node_modules/mcp_math_server/index.js"]
}
}
}- 重启 Claude Desktop
使用 npx(无需安装)
如果不想全局安装,也可以直接使用 npx:
{
"mcpServers": {
"math-server": {
"command": "npx",
"args": ["-y", "mcp_math_server"]
}
}
}使用方法
配置完成后,重启你的 MCP 客户端(Cursor 或 Claude Desktop),然后就可以在对话中使用这些数学计算工具了。
示例
- "计算 1, 2, 3, 4 的和"
- "计算 5 乘以 6 乘以 7"
- "计算 100 减去 25"
- "计算 50 除以 2"
AI 助手会自动调用相应的 MCP 工具来执行计算。
开发
本地运行
npm start项目结构
index.js: MCP 服务器主文件package.json: 项目配置和依赖
许可证
ISC
