Labsco
MCP SERVER

Calculator MCP

by cyanheads

One tool: evaluate an expression, simplify it symbolically, or take its derivative.

Time, Dates & CalculationVerified
Summary
One tool, and the interesting work is in what it refuses to run.

Handing a model a general expression evaluator is the sort of thing that goes wrong quietly, so this one strips the dangerous functions out of math.js, runs what is left inside vm.runInNewContext() with a timeout, and bounds both directions: expression length, separators, numeric-only scope values with prototype-pollution keys blocked, result type and result size. That containment is why it needs no credentials — nothing is stateful and nothing can write. The practical reason to add it is narrower than "a calculator": symbolic simplification and derivatives are exactly the arithmetic a language model gets subtly wrong on its own.

What it is

A single-tool math server. calculate evaluates arithmetic, trigonometry, logarithms, statistics, matrices, complex numbers, unit conversions and combinatorics, simplifies algebraic and trigonometric expressions, and computes symbolic derivatives. It runs over stdio or Streamable HTTP, and a public instance at https://calculator.caseyjhand.com/mcp means you need not run anything at all.

What you get
  • calculate takes one expression per call, with operation defaulting to evaluate, so the ordinary case is just { expression: "..." }
  • Simplify reduces algebraically — 2x + 3x becomes 5 * x — and handles trigonometric identities as well
  • Derivative is symbolic: 3x^2 + 2x + 1 comes back as 6 * x + 2
  • A scope parameter supplies variable values such as { "x": 5, "y": 3 }, and the precision of numeric results is configurable
  • Evaluation runs on a hardened math.js v15 instance with dangerous functions disabled, sandboxed through vm.runInNewContext() with a timeout
  • Both ends are bounded: expression length limits, semicolons and newlines rejected as separators, numeric-only scope values with prototype-pollution keys blocked, and blocked result types with a maximum result size
  • Blank optional variable and precision values sent by form-based clients are treated as omitted rather than as errors
Requirements

No authentication and no state — every operation reads. Run it as bunx @cyanheads/calculator-mcp-server@latest, as npx -y @cyanheads/calculator-mcp-server@latest if you would rather not install Bun, from the Docker image, or point a client at https://calculator.caseyjhand.com/mcp over Streamable HTTP. Building from source wants Bun v1.3.0 or newer. The limits are tunable: CALC_MAX_EXPRESSION_LENGTH defaults to 1000 within a 10 to 10,000 range, CALC_EVALUATION_TIMEOUT_MS to 5000 within 100 to 30,000, and CALC_MAX_RESULT_LENGTH to 100000. In HTTP mode MCP_HTTP_PORT defaults to 3010, MCP_HTTP_ENDPOINT_PATH to /mcp, and MCP_AUTH_MODE to none with jwt and oauth available. Apache-2.0.

Setup effort

One command — npx -y @cyanheads/calculator-mcp-server@latest