Calculator MCP Server

Calculator MCP Server

mcp-calculate-server-xiaoyingv•byxiaoyingv

A Python AST-based safe expression calculator MCP service supporting basic math operations and error protection.

License: MIT License•Runtime: Awaiting documentation review•Category: developer tools

WHAT IT DOES

  • •Provides a perform_calculation tool that accepts a math expression string and returns a formatted result or error message.
  • •Supports addition, subtraction, multiplication, division, exponentiation, and unary plus/minus operations.
  • •Formats results intelligently: integers display as integers, decimals keep up to 15 significant digits, and trailing zeros are removed.
  • •Includes safety protections such as AST parsing instead of eval, division-by-zero guarding, syntax error messages, type checks, and exponentiation safety checks.

BEST FOR

  • •Running a stdio-based calculator service for MCP clients that need arithmetic evaluation.
  • •Evaluating simple math expressions while avoiding code injection risks through AST-based parsing rather than eval.
  • •Getting formatted numeric results and clear error messages for invalid calculations like division by zero.

ABOUT MCP-CALCULATE-SERVER-XIAOYINGV

Calculator MCP Server is cataloged as an MCP server attributed to xiaoyingv. A Python AST-based safe expression calculator MCP service supporting basic math operations and error protection. It is categorized under developer tools. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT License. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for Calculator MCP Server are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

How does the calculator avoid code injection risks?

It parses expressions with Python's AST instead of using eval.

What happens when dividing by zero?

It returns a division-by-zero error message instead of a result.

上游原版 README

在 GitHub 查看同一版本原文

README.md · 33730ac72699 · 采集于 2026-11-13 10:41:03 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

Calculator MCP Server 🧮

PyPI version License Python Version

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

功能特性

  • ✅ 支持加减乘除四则运算(+, -, *, /)
  • ✅ 支持幂运算(**)
  • ✅ 支持正负号处理(+5, -3)
  • ✅ 智能格式化计算结果:
    • 整数结果直接显示整数
    • 小数结果保留最多15位有效数字
    • 自动去除末尾多余的零
  • ⚠️ 安全防护:
    • 拦截代码注入风险(通过 AST 解析而非 eval)
    • 除零错误防护
    • 语法错误提示
    • 类型安全检查
    • 幂运算安全检查

安装方式

pip install mcp-calculate-server

快速使用

from mcp.server.fastmcp import FastMCP

# 启动计算器服务
calculator = FastMCP("CalculatorServer")
calculator.run(transport='stdio')

API 接口

perform_calculation(expression: str) -> str

接收数学表达式字符串,返回格式化结果或错误信息

>>> perform_calculation("5+3")
"🧮 计算结果:5+3 = 8"

>>> perform_calculation("10/3")
"🧮 计算结果:10/3 = 3.333333333333333"

>>> perform_calculation("10**20")
"🧮 计算结果:10**20 = 100000000000000000000"

>>> perform_calculation("2**3")
"🧮 计算结果:2**3 = 8"

>>> perform_calculation("10/0")
"❌ 错误:除数不能为零"

>>> perform_calculation("0**-1")
"❌ 错误:零的负数次幂未定义"

>>> perform_calculation("(-1)**0.5")
"❌ 错误:负数的非整数次幂未定义"

支持的运算符

操作符说明示例
+加法3+4
-减法5-2
*乘法6*7
/除法8/2
**幂运算2**3
-x取负-5
+x取正+3

错误码说明

错误类型示例输出
语法错误❌ 表达式语法错误:unexpected EOF
不支持的运算符❌ 不支持的运算符:Mod
除零错误❌ 错误:除数不能为零
非法操作数类型TypeError: 不支持的常量类型
零的负数次幂❌ 错误:零的负数次幂未定义
负数的非整数次幂❌ 错误:负数的非整数次幂未定义

依赖环境

  • Python 3.13+
  • mcp-server 库(自动安装)

开源协议

MIT License,详情见 LICENSE

源码地址

GitHub: https://github.com/xiaoyingv/mcp_calculate_server

贡献指南

欢迎提交 PR 和报告 issue,提交前请阅读 CONTRIBUTING.md

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for Calculator MCP Server from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/mcp-calculate-server-xiaoyingv)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related developer tools MCP Servers

Alternative and complementary servers in the same category

View all in developer tools →
Postbye
postbye-mcp•postbye-team

A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools
Singapore Proxy MCP
singapore-proxy-mcp•Xavierfok

A hosted MCP service for browsing and searching through Singapore mobile-network proxies.

0
Developer Tools

A directory listing describing a Markdown-to-PDF service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools