Calculator Mcp Server

io.github.cyanheads由 GitHub 帳號 cyanheads 發布v0.6.0更新於 Nov 12, 2026

Evaluate, simplify, and differentiate mathematical expressions.

發布方自己的服務:Calculator Tools MCP

已驗證Streamable HTTP可網頁執行開發者工具資料與分析

概覽

AI 產生的概覽

以 math.js 為基礎的 MCP 伺服器,透過單一 calculate 工具讓助理求值、化簡與求導數學運算式,並支援矩陣、單位與日期。

可以做什麼
  • 對數值運算式求值,可帶入變數範圍並設定 1 至 16 位精度
  • 化簡代數運算式,並依指定變數計算符號導數
  • 處理矩陣、線性方程組、多項式根、複數、統計與組合數學
  • 進行單位換算、對加引號的 YYYY-MM-DD 日期做日期運算,以及數值定積分
  • 讀取說明資源,了解運算子、函式、限制與範例
適用情境
適合需要助理核對算術或數值結論、而不是憑猜測作答的情境,也適合涉及符號化簡、求導、單位換算、矩陣求解或日期差距的任務。對任何重視計算正確性的工作流程都是輕量的唯讀補充。
執行需求
可使用公開託管端點,或透過 npx 在本機執行(需 Node.js);原始碼建置需 Bun,也可使用 Docker 映像。不需帳號或 API 金鑰;選用環境變數可調整運算式長度、求值逾時、結果大小、傳輸方式、主機、連接埠、端點路徑、驗證模式與日誌等級。
安裝前請注意
所有操作皆為唯讀且無狀態,不索取任何憑證。結果取決於所給的運算式:simplify 可能原樣回傳,Fraction 模式對無理結果會失敗,浮點比較需使用容差。使用託管端點時運算式會傳送到第三方伺服器,請勿貼上機密數值。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Calculator Mcp Server,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Web executable,透過 Streamable HTTP。 遠端服務在工作區中設定後即可從網頁執行環境執行。

交給代理程式安裝

把這段提示詞貼上到 Claude Code、Codex、Cursor 等代理程式,或 SourceWeft 對話中。代理程式會讀取該伺服器的安裝指南,先向你展示發布者、端點和登入方式,經你同意後再把它新增到你的客戶端。金鑰不會寫進任何命令。

閱讀 https://sourceweft.com/mcp/io.github.cyanheads%2Fcalculator-mcp-server/install.md,並按其中說明把這個 MCP 伺服器接入我的客戶端。修改任何設定之前,先告訴我它的發布者、端點和登入方式,等我確認。不要把 API 金鑰寫進命令或我會提交的檔案;問我金鑰應從哪裡取得。

檢視代理程式所依據的安裝指南

其他 MCP 客戶端

把它新增到你客戶端的 mcpServers 設定中。

{
  "mcpServers": {
    "calculator": {
      "type": "http",
      "url": "https://calculator.caseyjhand.com/mcp"
    }
  }
}

README

@cyanheads/calculator-mcp-server

Evaluate, simplify, and differentiate mathematical expressions via MCP. STDIO or Streamable HTTP.

1 Tool • 1 Resource • 1 Skill


Overview

Calculator powered by math.js. Verify numeric results, simplify algebraic expressions, and compute symbolic derivatives through one tool.

Tools

ToolDescription
calculateEvaluate math expressions, simplify algebraic expressions, or compute symbolic derivatives.

Resources

ResourceDescription
calculator://helpAvailable functions, operators, constants, and syntax reference.

Skills

SkillDescription
calculator-guideWhich numericType answers which question, what a result does not prove (integer-looking floats, tolerance-based ==, lusolve on a singular matrix, a simplify that stops short of 0), and workflows for derivative checks, business-day deadlines, statistics by dimension, unit chains, and integral tails

The server serves it over MCP as skill://calculator-guide/SKILL.md; it also ships in skills/ in the npm package and Docker image.

