
Calculator Mcp Server
io.github.cyanheadsv0.5.0更新於 Oct 8, 2026
Evaluate, simplify, and differentiate mathematical expressions.
概覽
讓助理對數學運算式求值、化簡與微分,支援矩陣、複數、單位和精確分數。
- 功能
- 只有一個 calculate 工具,提供三種操作:evaluate(預設)、simplify 和 derivative,微分需要指定變數名稱。它支援算術、三角函數、對數、統計、矩陣、複數、單位和組合數學,並可透過 scope 傳入數值變數,例如 x 等於 5。數值型別可選 number、BigNumber(64 位有效數字)或 Fraction(精確有理數),精度可設為 1 到 16 位有效數字。calculator://help 資源提供靜態語法參考。
- 適用情境
- 適合助理需要可靠數值或符號運算、而不是憑推測做算術的情境:核對計算結果、化簡代數式或求符號導數。公開託管端點無需安裝,也適合快速試用。
- 執行需求
- 可以使用公開託管的 Streamable HTTP 端點,也可以用 bunx、npx 或 Docker 在本機執行。README 將 Bun v1.4.0 或更高版本列為本機建置的前提。選用環境變數可調整限制與傳輸方式,包括 CALC_MAX_EXPRESSION_LENGTH、CALC_EVALUATION_TIMEOUT_MS、CALC_MAX_RESULT_LENGTH、MCP_TRANSPORT_TYPE、MCP_HTTP_HOST、MCP_HTTP_PORT、MCP_HTTP_ENDPOINT_PATH、MCP_AUTH_MODE 和 MCP_LOG_LEVEL。未宣告需要身分驗證。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Calculator Mcp Server,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Web executable,透過 Streamable HTTP。 遠端服務在工作區中設定後即可從網頁執行環境執行。
其他 MCP 客戶端
把它新增到你客戶端的 mcpServers 設定中。
{
"mcpServers": {
"calculator-mcp-server": {
"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.
Public Hosted Server: https://calculator.caseyjhand.com/mcp
Overview
Calculator powered by math.js. Verify numeric results, simplify algebraic expressions, and compute symbolic derivatives through one tool. Runs as a stdio process, a local Streamable HTTP server, or the public hosted endpoint above.
Tools
Resources
Capability reference
calculate tool
- One
expressionper call.operationselectsevaluate(default),simplify, orderivative; derivatives requirevariable(e.g."x"). - Evaluate arithmetic, trigonometry, logarithms, statistics, matrices, complex numbers, units, and combinatorics; assign numeric variables through
scope, e.g.{ "x": 5 }. numericTypeselectsnumber,BigNumber(64 significant digits, for values that overflow a 64-bit float), orFraction(exact rationals). Fraction mode returnsfraction_unsupported, with guidance to change numeric type, when a result has no exact rational value (sqrt(2)), the expression calls a function Fraction mode cannot compute (sqrt(4),5!), or it uses a value Fraction mode holds only as a rounded float (pi,2^(1/2)).precisionsets 1–16 significant digits for numeric results. Blank optionalvariableandprecisionvalues are treated as omitted; scope and precision do not affect symbolic operations.- Simplification includes algebraic and trigonometric identities (
2x + 3x→5 * x);unchanged: trueidentifies expressions the simplifier cannot reduce, including polynomial factoring and rational cancellation cases. - Returns the result string, result type, original expression, and operation. Validation failures include typed reasons and recovery hints.
calculator://help resource
- Markdown reference for functions, operators, constants, units, and expression syntax; no parameters.
- Examples cover scope, matrices, complex numbers, precision, 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
vmtimeout - No auth required — all operations are read-only and stateless
- Input validation: expression length limits and rejection of multiple statements; matrix row separators and string contents remain valid
- Result validation: blocked result types (functions, parsers, result sets), configurable max result size
- Size limits: functions that build a matrix or string from a size, product, broadcast, index, or precision argument are capped per call, and each evaluation has a total element budget; oversized requests fail fast with
result_too_large - 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: trueonsimplifyflags 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
Public Hosted Instance
A public instance is available at https://calculator.caseyjhand.com/mcp — no installation required. Point any MCP client at it via Streamable HTTP:
Self-Hosted / Local
Add one of the following to your MCP client configuration file:
Or with npx (no Bun required):
Or with Docker:
For Streamable HTTP, set the transport and start the built server:
Prerequisites
- Bun v1.4.0 or higher
Installation
- Clone the repository:
- Navigate into the directory:
- Install dependencies:
Configuration
See .env.example for optional session, resumability, logging, and telemetry settings.
Running the server
Local development
-
Build and run the production version:
-
Run checks and tests:
Docker
The image defaults to Streamable HTTP on port 3010, stateless sessions, and logs at /var/log/calculator-mcp-server. OpenTelemetry dependencies are installed by default; build with --build-arg OTEL_ENABLED=false to omit them.
Project structure
Development guide
See AGENTS.md or CLAUDE.md for development guidelines and architectural rules. The short version:
- Handlers throw, framework catches — no
try/catchin tool logic - Use
ctx.logfor logging - Register new tools and resources in
src/index.ts
Contributing
Issues are welcome. Run checks before submitting:
License
Apache-2.0 — see LICENSE for details.
來源:README.md,提交 752849e
工具
0版本歷史
3- v0.5.0最新Sep 25, 2026
- v0.4.3Sep 19, 2026
- v0.4.2Sep 16, 2026

