MCP.so
登录

Calculator MCP Server 🧮

@xiaoyingv

关于 Calculator MCP Server 🧮

Calculator MCP Server tool ;基于 Python AST 的安全表达式计算器 MCP 服务,支持基础数学运算和错误防护机制。

基本信息

分类

其他

许可证

MIT

运行时

html

传输方式

stdio

发布者

xiaoyingv

配置

暂无标准配置

该服务器的 README 中没有可解析的 MCP 配置块,请前往代码仓库查看安装说明。

代码仓库

工具

未检测到工具

工具是从 README 中自动提取的。维护者可以在 ## Tools 标题下列出工具,即可填充这部分内容。

概览

What is Calculator MCP Server 🧮?

Calculator MCP Server 🧮 is a Python-based MCP service that evaluates mathematical expressions safely using Python AST parsing instead of eval. It supports basic arithmetic operations, power operations, and sign handling, with built-in error protection against code injection, division by zero, and invalid expressions.

How to use Calculator MCP Server 🧮?

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.

Key features of Calculator MCP Server 🧮

  • 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

Use cases of Calculator MCP Server 🧮

  • Performing safe arithmetic calculations within MCP-based applications
  • Evaluating user-supplied expressions without risk of code injection
  • Integrating math operations into AI assistants or automation tools
  • Providing formatted calculation results with clear error messages

FAQ from Calculator MCP Server 🧮

What Python version is required?

Python 3.13 or higher is required, along with the mcp-server library which is installed automatically.

How does it ensure safety?

It parses expressions into an AST and evaluates only supported nodes, preventing arbitrary code execution that eval would allow.

Which operators are supported?

The server supports +, -, *, /, **, unary plus, and unary minus.

What happens on division by zero?

The server returns an error message: ❌ 错误:除数不能为零 (Division by zero is not allowed).

Is the server free to use?

Yes, it is released under the MIT License. Source code is available on GitHub.

评论

其他 分类下的更多 MCP 服务器