Sponsored by Deepsite.site

Mcp Math Calculator

Created By
Cosmiumx25 days ago
精确数学计算的 MCP 服务器 - 为 AI 提供 100% 准确的数学计算能力
Content

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秒自动终止
  • 结果大小限制 - 防止内存溢出

Server Config

{
  "mcpServers": {
    "math-calculator": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-math-calculator"
      ]
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Playwright McpPlaywright MCP server
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Serper MCP ServerA Serper MCP Server
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
ChatWiseThe second fastest AI chatbot™
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
WindsurfThe new purpose-built IDE to harness magic
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Amap Maps高德地图官方 MCP Server
CursorThe AI Code Editor
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
DeepChatYour AI Partner on Desktop
Tavily Mcp