A hardened math.js wrapper that gives Claude a single `calculate` tool for evaluation, symbolic simplification, and derivatives. Handles arithmetic, trig, matrices, unit conversion, and more with configurable precision and variable scoping. Built with sandbox isolation (disabled dangerous functions, vm context with timeout, input validation blocking semicolons and prototype pollution). Ships as both stdio and streamable HTTP with a public hosted instance at calculator.caseyjhand.com, so you can point Claude at it without installing anything. Reach for this when you need Claude to crunch numbers, simplify algebraic expressions, or compute symbolic derivatives without writing your own math service.
Public tool metadata for what this MCP can expose to an agent.
calculateEvaluate math expressions, simplify algebraic expressions, or compute symbolic derivatives. Supports arithmetic, trigonometry, statistics, matrices, complex numbers, units, and combinatorics.5 paramsEvaluate math expressions, simplify algebraic expressions, or compute symbolic derivatives. Supports arithmetic, trigonometry, statistics, matrices, complex numbers, units, and combinatorics.
scopeobjectvariablevalueoperationstringevaluate · simplify · derivativedefault: evaluateprecisionvalueexpressionstringEvaluate, simplify, and differentiate mathematical expressions via MCP. STDIO or Streamable HTTP.
Public Hosted Server: https://calculator.caseyjhand.com/mcp
One tool for all mathematical operations:
| Tool Name | Description |
|---|---|
calculate | Evaluate math expressions, simplify algebraic expressions, or compute symbolic derivatives. |
calculateA single tool covering 100% of the server's purpose. The operation parameter defaults to evaluate, so the common case is just { expression: "..." }.
2x + 3x -> 5 * x). Supports algebraic and trigonometric identities3x^2 + 2x + 1 -> 6 * x + 2)scope parameter: { "x": 5, "y": 3 }variable and precision values from form-based MCP clients are treated as omitted| URI Pattern | Description |
|---|---|
calculator://help | Available functions, operators, constants, and syntax reference. |
Built on @cyanheads/mcp-ts-core:
Calculator-specific:
vm.runInNewContext() with timeout__proto__, constructor, etc.)A public instance is available at https://calculator.caseyjhand.com/mcp — no installation required. Point any MCP client at it via Streamable HTTP:
{
"mcpServers": {
"calculator-mcp-server": {
"type": "streamable-http",
"url": "https://calculator.caseyjhand.com/mcp"
}
}
}
Add to your MCP client config (e.g., claude_desktop_config.json):
{
"mcpServers": {
"calculator-mcp-server": {
"type": "stdio",
"command": "bunx",
"args": ["@cyanheads/calculator-mcp-server@latest"]
}
}
}
git clone https://github.com/cyanheads/calculator-mcp-server.git
cd calculator-mcp-server
bun install
| Variable | Description | Default |
|---|---|---|
CALC_MAX_EXPRESSION_LENGTH | Maximum allowed expression string length (10–10,000). | 1000 |
CALC_EVALUATION_TIMEOUT_MS | Maximum evaluation time in milliseconds (100–30,000). | 5000 |
CALC_MAX_RESULT_LENGTH | Maximum result string length in characters (1,000–1,000,000). | 100000 |
MCP_TRANSPORT_TYPE | Transport: stdio or http. | stdio |
MCP_HTTP_PORT | Port for HTTP server. | 3010 |
MCP_AUTH_MODE | Auth mode: none, jwt, or oauth. | none |
MCP_LOG_LEVEL | Log level (RFC 5424). | info |
Build and run the production version:
bun run build
bun run start:http # or start:stdio
Run checks and tests:
bun run devcheck # Lints, formats, type-checks
bun run test # Runs test suite
docker build -t calculator-mcp-server .
docker run -p 3010:3010 calculator-mcp-server
| Directory | Purpose |
|---|---|
src/mcp-server/tools/ | Tool definitions (*.tool.ts). |
src/mcp-server/resources/ | Resource definitions (*.resource.ts). |
src/services/ | Domain service integrations (MathService). |
src/config/ | Environment variable parsing and validation with Zod. |
docs/ | Generated directory tree. |
See AGENTS.md or CLAUDE.md for development guidelines and architectural rules. The short version:
try/catch in tool logicctx.log for loggingsrc/index.tsIssues and pull requests are welcome. Run checks before submitting:
bun run devcheck
bun run test
Apache-2.0 — see LICENSE for details.
CALC_MAX_EXPRESSION_LENGTHdefault: 1000Maximum allowed expression string length.
CALC_EVALUATION_TIMEOUT_MSdefault: 5000Maximum evaluation time in milliseconds.
CALC_MAX_RESULT_LENGTHdefault: 100000Maximum result string length in characters.
MCP_LOG_LEVELdefault: infoSets the minimum log level for output (e.g., 'debug', 'info', 'warn').
MCP_HTTP_HOSTdefault: 127.0.0.1The hostname for the HTTP server.
MCP_HTTP_PORTdefault: 3010The port to run the HTTP server on.
MCP_HTTP_ENDPOINT_PATHdefault: /mcpThe endpoint path for the MCP server.
MCP_AUTH_MODEdefault: noneAuthentication mode to use: 'none', 'jwt', or 'oauth'.