Token导航 LogoToken导航TokenDH.com
MCP Math Calculator logo
搜索检索stdio官方级别未说明来源级核验

MCP Math Calculator

MCP Server

mcp-math-calculator

精确数学计算的 MCP 服务器 - 为 AI 提供 100% 准确的数学计算能力

工具数

1

提示词数

0

GitHub Stars

0

资源数

0
TypeScriptClaude搜索Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

Cosmiumx

提供方

Cosmiumx

最后核验

2026/5/18 02:51

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx -y mcp-math-calculator [object Object]

详细介绍

mcp-math-calculator

🧮 精确数学计算的 MCP 服务器 - 为 AI 提供 100% 准确的计算能力

](https://www.npmjs.com/package/mcp-math-calculator) ![License: MIT](https://opensource.org/licenses/MIT)

🌟 特性

  • 精确算术运算 - 解决浮点数精度问题(如 0.1 + 0.2 = 0.3)
  • 大数支持 - 处理超出 JavaScript 安全整数范围的数字
  • 复杂表达式 - 支持括号、运算符优先级
  • 科学函数 - sqrt, pow, sin, cos, log, exp 等 300+ 函数
  • 安全求值 - 无代码注入风险,沙箱隔离执行
  • 超时保护 - 5秒自动超时,防止恶意计算

📦 安装

快速开始(推荐)

在你的 MCP 客户端配置中添加(如 Claude Desktop):

macOS/Linux: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "math-calculator": {
      "command": "npx",
      "args": ["-y", "mcp-math-calculator"]
    }
  }
}

方式 2: 全局安装

npm install -g mcp-math-calculator
# 或
pnpm add -g mcp-math-calculator

然后配置:

{
  "mcpServers": {
    "math-calculator": {
      "command": "mcp-math-calculator"
    }
  }
}

🚀 使用方法

配置完成后,重启你的 AI 客户端,然后可以这样提问:

  • "精确计算 0.1 + 0.2"
  • "123456789 * 987654321 等于多少?"
  • "计算 (10 + 20) * 3 / 2"
  • "sqrt(16) + pow(2, 3) 的值是多少?"
  • "帮我算一下 sin(pi/2)"

AI 会自动调用此工具进行精确计算。

🛠️ 可用工具

calculate

精确计算数学表达式。

参数:

  • expression (string, 必需): 要计算的数学表达式
  • precision (number, 可选): 小数精度位数(默认: 15,范围: 1-64)

支持的运算:

类型示例
基础运算+, -, *, /, ^, %
括号(, )
函数sqrt(), pow(), abs(), round(), floor(), ceil()
三角函数sin(), cos(), tan(), asin(), acos(), atan()
对数指数log(), log10(), log2(), exp()
常数pi, e, tau, phi

示例:

// 基础运算
"2 + 2"                    // 4
"10 - 3"                   // 7
"6 * 7"                    // 42
"20 / 4"                   // 5

// 浮点数精度
"0.1 + 0.2"                // 0.3 (不是 0.30000000000000004)

// 复杂表达式
"(10 + 20) * 3"            // 90
"2 + 3 * 4 - 5 / 5"        // 13

// 科学函数
"sqrt(16)"                 // 4
"pow(2, 3)"                // 8
"sin(pi / 2)"              // 1

// 大数运算
"123456789 * 987654321"    // 121932631112635269
"999999999999999999 + 1"   // 1000000000000000000

🔒 安全性

本工具采用多层安全机制:

  • 不使用 eval() - 使用 mathjs 安全解析器
  • 沙箱执行 - 隔离计算环境
  • 函数白名单 - 仅允许安全的数学函数
  • 输入验证 - 拒绝危险模式(import, require, eval 等)
  • 超时保护 - 5秒自动终止
  • 结果大小限制 - 防止内存溢出

🧪 开发

# 克隆仓库
git clone https://github.com/Cosmiumx/mcp-math-calculator.git
cd mcp-math-calculator

# 安装依赖
pnpm install

# 构建
pnpm build

# 运行测试
pnpm test

# 监听模式
pnpm watch

📊 测试覆盖

项目包含 37 个测试用例,覆盖:

  • ✅ 基础算术运算
  • ✅ 浮点数精度问题
  • ✅ 复杂表达式计算
  • ✅ 科学函数
  • ✅ 数学常数
  • ✅ 大数运算
  • ✅ 错误处理
  • ✅ 安全性验证
  • ✅ 精度控制

🤝 贡献

欢迎贡献!请随时提交 Issue 或 Pull Request。

  1. Fork 本仓库
  2. 创建你的特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交你的改动 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 开启一个 Pull Request

📝 License

MIT License - 详见 LICENSE 文件

🐛 问题反馈

遇到问题?请在 中报告。

📚 相关资源

⭐ Star History

如果这个项目对你有帮助,请给它一个 ⭐️!


Made with ❤️ by Cosmiumx

目录标签

目录标签

TypeScriptClaude搜索research-and-datamathgptmath-solvermath-assistant精确计算本地部署大数运算科学函数AI辅助工具数学解析

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

mcp-math-calculator

工具数量(toolCount,工具数)

1

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP