Math Calculation MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add math-mcps -- uv run main.py
README.md

A comprehensive mathematical calculation server for the Model Context Protocol.

Math_MCPS 项目文件描述

项目概述

Math_MCPS 是一个基于 Model Context Protocol (MCP) 的数学计算服务器,提供丰富的数学计算功能,包括基础运算、高级数学函数、统计学工具、数学常量资源和复杂算式处理能力。

文件结构

Math_MCPS/
├── .gitignore              # Git 忽略文件配置
├── .python-version        # Python 版本要求 (>=3.12)
├── main.py                # 主程序文件,包含所有数学工具和资源
├── pyproject.toml         # 项目配置文件,定义依赖和元数据
├── README.md              # 项目文档,包含功能介绍和使用方法
├── uv.lock                # UV 依赖锁定文件
└── cute_message.txt       # 示例文件,包含可爱消息

核心文件详解

1. main.py - 主程序文件

功能:实现所有数学计算工具和资源的核心代码

主要组件

  • 基础数学运算:加、减、乘、除
  • 高级数学运算:幂运算、根运算、对数、指数、三角函数、反三角函数
  • 组合数学:阶乘、组合数、排列数
  • 统计学工具:平均值、中位数、众数、方差、标准差
  • 数学常量资源:π、e、黄金比例、根号2
  • 复杂算式处理:表达式计算、表达式简化
  • 提示生成器:解方程、证明定理、创建图形的提示模板
  • 单位转换:角度单位转换

技术特点

  • 使用 FastMCP 框架构建服务器
  • 支持类型提示,提高代码可读性
  • 包含完整的错误处理机制
  • 安全的数学表达式计算

2. pyproject.toml - 项目配置文件

功能:定义项目元数据和依赖关系

关键配置

  • 项目名称:math
  • 版本:0.1.0
  • Python 版本要求:>=3.12
  • 主要依赖:mcp[cli]>=1.26.0
  • 使用 UV 作为包管理器
  • 配置清华源为默认 PyPI 源

3. README.md - 项目文档

功能:提供项目概述、功能介绍和使用指南

内容概览

  • 功能特性分类介绍
  • 安装和运行说明
  • 使用示例
  • 扩展功能指导
  • 注意事项和错误处理
  • 测试方法

4. .gitignore - Git 忽略配置

功能:指定 Git 版本控制系统应忽略的文件

包含内容

  • Python 生成的文件 (pycache, *.pyo, *.pyd)
  • 构建和分发目录 (build/, dist/, wheels/)
  • 虚拟环境 (.venv)
  • 项目特定的测试和调试文件

5. .python-version - Python 版本要求

功能:指定项目所需的 Python 版本

当前设置:>=3.12

6. uv.lock - 依赖锁定文件

功能:锁定项目依赖的确切版本,确保环境一致性

7. cute_message.txt - 示例文件

功能:包含一个可爱消息的示例文件,用于测试提交和推送功能

技术栈

  • 编程语言:Python 3.12+
  • 框架:MCP (Model Context Protocol) with FastMCP
  • 包管理器:UV
  • 版本控制:Git
  • 密钥管理:GPG 签名验证

特色功能

  1. 全面的数学工具集:从基础运算到高级数学函数
  2. 安全表达式计算:支持复杂数学表达式的安全计算
  3. 资源访问:提供数学常量的结构化访问
  4. 提示生成:为数学问题提供解题思路和证明方法
  5. 错误处理:完善的边界条件检查和错误提示
  6. 类型安全:使用 Python 类型提示确保接口一致性

开发状态

  • 项目已完成基本功能开发
  • 配置了 GPG 签名验证
  • 支持代码推送和版本控制
  • 可以通过 MCP 协议提供数学计算服务

Tools (4)

basic_arithmeticPerforms basic addition, subtraction, multiplication, and division.
advanced_mathPerforms power, root, logarithmic, exponential, and trigonometric calculations.
statisticsCalculates mean, median, mode, variance, and standard deviation.
expression_evaluatorSafely evaluates and simplifies complex mathematical expressions.

Configuration

claude_desktop_config.json
{"mcpServers": {"math": {"command": "uv", "args": ["run", "main.py"]}}}

Try it

Calculate the standard deviation of the following dataset: [10, 12, 23, 23, 16, 23, 21, 16].
Simplify the mathematical expression: 2 * (x + 3) - 5.
What is the value of the golden ratio and the square root of 2?
Calculate the sine of 45 degrees.
Help me solve the equation 3x^2 + 2x - 5 = 0.

Frequently Asked Questions

What are the key features of Math Calculation MCP Server?

Comprehensive mathematical toolset from basic arithmetic to advanced functions. Secure evaluation and simplification of complex mathematical expressions. Structured access to mathematical constants like pi, e, and the golden ratio. Statistical analysis tools including mean, median, and standard deviation. Built-in prompt generation for solving equations and proving theorems.

What can I use Math Calculation MCP Server for?

Automating complex statistical analysis for data research tasks. Assisting students with step-by-step equation solving and theorem proofs. Integrating reliable mathematical constant lookups into AI workflows. Performing unit conversions and trigonometric calculations for engineering problems.

How do I install Math Calculation MCP Server?

Install Math Calculation MCP Server by running: git clone https://github.com/K-Summer/Math_MCPS && cd Math_MCPS && uv sync

What MCP clients work with Math Calculation MCP Server?

Math Calculation MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Math Calculation MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare