本项目是一个MCP(模型上下文协议)服务器,能够以64位精度进行基本算术运算,同时支持矩阵乘法。
本服务器可实现基本算术运算(64位精度)与矩阵乘法,为相关计算场景提供支持。
确保已安装以下软件:
所有安装选项请参考 安装指南。
curl -LsSf https://astral.sh/uv/install.sh | sh
或者
brew install uv
winget install --id=astral-sh.uv -e
git clone https://github.com/avanishd-3/math-mcp.git
cd math-mcp-server
uv sync
fastmcp install claude-code src/math_server.py:math_mcp
fastmcp install claude-desktop src/math_server.py:math_mcp
fastmcp install cursor src/math_server.py:math_mcp
添加以下 .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"
]
}
}
}
git checkout -b add-feature
test/ 目录中添加单元测试)git commit -m "Added a new feature"
git push origin add-feature
/
├── 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 项目中都使用它。