calculator-mcp-server
公共托管服务器: https://calculator.caseyjhand.com/mcp
工具
一个工具即可完成所有数学运算:
工具名称 | 描述 |
| 对数学表达式求值、化简代数表达式,或计算符号导数。 |
calculate
一个工具即可覆盖服务器的全部用途。operation 参数默认为 evaluate,因此常见用法只需 { expression: "..." }。
求值(Evaluate) — 算术、三角函数、对数、统计、矩阵、复数、单位换算、组合数学
化简(Simplify) — 以符号方式化简代数表达式(例如
2x + 3x->5 * x)。支持代数和三角恒等式求导(Derivative) — 计算符号导数(例如
3x^2 + 2x + 1->6 * x + 2)通过
scope参数设置变量作用域:{ "x": 5, "y": 3 }数值结果精度可配置
基于表单的 MCP 客户端传入的空白可选
variable和precision值将被视为未提供
Related MCP server: math-mcp
资源
URI 模式 | 描述 |
| 可用函数、运算符、常量和语法参考。 |
特性
基于 @cyanheads/mcp-ts-core 构建:
声明式工具定义 — 每个工具一个文件,框架负责注册和验证
所有工具统一错误处理
结构化日志,支持可选的 OpenTelemetry 追踪
本地运行(stdio/HTTP)或 Docker 运行
计算器专属特性:
加固的 math.js v15 实例 — 禁用危险函数,通过
vm.runInNewContext()在沙箱中求值并设置超时无需认证 — 所有操作均为只读且无状态
输入验证:表达式长度限制、拒绝表达式分隔符(分号和换行)、仅允许数值型作用域值
结果验证:阻止危险结果类型(函数、解析器、结果集),可配置最大结果大小
作用域净化:仅允许数值型值,防止原型污染(阻止
__proto__、constructor等)
快速开始
公共托管实例
公共实例位于 https://calculator.caseyjhand.com/mcp — 无需安装。通过 Streamable HTTP 将任意 MCP 客户端指向该地址:
{
"mcpServers": {
"calculator-mcp-server": {
"type": "streamable-http",
"url": "https://calculator.caseyjhand.com/mcp"
}
}
}自托管 / 本地
将以下配置之一添加到您的 MCP 客户端配置文件中:
{
"mcpServers": {
"calculator-mcp-server": {
"type": "stdio",
"command": "bunx",
"args": ["@cyanheads/calculator-mcp-server@latest"]
}
}
}或使用 npx(无需 Bun):
{
"mcpServers": {
"calculator-mcp-server": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@cyanheads/calculator-mcp-server@latest"]
}
}
}或使用 Docker:
{
"mcpServers": {
"calculator-mcp-server": {
"type": "stdio",
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "MCP_TRANSPORT_TYPE=stdio",
"ghcr.io/cyanheads/calculator-mcp-server:latest"
]
}
}
}前置要求
Bun v1.3.0 或更高版本
安装
克隆仓库:
git clone https://github.com/cyanheads/calculator-mcp-server.git进入目录:
cd calculator-mcp-server安装依赖:
bun install配置
变量 | 描述 | 默认值 |
| 允许的最大表达式字符串长度(10–10,000)。 |
|
| 最大求值时间(毫秒)(100–30,000)。 |
|
| 最大结果字符串长度(字符数)(1,000–1,000,000)。 |
|
| 传输方式: |
|
| HTTP 服务器的主机名。 |
|
| HTTP 服务器的端口。 |
|
| HTTP MCP 端点的路径。 |
|
| 最大入站 HTTP 请求大小; |
|
| 认证模式: |
|
| 日志级别(RFC 5424)。 |
|
有关可选的会话、可恢复性、日志和遥测设置,请参阅 .env.example。
运行服务器
本地开发
构建并运行生产版本:
bun run build bun run start:http # or start:stdio运行检查和测试:
bun run devcheck # Lints, formats, type-checks bun run test # Runs test suite
Docker
docker build -t calculator-mcp-server .
docker run -p 3010:3010 calculator-mcp-server该镜像默认以 Streamable HTTP 模式运行在端口 3010 上,使用无状态会话,日志输出到 /var/log/calculator-mcp-server。
项目结构
目录 | 用途 |
| 工具定义( |
| 资源定义( |
| 领域服务集成(MathService)。 |
| 使用 Zod 进行环境变量解析和验证。 |
| 生成的目录树。 |
开发指南
有关开发指南和架构规则,请参阅 AGENTS.md 或 CLAUDE.md。简要说明:
处理器抛出异常,框架负责捕获 — 工具逻辑中不使用
try/catch使用
ctx.log记录日志在
src/index.ts中注册新工具和资源
贡献
欢迎提交 Issue 和 Pull Request。提交前请先运行检查:
bun run devcheck
bun run test许可证
Apache-2.0 — 详情请参阅 LICENSE。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Math.js MCP — wraps the mathjs.org API (free, no auth)
Safe scientific calculator MCP for numeric expressions
Newton MCP — wraps the Newton math solver API (free, no auth)
Find and call the right MCP server for any task - pay per use, no install.
Related MCP Servers
- AlicenseBqualityAmaintenanceProvides secure mathematical computation capabilities including expression evaluation, symbolic math (derivatives, simplification), matrix operations, statistics, and unit conversion, with multi-tier acceleration through WebAssembly and WebWorkers for high-performance calculations.7178ISC
- AlicenseAqualityCmaintenanceA secure MCP server for evaluating mathematical expressions with grammar validation, function whitelisting, and sandboxed execution. It provides tools for expression evaluation, variable management, and resources for grammar and function documentation.637MIT
- AlicenseBqualityCmaintenanceHigh-precision mathematics server for MCP clients, providing exact integer arithmetic, symbolic derivatives, and numerical calculus via LaTeX-style input.672MIT
- AlicenseNot gradedqualityAmaintenanceProvides a token-efficient exact math engine for AI agents, enabling computation of derivatives, integrals, equations, and optimized Python/NumPy code via a single MCP tool.4MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/cyanheads/calculator-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server