Symbolic Algebra MCP Server
About
Perform symbolic mathematics and computer algebra using the SymPy library.
Details
- Author
- sdiehl
- Categories
- Developer Tools, Other
Jump to
Setup
Install Symbolic Algebra MCP Server in your MCP client (Claude Desktop, Cursor, Windsurf, and others).
Repository: https://github.com/sdiehl/sympy-mcp
Follow the installation instructions in the repository README, then restart your MCP client.
Perform symbolic mathematics and computer algebra using the SymPy library.
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.
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) $$
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$.
- 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 theeinsteinpylibrary.
The sympy-mcp server provides the following tools for symbolic mathematics:
By default variables are predefined with assumptions (similar to how thesymbols()function works in SymPy). Unless otherwise specified the defaut assumptions is that a variable is complex, commutative, term over the complex field $\mathbb{C}$.
Normally themcp installcommand will automatically add the server to theclaude_desktop_config.jsonfile. If it doesn't you need to find the config file and add the following:
- macOS:~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:%APPDATA%\Claude\claude_desktop_config.json
Add the following to themcpServersobject, replacing/ABSOLUTE_PATH_TO_SYMPY_MCP/server.pywith the absolute path to the sympy-mcpserver.pyfile.
{ "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" ] } } }
In your~/.cursor/mcp.json, add the following, whereABSOLUTE_PATH_TO_SYMPY_MCPis the path to the sympy-mcp server.py file.
{ "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" ] } } }
VS Code and VS Code Insiders now support MCPs inagent mode. For VS Code, you may need to enableChat > Agent: Enablein the settings.
OR manually add the config to yoursettings.json(global):
{ "mcp": { "servers": { "sympy-mcp": { "command": "uv", "args": [ "run", "--with", "einsteinpy", "--with", "mcp[cli]", "--with", "pydantic", "--with", "sympy", "mcp", "run", "/ABSOLUTE_PATH_TO_SYMPY_MCP/server.py" ] } } } }
- Click "Start" above the server config switch to agent mode in the chat, and try commands like "integrate x^2" or "solve x^2 = 1" to get started.
Then select "Remote Servers" and add the following:
- Server Name:sympy-mcp
- Server URL:http://127.0.0.1:8081/sse
Another MCP client that supports multiple models (o3, o4-mini, DeepSeek-R1, etc.) on the backend is 5ire.
To set up with5ire, open 5ire and go to Tools -> New and set the following configurations:
- Tool Key:sympy-mcp
- Name: SymPy MCP
- Command:/opt/homebrew/bin/uv run --with einsteinpy --with mcp[cli] --with pydantic --with sympy mcp run /ABSOLUTE_PATH_TO/server.py
Replace/ABSOLUTE_PATH_TO/server.pywith the actual path to your sympy-mcp server.py file.
The server supports MCP over HTTP using thestreamable-http transportintroduced in MCP spec 2025-03-26. This replaces the legacy SSE transport and exposes a single/mcpendpoint that clients connect to over HTTP.
This is the recommended transport when running the server as a standalone process or in a container, because it allows any HTTP-capable MCP client to connect without needing to launch the server as a subprocess.
# Run locally with HTTP transport uv run python server.py --transport streamable-http # Override host/port uv run python server.py --transport streamable-http --mcp-host 127.0.0.1 --mcp-port 9000
The legacy--transport sseflag is still supported for backward compatibility.
A/healthcheckendpoint is also exposed that runs a full MCP protocol round-trip (initialize → tools/list → session teardown) and returns{"status": "ok", "tool_count": N}.
You can build and run the server using Docker locally:
# Build the Docker image docker build -t sympy-mcp . # Run the Docker container docker run -p 8081:8081 sympy-mcp
Or use Docker Compose from thedocker/directory:
Alternatively, you can pull the pre-built image from GitHub Container Registry:
# Pull the latest image docker pull ghcr.io/sdiehl/sympy-mcp:main # Run the container docker run -p 8081:8081 --rm ghcr.io/sdiehl/sympy-mcp:main
To configure Claude Desktop to launch the Docker container, edit yourclaude_desktop_config.jsonfile:
{ "mcpServers": { "sympy-mcp": { "command": "docker", "args": [ "run", "-i", "-p", "8081:8081", "--rm", "sympy-mcp" ] } } }
Or to use the pre-built container from GitHub:
{ "mcpServers": { "sympy-mcp": { "command": "docker", "args": [ "run", "-i", "-p", "8081:8081", "--rm", "ghcr.io/sdiehl/sympy-mcp:main" ] } } }
This configuration tells Claude Desktop to launch the Docker container when needed. Make sure to build the Docker image (docker build -t sympy-mcp .) before using Claude Desktop with this configuration.
The other installation methods can also be adapted to work with Docker if you change the uv command to use the docker run command instead.
Example Interaction 1 : Differential Equations
Here's an example of how the tool-calling works in a conversation with an AI assistant using this MCP server:
User: 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) $$
Assistant: (Internal tool call)intro_manyto introduce variables:
{ "variables": [ {"var_name": "t", "pos_assumptions": ["real"], "neg_assumptions": []}, {"var_name": "m", "pos_assumptions": ["real", "positive"], "neg_assumptions": []}, {"var_name": "c", "pos_assumptions": ["real", "positive"], "neg_assumptions": []}, {"var_name": "k", "pos_assumptions": ["real", "positive"], "neg_assumptions": []} ] }
Assistant: (Internal tool call)introduce_functionto define x(t):
{ "func_name": "x" }
Assistant: (Internal tool call)introduce_expressionto create the differential equation:
{ "expr_str": "Eq(mDerivative(x(t), t, t) + cDerivative(x(t), t) + k*x(t), F(t))" }
Assistant: (Internal tool call)print_latex_expressionto display the equation nicely:
{ "expr_key": "expr_12" }
$$ c \frac{d}{d t} x{\left(t \right)} + k x{\left(t \right)} + m \frac{d^{2}}{d t^{2}} x{\left(t \right)} = F{\left(t \right)} $$
Assistant: (Internal tool call)introduce_functionto define F(t):
{ "func_name": "F" }
Assistant: (Internal tool call)dsolve_odeto solve the differential equation:
{ "expr_key": "expr_12", "func_name": "x" }
$$ x{\left(t \right)} = C_{1} e^{\frac{t \left(- c + \sqrt{c^{2} - 4 k m}\right)}{2 m}} + C_{2} e^{- \frac{t \left(c + \sqrt{c^{2} - 4 k m}\right)}{2 m}} + \cdots $$
Example Interaction 2: General Relativity
User: 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$.
Assistant: (Internal tool call)create_predefined_metricto create the Anti-de Sitter metric:
{ "metric_name": "AntiDeSitter" }
Assistant: (Internal tool call)calculate_tensorto calculate the Ricci tensor:
{ "metric_key": "metric_AntiDeSitter", "tensor_type": "RICCI_TENSOR", "simplify_result": true }
Assistant: (Internal tool call)print_latex_tensorto display the Ricci tensor:
{ "tensor_key": "riccitensor_metric_AntiDeSitter" }
$$ \left[\begin{matrix}3 & 0 & 0 & 0\\0 & - 3 \cos^{2}{\left(t \right)} & 0 & 0\\0 & 0 & - 3 \cos^{2}{\left(t \right)} \sinh^{2}{\left(\chi \right)} & 0\\0 & 0 & 0 & - 3 \sin^{2}{\left(\theta \right)} \cos^{2}{\left(t \right)} \sinh^{2}{\left(\chi \right)}\end{matrix}\right] $$
Assistant: (Internal tool call)calculate_tensorto calculate the Ricci scalar:
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