Capability reference

calculate tool

  • One expression per call, up to 4,000 characters by default. operation selects evaluate (default), simplify, or derivative (requires variable, e.g. "x"); scope assigns numeric variables ({ "x": 5 }) and precision sets 1–16 significant digits, both for evaluate only.
  • Covers arithmetic, trigonometry, logarithms, statistics, matrices and linear systems (lusolve), polynomial roots (polynomialRoot), complex numbers, units, combinatorics, dates as quoted YYYY-MM-DD strings (dateDiff, dateAdd, weekday, isoWeek, daysInMonth), and numeric definite integrals (integrate(f, x, a, b)). Accepts **, ×, ÷, −, and ° (°C, °F) as math.js operators in every operation; × and ** take scalar operands.
  • numericType selects number, BigNumber (64 significant digits, for values that overflow a 64-bit float), or Fraction (exact rationals, including integer combinatorics and rational roots: 5! → 120/1). Fraction mode returns fraction_unsupported when a result has no exact rational value (sqrt(2), 2^(1/2)), the expression calls a function Fraction mode cannot compute (log2(8), stirlingS2(5, 2)), or it uses a value Fraction mode holds only as a rounded float (pi, random()).
  • Returns the result string, result type, original expression, and operation; simplify sets unchanged: true when it cannot reduce the expression (it does no polynomial factoring or rational cancellation). Failures carry a typed reason and a recovery hint.

calculator://help resource

  • Markdown reference for functions, operators, constants, units, limits, and expression syntax; no parameters.
  • Worked examples cover scope, matrices, polynomial roots, dates, integrals, complex numbers, precision, each numericType, and all three operations.
  • Cacheable for 24 hours with public scope (cacheHint) — static content that never changes at runtime.

Features

Built on @cyanheads/mcp-ts-core: stdio and Streamable HTTP transports, pluggable auth (none / jwt / oauth), swappable storage (in-memory, filesystem, Supabase, Cloudflare KV/R2/D1), structured logging with optional OpenTelemetry tracing.

Calculator-specific:

  • Hardened math.js v15 instance — dangerous functions disabled, evaluation run under a vm timeout
  • No auth required — all operations are read-only and stateless, and nothing reads a clock (now() and today() are rejected; pass dates as strings)
  • Input validation: expression length limits and rejection of multiple statements; matrix row separators and string contents remain valid; nesting past the call stack fails with expression_too_deep
  • Result validation: blocked result types (functions, parsers, result sets), configurable max result size
  • Size limits: functions that build a matrix, range, or string from a size, product, broadcast, index, or precision argument are capped per call, stirlingS2, bellNumbers, and bernoulli bound their arguments, and each evaluation has a total element budget; oversized requests fail fast with result_too_large. integrate() uses at most 500 subintervals per call
  • Scope sanitization: numeric-only values, prototype pollution prevention (blocked __proto__, constructor, etc.)

Agent-friendly output:

  • Effective-call echo — every response echoes the expression and operation, plus which scope variables and what precision were applied, so agents can verify what was actually computed
  • Discriminated output contracts — unchanged: true on simplify flags a no-op result instead of silently returning the same expression
  • Typed error reasons — validation and evaluation failures carry a typed reason (e.g. fraction_unsupported, evaluation_timeout, disallowed_result_type) plus an actionable recovery hint, rather than a raw exception

Getting started

Connect to the hosted instance, no install:

sh
claude mcp add --transport http calculator-mcp-server https://calculator.caseyjhand.com/mcp

Or run it locally:

sh
claude mcp add calculator-mcp-server -- npx -y @cyanheads/calculator-mcp-server

For other clients, add this to the MCP config file:

json
{  "mcpServers": {    "calculator-mcp-server": {      "command": "npx",      "args": ["-y", "@cyanheads/calculator-mcp-server"]    }  }}

For Docker or a source build, see Running the server.

Configuration

