
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 分