Provides a calculator implementation built using Python, offering tools for basic arithmetic operations, expression evaluation, and history tracking through a Model Context Protocol server.
计算器 MCP 服务器
这是一个使用 Model Context Protocol (MCP) 开发的计算器服务器,提供基本的算术运算功能。
功能特点
基本计算器功能
- 加法、减法、乘法、除法的基本运算
- 自动记录计算历史
- 通过资源 API 访问帮助信息和历史记录
高级计算器功能
- 幂运算和平方根计算
- 表达式计算(使用安全的表达式求值)
- 资源更新通知(当历史记录更新时)
安装要求
- Python 3.7 或更高版本
- MCP Python SDK
安装步骤
- 克隆或下载此仓库
- 安装依赖项:
使用方法
运行基本计算器服务器
或者使用 MCP 命令:
运行高级计算器服务器
运行客户端示例
可用工具
基本工具:
add(a, b)
: 计算 a + bsubtract(a, b)
: 计算 a - bmultiply(a, b)
: 计算 a * bdivide(a, b)
: 计算 a / b
高级工具(仅在高级计算器中可用):
power(base, exponent)
: 计算 base 的 exponent 次幂sqrt(value)
: 计算平方根evaluate_expression(expression)
: 计算数学表达式字符串
可用资源
calculator://help
: 获取帮助信息calculator://history
: 获取计算历史记录
示例代码
使用 Python 客户端调用计算器服务器
项目结构
calculator_server.py
: 基本计算器 MCP 服务器advanced_calculator_server.py
: 高级计算器 MCP 服务器,带有更多功能calculator_client.py
: 计算器客户端示例requirements.txt
: 项目依赖README.md
: 项目文档
进一步开发
你可以通过以下方式扩展这个计算器服务器:
- 添加更多数学函数(如三角函数、对数等)
- 实现更复杂的表达式解析器
- 添加图形界面
- 实现持久化存储计算历史
- 添加用户自定义变量和函数
许可证
MIT 许可证
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Provides basic arithmetic operations and advanced mathematical functions through the Model Context Protocol (MCP), with features like calculation history tracking and expression evaluation.
Related MCP Servers
- -securityFlicense-qualityA Model Context Protocol (MCP) server that provides mathematical calculations and operations using NumPy, enabling users to perform numerical computations like matrix operations, statistical analysis, and polynomial fitting directly through Claude.Last updated -1Python
- AsecurityFlicenseAqualityA server that provides tools for performing basic arithmetic operations (addition, subtraction, multiplication, division) via the Model Context Protocol.Last updated -4JavaScript
- AsecurityAlicenseAqualityA Model Context Protocol server that enables LLMs to perform precise numerical calculations by evaluating mathematical expressions.Last updated -148PythonMIT License
- AsecurityFlicenseAqualityA simple Model Context Protocol server that provides basic arithmetic operations (addition, subtraction, multiplication, division) as tools that can be called by Large Language Models.Last updated -4JavaScript