MCP.so
Sign In

Calculator MCP Server 🧮

@xiaoyingv

About Calculator MCP Server 🧮

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

Basic information

Category

Other

License

MIT

Runtime

html

Transports

stdio

Publisher

xiaoyingv

Config

No standard config provided

This server doesn't expose a parseable MCP config block in its README. See the repository for install instructions.

Repository

Tools

No tools detected

We auto-extract tools from the README. The maintainer can list them under a ## Tools heading to populate this section.

Overview

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.

Comments

More Other MCP servers