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 集成