calculator-mcp-server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
@retiform/calculator-mcp-server
A scientific calculator MCP tool server for AI agents — safe expression evaluation, symbolic calculus (derivatives, simplification, equation solving, integration), statistics, and matrix operations, over the Model Context Protocol.
Stateless pure math. The agent is the brain; the server is the calculator.
Tools (13)
Tool | What it does | Example |
| Safe expression evaluation |
|
| Symbolic differentiation |
|
| Algebraic simplification |
|
| Equation solving |
|
| Definite integrals |
|
| Polynomial antiderivatives |
|
| Summary statistics | mean/median/mode/variance/quartiles |
| Pearson correlation |
|
| OLS linear regression | slope/intercept/r²/rmse |
| t-based CI for the mean | verified against R |
| Element-wise sum |
|
| Matrix product |
|
| Transpose | rows become columns |
Every tool description embeds worked examples — an LLM caller learns each tool from the tool itself.
Related MCP server: Math MCP Server
Highlights
Sandboxed by design. Expressions are parsed to ASTs and audited before evaluation: a symbol allowlist (namespace members + your scope variables), a host-global blocklist enforced in every mode, assignment rejection, and throwing stubs on
import/evaluate/createUnit. Escape-vector tests (constructor.constructor,import("fs"),process,globalThis) are first-class and must stay green.Exact where possible. Linear/quadratic equations are solved symbolically (rationals as fractions, complex pairs as
1 + 2i); polynomial definite integrals (degree ≤ 4) are exact via antiderivatives that are self-checked (dF/dx ≡ fverified before returning).Numeric where not. Transcendental equations: deterministic scan of [-100, 100] with bisection polish. General integrals: adaptive Simpson with an error estimate.
Statistics you can trust. The t-quantile (continued-fraction incomplete beta + Lanczos log-gamma) matches R's
qt()to 15 digits — verified in the test suite against reference values.JSON-native matrices. Plain nested arrays in, plain nested arrays out. No library types leak across the wire.
All transports. stdio (default for the bin entry), HTTP, and SSE — see Configuration.
Install
npm install @retiform/calculator-mcp-server
# or run directly:
npx -y @retiform/calculator-mcp-serverRequires Node.js ≥ 22.
Usage with MCP clients
stdio (Claude Desktop, most clients)
{
"mcpServers": {
"calculator": {
"command": "npx",
"args": ["-y", "@retiform/calculator-mcp-server"]
}
}
}HTTP / SSE
npx -y @retiform/calculator-mcp-server # stdio (bin default)
CALC_MCP_TRANSPORT=http npx -y @retiform/calculator-mcp-server # HTTP on 127.0.0.1:3778
CALC_MCP_TRANSPORT=sse npx -y @retiform/calculator-mcp-server # SSELibrary use:
import { createCalculatorMcpServer } from '@retiform/calculator-mcp-server'
const server = createCalculatorMcpServer({ transport: 'http', port: 3778, host: '127.0.0.1' })
await server.start()Configuration
Precedence: code defaults ← JSON5 config file ← environment variables.
Setting | Default | Config key | Env var |
Transport |
|
|
|
Port |
|
|
|
Host |
|
|
|
Config file path defaults to ./config.json5 (override with
CALC_MCP_CONFIG). See config.example.json5. An explicitly chosen
transport always wins over entry defaults.
Security notes
Expressions are untrusted input. The engine evaluates them in a sandboxed mathjs namespace with an audited AST pipeline — see
src/engine/evaluate.jsfor the threat model and defense layers.Scope values must be finite numbers; nothing else crosses the boundary.
DoS bounds: expression length ≤ 2000 chars, datasets ≤ 1M values, matrix dimensions ≤ 400×400.
Bind loopback-only deployments unless you explicitly need otherwise; layer firewall rules for anything network-reachable.
Development
npm install
npm test # vitest: 169 unit + e2e tests
npm run lint # eslint
npm run format:checkLicense
Sponsors
If calculator-mcp-server is useful to you, consider supporting its continued development:
Bitcoin:
bc1q0gd3mwjg3zy9sghv22kmpg823vss4c0zzdzg24Solana:
Eu8wQcW68TKMs1a6eqzZu8znzU52QLqQugAMG8uCD6y6Ethereum / EVM:
0x2733ff7c865C56d565a99BE1DC11B81cc76850A5XRP Ledger:
r4X6e7McAQj7e8vBCeued1RYu4mCJrREDG
Crafted with ❤️ by Retiform Labs
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Math.js MCP — wraps the mathjs.org API (free, no auth)
Scientific compute for AI agents: symbolic, numerical, quantum, chemistry, ODE. Paid via x402.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides a suite of deterministic math tools powered by SymPy to handle algebra, calculus, linear algebra, and statistics via the Model Context Protocol. It enables smaller language models to delegate complex computations to a verified symbolic backend for accurate and reliable results.Apache 2.0
- AlicenseAqualityDmaintenanceA Model Context Protocol server that exposes 8 mathematical tools (arithmetic, algebra, calculus, matrix operations, statistics, probability, unit conversions) to any MCP-compatible AI agent, enabling mathematical computations without code.811 npm1MIT
- AlicenseAqualityDmaintenanceA stdio MCP server that gives LLMs a safe scientific calculator with infix math, complex numbers, matrices, statistics, unit conversions, and more via tools that return JSON.331MIT
- AlicenseAqualityBmaintenanceEnables LLMs to perform deterministic arithmetic, high-precision decimal math, unit conversions, statistics, finance, matrix operations, complex-number calculations, numerical calculus, probability distributions, date math, and root solving through MCP tools. It supports both Streamable HTTP and stdio transport.1320 npmMIT