
Cruncher
io.github.islobodan由 GitHub 账号 islobodan 发布v1.2.29更新于 Oct 24, 2026
Scientific calculator MCP server with 43 tools: arithmetic, trig, stats, unit conversion.
概览
Cruncher 是一个本地科学计算器 MCP 服务器,让 AI 助手执行算术、三角函数、统计、单位换算和常量查询。
- 可以做什么
- 计算纯文本数学表达式,并完成加减乘除、幂、开方、阶乘和对数运算,数学与物理常量可直接在表达式中使用或通过工具查询。以角度或弧度进行三角函数与反三角函数计算,并可切换角度模式。对数字数组做统计:求和、平均值、中位数、最小值、最大值、极差、计数、方差、标准差、百分位数和百分比计算。在 8 个类别、80 多种单位之间换算,完整档位还支持 2、8、10、16 进制互转。完整档位下可使用计算器记忆、一次调用批量执行最多 50 个操作,以及查看或清空结果缓存。
- 适用场景
- 适合需要助手精确计算算术、统计或单位换算而不是估算的场景,例如多步数学运算、百分比变化或科学常量。分档工具集让你在简单计算时保持上下文精简,或在复杂流程中开放全部 43 个工具。
- 运行要求
- 以 npm 包形式通过 stdio 在本地运行,需要 Node.js 18 或更高版本。可选环境变量 CRUNCHER_TOOL_SET(minimal、standard 或 full,默认 standard)和 CRUNCHER_TIMEOUT(工作线程超时毫秒数,默认 3000)用于调整。无需账号、API 密钥或网络访问。
安装
在 SourceWeft 中
- 打开 控制台中的 Cruncher,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Cruncher: The Scientific Calculator MCP Server
[Version] [Node.js Version] [License: MIT] [Tests] [Status]
A powerful scientific calculator for your AI assistant, built as a Model Context Protocol (MCP) server. Cruncher allows compatible AI clients (like Claude Desktop) to perform complex mathematical calculations, handle memory, perform statistical analysis, and access scientific constants with a simple, secure, and standardized interface.
🌟 The Purity Promise (Zero Dependencies)
Cruncher is built as a highly educational, extremely lightweight tool. It accomplishes powerful features without pulling in any heavy external libraries (no mathjs, no zod, no @modelcontextprotocol/sdk). Everything is handled using native Node.js capabilities:
- Safe Expression Evaluation: Instead of relying on
mathjsor dangerouseval(), Cruncher usesnew Function()guarded by a strict whitelist Regex that guarantees only numbers and math operators can pass. - Input Validation: Instead of heavy schema libraries like Zod, a custom recursive validation function rigidly enforces AI inputs against JSON Schemas directly.
- Timeout Protection: Instead of complex process managers, it leverages Node.js
worker_threadsto spawn calculations. If an AI requests a multi-million loop factorial, the main thread easily terminates the worker after a strict timeout (default 3 seconds). This timeout is configurable via theCRUNCHER_TIMEOUTenvironment variable (in milliseconds), ensuring the server remains responsive even during heavy computational loads. - Floating-Point Accuracy: Instead of using
decimal.js, it solves the classic JS math error (0.1 + 0.2 = 0.30000000000000004) via dynamic integer-scaling logic under the hood.
📚 An Educational Approach to MCP
This project serves as an excellent learning resource for developers looking to understand the Model Context Protocol (MCP) deeply. Because it deliberately avoids using the official @modelcontextprotocol/sdk, the entire implementation of the MCP protocol, JSON-RPC message handling, input validations, and error formatting is exposed in plain JavaScript.
Reading through cruncher.js provides unparalleled, transparent insight into exactly how an MCP server communicates over stdio, parses incoming requests (initialize, tools/list, tools/call), and responds back to the AI client-demystifying the "magic" that SDKs usually hide away.
What is the Model Context Protocol?
The Model Context Protocol (MCP) is an open standard that allows AI applications to securely connect with external data sources and tools. Think of it as a universal API for AI. By implementing Cruncher as an MCP server, any AI that understands MCP can instantly gain powerful, built-in calculator capabilities without custom integrations.
✨ Features
Cruncher provides a comprehensive set of calculator functions built completely from scratch without heavy dependencies:
- Robust Architecture:
- Zero Dependencies: Relies purely on Node.js standard libraries.
- Strict Input Validation: Custom schema validator prevents AI hallucinations and invalid data.
- Infinite Loop Protection: Utilizes Node.js
worker_threadswith a 3-second strict timeout to prevent complex calculations from freezing the server. - Accurate Decimal Math: Uses an integer-scaling approach to prevent classic JS floating-point errors (e.g.,
0.1 + 0.2 === 0.3).
- Tiered Tool Exposure: Three tiers (
minimal,standarddefault,full) to optimize context token usage. - Basic Arithmetic: Addition, Subtraction, Multiplication, Division, Modulo.
- Expression Evaluation: Safely compute entire plain-text math strings (e.g.
(5 + 3) * 10 / 2). - Power & Roots: Exponentiation (
a^b), Square Root. - Number Theory: Factorial (n!).
- Trigonometry: Sine, Cosine, Tangent, Arcsine (
asin), Arccosine (acos), and Arctangent (atan) (with support for degrees and radians). - Logarithms: Base-10 Logarithm and Natural Logarithm (ln).
- Statistical Functions: Sum, Average, Median, Min, Max, Range, Count, Variance, and Standard Deviation for arrays of numbers.
- Percentage Functions: Percentage-of, percentage-change, and reverse-percentage calculations.
- Unit Conversion: 80+ conversions across 8 categories (length, weight, temperature, area, volume, time, speed, digital_storage).
- Convenience Functions: Absolute Value.
- Constants: Easy access to Math (
pi,e,tau,phi,sqrt2,euler_mascheroni), Physics (c,g,G,h,k,R), and Chemistry constants (NA,e_charge,m_e,m_p). - Memory Functions:
M+,M-,MR(Memory Recall), andMC(Memory Clear) - full tier only.
🚀 Installation & Usage
Get Cruncher up and running with Claude Desktop in just a few minutes.
Step 1: Prerequisites
Ensure you have Node.js (version 18.0.0 or newer) installed on your system. You can download it from nodejs.org.
Step 1: Quick Start with npm
Recommended: Install via npm and use directly:
This downloads and runs the latest version automatically.
Step 2: Configure Claude Desktop
Recommended: Use the npm package for automatic updates:
Step 3: Manual File (Alternative)
If you prefer to download the file manually instead:
-
Download the
cruncher.jsfile directly from GitHub. -
Place it in a permanent location (e.g.,
C:\mcp-servers\cruncher.jsor/home/user/mcp-servers/cruncher.js). -
Locate the Claude Desktop configuration file:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
-
Add the server configuration pointing to your downloaded file:
Note for macOS/Linux Users: Use a POSIX-style path, e.g.,
"/home/YOUR_USERNAME/mcp-servers/cruncher.js". Make sure yournodeexecutable is in your system's PATH.
Step 4: Start Calculating!
- Save the configuration file and completely quit the Claude Desktop app.
- Restart Claude Desktop. It will automatically connect to the Cruncher server.
- Start asking questions!
OpenWebUI (Formerly Ollama WebUI)
OpenWebUI natively supports connecting to stdio MCP servers.
Option A: Using npm package
- Go to Admin Panel > Settings > Tools > MCP Servers.
- Click Add Server.
- Name it "Cruncher", select Command and enter
npx, set Args to@slbdn/cruncher-mcp.
Option B: Using downloaded file
- Go to Admin Panel > Settings > Tools > MCP Servers.
- Click Add Server.
- Name it "Cruncher", select stdio, use
nodeas the command, and/path/to/cruncher.jsas the argument.
Cursor IDE
You can give Cursor's built-in AI the ability to run math and calculate hashes.
Option A: Using npm package
- Open Cursor Settings (gear icon) > Features > MCP Servers.
- Click + Add New MCP Server.
- Set Type to
command, Name tocruncher, and Command tonpx @slbdn/cruncher-mcp.
Option B: Using downloaded file
- Open Cursor Settings (gear icon) > Features > MCP Servers.
- Click + Add New MCP Server.
- Set Type to
command, Name tocruncher, and Command tonode /path/to/cruncher.js.
Cline (VS Code Extension)
If you use Cline for agentic coding in VS Code, open the MCP configuration file (cline_mcp_settings.json) and add:
Option A: Using npm package
Option B: Using downloaded file
Goose (Terminal Agent)
Goose is a lightweight, terminal‑based AI assistant that fully supports MCP.
Option A: Using npm package
- Edit
~/.goose/config.yaml(or the local project config). - Add a new server entry:
Option B: Using downloaded file
- Edit
~/.goose/config.yaml(or the local project config). - Add a new server entry:
- Restart Goose. You can now ask Goose to run calculations like
evaluate_expressionormediandirectly.
Zed Editor (AI Pane)
Zed's built‑in AI pane supports MCP connections.
Option A: Using npm package
- Open Settings → AI → MCP Servers.
- Click Add Server and fill in:
- Name:
cruncher - Command:
npx - Args:
@slbdn/cruncher-mcp
- Name:
- Save. The Zed AI can now call Cruncher for precise arithmetic and statistics.
Option B: Using downloaded file
- Open Settings → AI → MCP Servers.
- Click Add Server and fill in:
- Name:
cruncher - Command:
node - Args:
/absolute/path/to/cruncher.js - Env (optional):
CRUNCHER_TOOL_SET=standard
- Name:
- Save. The Zed AI can now call Cruncher for precise arithmetic and statistics.
LM Studio (Local LLM + MCP)
LM Studio runs LLMs entirely offline and now includes an MCP client.
Option A: Using npm package
- Open Settings → MCP in LM Studio.
- Click Add Server and provide:
- Executable:
npx - Arguments:
@slbdn/cruncher-mcp
- Executable:
- Confirm. Your private model can now offload math to Cruncher without any network traffic.
Option B: Using downloaded file
- Open Settings → MCP in LM Studio.
- Click Add Server and provide:
- Executable:
node - Arguments:
/absolute/path/to/cruncher.js - Environment (optional):
CRUNCHER_TOOL_SET=standard
- Executable:
- Confirm. Your private model (e.g., Llama 3, DeepSeek-V2) can now offload math to Cruncher without any network traffic.
LibreChat Configuration
If you're using LibreChat, you can add the following configuration to your librechat.yaml file:
Option A: Using npm package
Option B: Using downloaded file
Example Questions for Claude
"What is the angle in degrees whose sine is 0.5?"
"Calculate the average, median, and range of these numbers: [15, 22, 8, 41, 19, 30]"
"What is 2 raised to the power of 10?"
"What is the standard deviation of [10, 12, 8, 14, 6]?"
"What is 15% of 240?"
"A stock went from $50 to $75. What's the percentage change?"
"What is the variance of test scores [85, 92, 78, 90, 88]?"
"Calculate the range of values in [3, 7, 2, 9, 1]"
"Evaluate the expression: sin(pi/4) + sqrt(16) + log10(100)"
"What is 10 factorial?"
"What is 17 modulo 5?"
Full Tier Examples (with CRUNCHER_TOOL_SET=full):
"Store 99 in memory, add 5, then recall the total."
"What's the 75th percentile of [10, 20, 30, 40, 50]?"
"Convert 11010 from binary to decimal."
"Batch: square root of 144, add 10, then raise to power 2."
"Switch trigonometric functions to radians mode."
"Clear the result cache and show cache statistics."
"Recall what's in memory, then subtract 15 and store the result."
"What's the 95th percentile of [23, 45, 12, 67, 89, 34, 56, 78, 90, 11]?"
"Convert 0xFF from hex to binary."
📋 Available Tools
Cruncher exposes its functions as individual MCP tools. Here is the full list:
⚙️ Configuration
Environment Variables
Tool Tiers - Full Reference
Cruncher exposes 3 tiers via the CRUNCHER_TOOL_SET environment variable. Each tier is a strict superset of the one before it.
Tier Overview
Minimal Tier (5 Tools)
All tools run in the worker thread with timeout protection.
Standard Tier (34 Tools - includes all 5 Minimal)
Full Tier (43 Tools - includes all 34 Standard)
Fuzzy Tool Name Matching
If the LLM calls a tool that doesn't exist, Cruncher uses Levenshtein distance to find the closest match and suggests it:
Response format:
Extended evaluate_expression Built-ins
Beyond basic arithmetic, evaluate_expression supports these functions natively:
Combine freely: sin(pi/6) + sqrt(16) + log10(100) = 6.5
Improved Error Messages
Domain errors now tell you what went wrong:
sqrt(-1)→ "Check for: sqrt(negative), log(negative/zero), asin/acos out of [-1,1]"1/0→ "Check for division by zero or overflow"asin(5)→ "asin/acos out of [-1,1]"
Constants in Expressions
You can now use mathematical and physical constant names directly inside evaluate_expression:
Examples:
Rules:
- Use explicit operators:
2 * piworks,2pidoes not (no implicit multiplication) - Constants coexist with scientific notation:
1e6ande * 2both work correctly - Longest constant names match first:
euler_mascheroniwon't become299792458uler_mascheroni
Tiered Tool Exposure
The CRUNCHER_TOOL_SET environment variable lets you optimize context token usage by exposing only the tools you actually need:
Note: Even in minimal mode, evaluate_expression handles complex math - individual tools (sin, sqrt, etc.) just aren't registered as separate MCP tool calls. This saves up to 90% on context tokens.
Example MCP config (claude_desktop_config.json):
⛏️ How It Works (For Developers)
Cruncher is a plain Node.js JavaScript application that communicates over standard input/output (stdio). This makes it a lightweight, portable, and secure MCP server. The entire flow for a single tool call looks like this:
- Initialization: On startup, the server listens for an
initializerequest from the MCP client and responds with its capabilities and version info (v1.2.31). - Tool Discovery: The client sends a
tools/listrequest, and the server responds with the full list of available calculator tools and theirinputSchema, which defines the required arguments and their types. - Input Validation: Before any tool is executed, the server runs a custom recursive
validateArgumentsfunction against the tool'sinputSchema. This ensures required fields are present, types are correct (number, string, array), enum values are valid, and min/max constraints are respected - all without any external library. - Worker Thread Execution: Once validated, the tool call is handed off to an isolated Node.js
worker_thread. This completely protects the main thread (and itsstdiocommunication) from being blocked by a long-running or infinite calculation. - Timeout Protection: A configurable timer (
CRUNCHER_TIMEOUT, default 3000ms) watches the worker. If the worker takes too long, the main thread forcefully terminates it viaworker.terminate()and returns a-32000error to the AI client. - Safe Math & Result: The worker executes the handler function using
safeMath(integer-scaling) for decimal-safe arithmetic, then posts the result back to the main thread, which formats and writes the final JSON-RPC 2.0 response tostdout.
🤝 Contributing
Contributions are welcome! If you'd like to add a new function, fix a bug, or improve the documentation, please feel free to open an issue or submit a pull request.
📜 License
This project is licensed under the MIT License.
来源:README.md,提交 fbe5f6c
工具
0版本历史
1- v1.2.29最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分