VariableDescriptionDefault
CALC_MAX_EXPRESSION_LENGTHMaximum allowed expression string length (10–10,000).4000
CALC_EVALUATION_TIMEOUT_MSMaximum evaluation time in milliseconds (100–30,000).5000
CALC_MAX_RESULT_LENGTHMaximum result string length in characters (1,000–1,000,000).100000
MCP_TRANSPORT_TYPETransport: stdio or http.stdio
MCP_HTTP_HOSTHostname for the HTTP server.127.0.0.1
MCP_HTTP_PORTPort for HTTP server.3010
MCP_HTTP_ENDPOINT_PATHPath for the HTTP MCP endpoint./mcp
MCP_HTTP_MAX_BODY_BYTESMaximum inbound HTTP request size; 0 disables the limit.1048576
MCP_AUTH_MODEAuth mode: none, jwt, or oauth.none
MCP_SESSION_MODEauto, stateful, or stateless. The server declares stateless in code, so every launch path resolves the same way; setting this overrides that declaration.stateless
MCP_LOG_LEVELLog level (RFC 5424).info

See .env.example for optional session, resumability, logging, and telemetry settings.

Running the server

Local development

Requires Bun v1.4.4 or higher. The built server also runs on Node.js v24+.

  • Clone and install:

    sh
    git clone https://github.com/cyanheads/calculator-mcp-server.gitcd calculator-mcp-server && bun installcp .env.example .env
  • Build and run the production version:

    sh
    bun run buildbun run start:http   # or start:stdio
  • Run checks and tests:

    sh
    bun run devcheck     # Lints, formats, type-checksbun run test         # Runs test suite

Docker

sh
docker run --rm -p 3010:3010 ghcr.io/cyanheads/calculator-mcp-server:latest

The image defaults to Streamable HTTP on port 3010, stateless sessions, and logs at /var/log/calculator-mcp-server. For stdio, use docker run -i --rm -e MCP_TRANSPORT_TYPE=stdio ghcr.io/cyanheads/calculator-mcp-server:latest. To build locally, run docker build -t calculator-mcp-server .; OpenTelemetry dependencies are installed by default, and --build-arg OTEL_ENABLED=false omits them.

Project structure

DirectoryPurpose
src/mcp-server/tools/Tool definitions (*.tool.ts).
src/mcp-server/resources/Resource definitions (*.resource.ts).
src/services/Domain service integrations (MathService).
skills/Published skills, served over MCP and shipped in the package.
src/config/Environment variable parsing and validation with Zod.
docs/Generated directory tree.
tests/Calculation, configuration, and response-contract tests.

Development guide

See AGENTS.md or CLAUDE.md for development guidelines and architectural rules. The short version:

  • Handlers throw, framework catches — no try/catch in tool logic
  • Use ctx.log for logging
  • Register new tools and resources in src/index.ts

Contributing

Issues are welcome. Run checks before submitting:

sh
bun run devcheckbun run test

License

Apache-2.0 — see LICENSE for details.

來源:README.md,提交 7994e70

工具

1

calculate

Calculate

Evaluate math expressions, simplify algebraic expressions, or compute symbolic derivatives. One expression per call. Supports arithmetic, trigonometry, statistics, matrices, linear systems, polynomial roots, complex numbers, units, combinatorics, calendar dates (quoted YYYY-MM-DD strings), and numeric definite integrals.

輸入參數scopevariableoperationprecisionexpression必填numericType

版本歷史

7
  1. v0.6.0最新Nov 12, 2026
  2. v0.5.3Oct 29, 2026
  3. v0.5.2Oct 25, 2026
  4. v0.5.1Oct 8, 2026
  5. v0.5.0Sep 25, 2026
  6. v0.4.3Sep 19, 2026
  7. v0.4.2Sep 16, 2026

評分

已滿足適用檢查項的 100%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通必需25 分
  • 已宣告認證方式必需10 分
  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

其他 Calculator 整合