Calculator MCP Server 🧮
About
Calculator MCP Server tool ;基于 Python AST 的安全表达式计算器 MCP 服务,支持基础数学运算和错误防护机制。
Details
- Author
- xiaoyingv
- GitHub stars
- 3
- Downloads
- 68
- Categories
- Other
Jump to
- Supports addition, subtraction, multiplication, division (+, -, , /)
- Supports exponentiation (*) and sign operations (+, -)
- Smart formatting: integers shown directly, decimals up to 15 significant digits, trailing zeros removed
- Safe evaluation via Python AST – no code injection risk
- Protection against division by zero, syntax errors, invalid power operations, and illegal operand types
Install the package via pip install mcp-calculate-server, then create a FastMCP server instance and run it on stdio transport using calculator.run(transport='stdio'). The server exposes a single tool perform_calculation that accepts a string expression and returns the formatted result or an error message.
Calculator MCP Server 🧮
基于 Python AST 的安全表达式计算器 MCP 服务,支持基础数学运算和错误防护机制。
功能特性
- ✅ 支持加减乘除四则运算(+, -, , /)
- ✅ 支持幂运算(*)
- ✅ 支持正负号处理(+5, -3)
- ✅ 智能格式化计算结果:
- 整数结果直接显示整数
- 小数结果保留最多15位有效数字
- 自动去除末尾多余的零
- ⚠️ 安全防护:
- 拦截代码注入风险(通过 AST 解析而非 eval)
- 除零错误防护
- 语法错误提示
- 类型安全检查
- 幂运算安全检查
安装方式
pip install mcp-calculate-server
快速使用
```python
from mcp.server.fastmcp import FastMCP
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



