Math Mcp

Math Mcp

🚀 数学MCP服务器

本项目是一个MCP(模型上下文协议)服务器,能够以64位精度进行基本算术运算,同时支持矩阵乘法。

🚀 快速开始

本服务器可实现基本算术运算(64位精度)与矩阵乘法,为相关计算场景提供支持。

✨ 主要特性

  • 加法运算
  • 减法运算
  • 乘法运算
  • 除法运算
  • 矩阵乘法

📦 安装指南

前提条件

确保已安装以下软件:

  • Python 3.13 及以上版本
  • uv

安装 UV

所有安装选项请参考 安装指南

Unix/MacOS 系统
curl -LsSf https://astral.sh/uv/install.sh | sh

或者

brew install uv
Windows 系统
winget install --id=astral-sh.uv  -e

克隆仓库

git clone https://github.com/avanishd-3/math-mcp.git
cd math-mcp-server
uv sync

📚 详细文档

与客户端集成

Claude Code

fastmcp install claude-code src/math_server.py:math_mcp

Claude Desktop

fastmcp install claude-desktop src/math_server.py:math_mcp

Cursor

fastmcp install cursor src/math_server.py:math_mcp

VS Code

添加以下 .vscode/mcp.json 文件,并使用实际路径。

{
"servers": {
"Math MCP Server": {
"command": "uv",
"args": [
"run",
"--with",
"fastmcp",
"--with",
"numpy",
"fastmcp",
"run",
"/absolute/path/Desktop/to/math-mcp-server/src/math_server.py:math_mcp"
]
}
}
}

贡献代码

  1. 分叉仓库
  2. 创建新分支:
git checkout -b add-feature
  1. 进行修改并提交(记得在 test/ 目录中添加单元测试)
git commit -m "Added a new feature"
  1. 推送到你的分叉仓库
git push origin add-feature
  1. 发起拉取请求。

项目结构

/
├── src
│   └── math_server.py
├── tests
│   ├── test_arithmetic.py
│   │   └── astro.svg
│   ├── test_linear_algebra.py
├── pytest.ini
├── pyproject.toml
└── uv.lock

架构说明

此MCP服务器使用 Fast MCP 2.0,相较于官方MCP的Python SDK所使用的Fast MCP 1.0,它提供了更多功能。

此外,单元测试使用 Pytest 编写,这也是 Fast MCP 2.0 所推荐的。

最后,uv 是比 pip 更快的包管理工具,它还能为项目依赖提供锁文件(如果你使用过 npm 或 cargo,对此会很熟悉)。MCP Python SDK 本身就使用 uv,由于它比 pip 快 10 - 100 倍,且锁文件能让依赖版本管理更简单,因此我在所有新的 Python 项目中都使用它。

  • 0 关注
  • 0 收藏,29 浏览
  • system 提出于 2025-10-02 09:42

相似服务问题

相关AI产品