MCP server for precise mathematical calculations

MCP server for precise mathematical calculations

mcp-math-calculator•bycosmiumx

An MCP server that lets AI clients perform exact arithmetic and scientific math evaluations through a single calculate tool.

License: MIT•Runtime: Awaiting documentation review•Category: developer tools

WHAT IT DOES

  • •Provides a calculate tool that evaluates the given mathematical expression.
  • •Supports an optional precision setting between 1 and 64 decimal places, defaulting to 15.
  • •Offers scientific functions, trigonometric functions, logarithms, and constants like pi and e.
  • •Avoids floating-point errors such as 0.1 + 0.2 and handles numbers beyond JavaScript's safe integer range.

BEST FOR

  • •Getting exact decimal results for otherwise error-prone floating-point arithmetic.
  • •Evaluating multi-step expressions involving parentheses and operator precedence.
  • •Computing scientific expressions such as square roots, powers, and trigonometric values.

ABOUT MCP-MATH-CALCULATOR

MCP server for precise mathematical calculations is cataloged as an MCP server attributed to cosmiumx. An MCP server that lets AI clients perform exact arithmetic and scientific math evaluations through a single calculate tool. It is categorized under developer tools. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for MCP server for precise mathematical calculations are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

How does the server avoid security risks during calculation?

It avoids eval, uses the mathjs safe parser with a sandbox and function whitelist, rejects dangerous patterns, and enforces a 5-second timeout.

Can it handle numbers larger than JavaScript's safe integer range?

Yes, it includes big-number support, with examples such as 999999999999999999 + 1 returning 1000000000000000000.

上游原版 README

在 GitHub 查看同一版本原文

README.md · 414fc61154ed · 采集于 2026-11-13 11:20:05 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

mcp-math-calculator

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

npm version License: 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 文件

🐛 问题反馈

遇到问题?请在 GitHub Issues 中报告。

📚 相关资源

⭐ Star History

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


Made with ❤️ by Cosmiumx

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for MCP server for precise mathematical calculations from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/mcp-math-calculator)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related developer tools MCP Servers

Alternative and complementary servers in the same category

View all in developer tools →
Postbye
postbye-mcp•postbye-team

A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools
Singapore Proxy MCP
singapore-proxy-mcp•Xavierfok

A hosted MCP service for browsing and searching through Singapore mobile-network proxies.

0
Developer Tools

A directory listing describing a Markdown-to-PDF service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools