Cruncher MCP
About
The Scientific Calculator built as a Model Context Protocol (MCP) server
Details
- Author
- islobodan
- Categories
- Productivity, Other
Jump to
Setup
Install Cruncher MCP in your MCP client (Claude Desktop, Cursor, Windsurf, and others).
Repository: https://github.com/islobodan/cruncher-mcp
Follow the installation instructions in the repository README, then restart your MCP client.
Cruncher: The Scientific Calculator MCP Server
A powerful scientific calculator for your AI assistant, built as aModel 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 (nomathjs, nozod, no@modelcontextprotocol/sdk). Everything is handled using native Node.js capabilities:
- Safe Expression Evaluation: Instead of relying onmathjsor 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.jsworker_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 usingdecimal.js, it solves the classic JS math error (0.1 + 0.2 = 0.30000000000000004) via dynamic integer-scaling logic under the hood.
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 throughcruncher.jsprovides unparalleled, transparent insight into exactly how an MCP server communicates overstdio, parses incoming requests (initialize,tools/list,tools/call), and responds back to the AI client-demystifying the "magic" that SDKs usually hide away.
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.
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.jsworker_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).
Get Cruncher up and running with Claude Desktop in just a few minutes.
Ensure you haveNode.js(version 18.0.0 or newer) installed on your system. You can download it fromnodejs.org.
Recommended: Install via npm and use directly:
This downloads and runs the latest version automatically.
Recommended: Use the npm package for automatic updates:
{ "mcpServers": { "cruncher": { "command": "npx", "args": ["-y", "@slbdn/cruncher-mcp"] } } }
If you prefer to download the file manually instead:
-
Download thecruncher.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
Add the server configuration pointing to your downloaded file:
{ "mcpServers": { "cruncher": { "command": "node", "args": ["C:/Users/YOUR_USERNAME/mcp-servers/cruncher.js"], "env": { "CRUNCHER_TOOL_SET": "standard" } } } }
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.
- Savethe configuration file andcompletely quitthe Claude Desktop app.
- Restart Claude Desktop. It will automatically connect to the Cruncher server.
- Start asking questions!
OpenWebUI natively supports connecting tostdioMCP servers.
- Go toAdmin Panel>Settings>Tools>MCP Servers.
- ClickAdd Server.
- Name it "Cruncher", selectCommandand enternpx, set Args to@slbdn/cruncher-mcp.
- Go toAdmin Panel>Settings>Tools>MCP Servers.
- ClickAdd Server.
- Name it "Cruncher", selectstdio, usenodeas the command, and/path/to/cruncher.jsas the argument.
You can give Cursor's built-in AI the ability to run math and calculate hashes.
- Open Cursor Settings (gear icon) >Features>MCP Servers.
- Click+ Add New MCP Server.
- Set Type tocommand, Name tocruncher, and Command tonpx @slbdn/cruncher-mcp.
- Open Cursor Settings (gear icon) >Features>MCP Servers.
- Click+ Add New MCP Server.
- Set Type tocommand, Name tocruncher, and Command tonode /path/to/cruncher.js.
If you use Cline for agentic coding in VS Code, open the MCP configuration file (cline_mcp_settings.json) and add:
{ "mcpServers": { "cruncher": { "command": "npx", "args": ["-y", "@slbdn/cruncher-mcp"] } } }
{ "mcpServers": { "cruncher": { "command": "node", "args": ["/path/to/cruncher.js"], "env": { "CRUNCHER_TOOL_SET": "standard" } } } }
Goose is a lightweight, terminal‑based AI assistant that fully supports MCP.
- Edit~/.goose/config.yaml(or the local project config).
- Add a new server entry:
mcpServers: cruncher: command: npx args: - -y - "@slbdn/cruncher-mcp"
- Edit~/.goose/config.yaml(or the local project config).
- Add a new server entry:
mcpServers: cruncher: command: node args: - "/path/to/cruncher.js" env: CRUNCHER_TOOL_SET: "standard"
- Restart Goose. You can now ask Goose to run calculations likeevaluate_expressionormediandirectly.
Zed's built‑in AI pane supports MCP connections.
- OpenSettings → AI → MCP Servers.
- ClickAdd Serverand fill in:
- Name:cruncher
- Command:npx
- Args:@slbdn/cruncher-mcp
- OpenSettings → AI → MCP Servers.
- ClickAdd Serverand fill in:
- Name:cruncher
- Command:node
- Args:/absolute/path/to/cruncher.js
- Env(optional):CRUNCHER_TOOL_SET=standard
LM Studio runs LLMs entirely offline and now includes an MCP client.
- OpenSettings → MCPin LM Studio.
- ClickAdd Serverand provide:
- Executable:npx
- Arguments:@slbdn/cruncher-mcp
- OpenSettings → MCPin LM Studio.
- ClickAdd Serverand provide:
- Executable:node
- Arguments:/absolute/path/to/cruncher.js
- Environment(optional):CRUNCHER_TOOL_SET=standard
If you're using LibreChat, you can add the following configuration to your librechat.yaml file:
cruncher: type: stdio command: npx args: - -y - "@slbdn/cruncher-mcp"
cruncher: type: stdio command: node args: - "/opt/mcp/cruncher.js" env: CRUNCHER_TIMEOUT: "5000"
"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]?"
"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)"
Full Tier Examples(withCRUNCHER_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."
Cruncher exposes its functions as individual MCP tools. Here is the full list:
Cruncher exposes3 tiersvia theCRUNCHER_TOOL_SETenvironment variable. Each tier is a strict superset of the one before it.
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)
If the LLM calls a tool that doesn't exist, Cruncher usesLevenshtein distanceto find the closest match and suggests it:
{ "error": { "code": -32601, "message": "Tool 'fact' not found. Did you mean 'factorial'?" } }
Beyond basic arithmetic,evaluate_expressionsupports these functions natively:
Combine freely:sin(pi/6) + sqrt(16) + log10(100) = 6.5
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]"
You can now use mathematical and physical constant names directly insideevaluate_expression:
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.




