Skip to main content

A comprehensive MCP calculator service supporting basic arithmetic and advanced mathematical functions

Project description

MCP Calculator

一个支持多种传输方式的MCP计算器服务,提供基本算术运算和高级数学函数。

功能特性

  • 基本算术运算: 加法、减法、乘法、除法
  • 高级数学函数: 幂运算、平方根、阶乘
  • 多种传输方式: 支持stdio和streamable HTTP传输
  • 错误处理: 完善的错误处理机制(如除零检查)

安装

从PyPI安装(推荐)

# 使用pip安装
pip install mcp-calculator-wyt

# 或使用uv安装
uv add mcp-calculator-wyt

从源码安装

# 克隆仓库
git clone https://github.com/wyt/mcp-calculator-wyt.git
cd mcp-calculator-wyt

# 使用uv安装
uv sync

# 或使用pip安装
pip install .

使用方法

1. stdio传输方式(默认)

# 直接运行
python -m mcp_calculator_kel

# 或使用脚本入口
mcp_calculator_kel

2. HTTP传输方式

# 启动HTTP服务器
python -m mcp_calculator_kel.http_server

# 或使用脚本入口
mcp_calculator_kel_http

# 自定义主机和端口
mcp_calculator_kel_http --host 0.0.0.0 --port 8080

3. 测试传输方式

# 运行测试脚本
python test_transports.py

可用工具

  • add(a: float, b: float): 执行浮点数加法运算
  • subtract(a: float, b: float): 执行浮点数减法运算
  • multiply(a: float, b: float): 执行浮点数乘法运算
  • divide(a: float, b: float): 执行浮点数除法运算
  • power(base: float, exponent: float): 计算幂运算
  • sqrt(number: float): 计算平方根
  • factorial(n: int): 计算整数阶乘

传输方式说明

  • stdio: 适用于本地进程间通信,通过标准输入输出进行交互
  • streamable-http: 适用于远程通信,通过HTTP协议提供更灵活的交互方式

CherryStudio 集成

快速开始

  1. 进入项目根目录

    cd D:\实\mcp-calculator
    
  2. 运行集成测试

    uv run python test_cherrystudio_integration.py
    

    或直接双击 test_cherrystudio.bat

  3. 配置 CherryStudio

    • 打开 CherryStudio
    • 进入设置 → MCP 服务器
    • 添加服务器:
      • 名称: mcp-calculator
      • 命令: uv
      • 参数: run python -m mcp_calculator_kel
      • 工作目录: 项目根目录路径
  4. 开始使用

    • 在 CherryStudio 中直接使用计算工具
    • 支持自然语言交互,如:"请计算 15 + 27"

详细集成指南

查看 CherryStudio 集成指南 获取完整的集成说明和故障排除方法。

配置文件

项目提供了预配置的 CherryStudio 配置文件:

  • cherrystudio_config.json - CherryStudio MCP 服务器配置
  • test_cherrystudio_integration.py - 集成测试脚本

开发

项目使用fastmcp框架构建,支持MCP协议的标准功能。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_calculator_wyt-0.2.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_calculator_wyt-0.2.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file mcp_calculator_wyt-0.2.0.tar.gz.

File metadata

  • Download URL: mcp_calculator_wyt-0.2.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for mcp_calculator_wyt-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8e3e9ada13c10857b53584c6dc1ec6de080ca6d39604b73a294e1adceb841671
MD5 5695b2552987f49251a2b1d21e8d1d71
BLAKE2b-256 dc1dfe443c96e5079996b77c6f5856c8fd0ee8aa19bf4195d902bba64b078852

See more details on using hashes here.

File details

Details for the file mcp_calculator_wyt-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_calculator_wyt-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd9f4eb7399975021027339bee06ab10a0671d34ddca57a62ee506b06b447fdf
MD5 ca6596a9d15e9480f12c3f6048ea7404
BLAKE2b-256 715841eacacbcbadc89ad201cae33f1b3b16e5dff7b35003fcf328d5fb34d52b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page