SS

sdiehl/sympy-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

85 stars 17 forks 质量 83 趋势 8Apache-2.0

sdiehl/sympy-mcp 是从 https://github.com/sdiehl/sympy-mcp. 导入的 MCP 服务器候选

概览

sdiehl/sympy-mcp 是从 https://github.com/sdiehl/sympy-mcp. 导入的 MCP 服务器候选

概述(AI 翻译)

本库已不再维护。它是Apache许可的,欢迎分叉。

Sympy-MCP 是一款模型上下文协议服务器,允许大型语言模型自主执行符号数学和计算机代数。它向 MCP 客户端展示了 Sympy 核心功能的众多工具,用于操作数学表达式和方程。

为什么?

语言模型在符号操作方面极其糟糕。它们会幻觉变量,编造随机常数,置换项,通常会制造混乱。但我们有专门为符号操作设计的计算机代数系统,因此可以用工具调用来协调一系列变换,让符号核承担所有繁重工作。

虽然你当然可以让大型语言模型生成 Mathematica 或 Python 代码,但如果你想把它当作代理或即时计算器使用,使用主计算器服务器直接暴露符号工具会更好。

该服务器展示了一系列符号数学能力,包括代数方程求解、积分与微分、向量微积分、广义相对论的张量演算,以及常微分方程和偏微分方程。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Symbolic Algebra MCP Server

This library is no longer maintained. It is Apache licensed, so feel free to fork it.

Sympy-MCP is a Model Context Protocol server for allowing LLMs to autonomously perform symbolic mathematics and computer algebra. It exposes numerous tools from SymPy’s core functionality to MCP clients for manipulating mathematical expressions and equations.

Why?

Language models are absolutely abysmal at symbolic manipulation. They hallucinate variables, make up random constants, permute terms and generally make a mess. But we have computer algebra systems specifically built for symbolic manipulation, so we can use tool-calling to orchestrate a sequence of transforms so that the symbolic kernel does all the heavy lifting.

While you can certainly have an LLM generate Mathematica or Python code, if you want to use the LLM as an agent or on-the-fly calculator, it’s a better experience to use the MCP server and expose the symbolic tools directly.

The server exposes a subset of symbolic mathematics capabilities including algebraic equation solving, integration and differentiation, vector calculus, tensor calculus for general relativity, and both ordinary and partial differential equations.

For example, you can ask it in natural language to solve a differential equation:

Solve the damped harmonic oscillator with forcing term: the mass-spring-damper system described by the differential equation where m is mass, c is the damping coefficient, k is the spring constant, and F(t) is an external force.

$$ m\frac{d^2x}{dt^2} + c\frac{dx}{dt} + kx = F(t) $$

Or involving general relativity:

Compute the trace of the Ricci tensor $R_{\mu\nu}$ using the inverse metric $g^{\mu\nu}$ for Anti-de Sitter spacetime to determine its constant scalar curvature $R$.

Usage

You need uv first.

  • Homebrew : brew install uv
  • Curl : curl -LsSf https://astral.sh/uv/install.sh | sh

Then you can install and run the server with the following commands:

# Setup the project
git clone https://github.com/sdiehl/sympy-mcp.git
cd sympy-mcp
uv sync

# Install the server to Claude Desktop
uv run mcp install server.py

# Run the server
uv run mcp run server.py

You should see the server available in the Claude Desktop app now. For other clients, see below.

If you want a completely standalone version that just runs with a single command, you can use the following. Note this is running arbitrary code from Github, so be careful.

uv run --with https://github.com/sdiehl/sympy-mcp/releases/download/0.1/sympy_mcp-0.1.0-py3-none-any.whl python server.py

If you want to do general relativity calculations, you need to install the einsteinpy library.

uv sync --group relativity

Available Tools

The sympy-mcp server provides the following tools for symbolic mathematics:

在 GitHub 查看完整 README

安装

docker run -i -p 8081:8081 --rm sympy-mcp
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "sympy-mcp": { "command": "/opt/homebrew/bin/uv", "args": [ "run", "--with", "einsteinpy", "--with", "mcp[cli]", "--with", "pydantic", "--with", "sympy", "mcp", "run", "/ABSOLUTE_PATH_TO_SYMPY_MCP/server.py" ] } } }