Symbolic Algebra MCP Server is a tool that allows language models to perform symbolic mathematics and computer algebra operations through the Model Context Protocol (MCP). It exposes SymPy's powerful symbolic manipulation capabilities to LLMs, enabling them to solve complex mathematical problems accurately without hallucinating results.
Before installing the server, you need to have uv package manager installed:
brew install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone the repository
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
For a single-command installation (use with caution):
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
For general relativity calculations, install the additional dependency:
uv sync --group relativity
You can also run the server in a Docker container:
# Pull the pre-built image
docker pull ghcr.io/sdiehl/sympy-mcp:latest
# Run the container
docker run -p 8081:8081 --rm ghcr.io/sdiehl/sympy-mcp:latest
Or build and run locally:
# Build the Docker image
docker build -t sympy-mcp .
# Run the Docker container
docker run -p 8081:8081 sympy-mcp
The mcp install
command should automatically add the server to your Claude Desktop configuration. If not, edit your config file manually:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
Add this to the mcpServers
object:
{
"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 supports MCP in agent mode. You can use one-click setup or manually add to settings.json:
{
"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"
]
}
}
}
}
For Cline:
sympy-mcp
http://127.0.0.1:8081/sse
For 5ire:
sympy-mcp
/opt/homebrew/bin/uv run --with einsteinpy --with mcp[cli] --with pydantic --with sympy mcp run /ABSOLUTE_PATH_TO/server.py
The server provides these mathematical tools:
intro
): Introduces variables with specified assumptionsintro_many
): Introduces multiple variables simultaneouslyintroduce_expression
): Parses mathematical expressionsprint_latex_expression
): Outputs expressions in LaTeX formatsimplify_expression
): Simplifies expressionssubstitute_expression
): Replaces variables in expressionssolve_algebraically
): Solves algebraic equationssolve_linear_system
): Solves systems of linear equationssolve_nonlinear_system
): Solves nonlinear equation systemsintegrate_expression
): Integrates expressionsdifferentiate_expression
): Differentiates expressionsintroduce_function
): Creates function variablesdsolve_ode
): Solves ordinary differential equationspdsolve_pde
): Solves partial differential equationscreate_coordinate_system
): Creates 3D coordinate systemscreate_vector_field
): Creates vector fieldscalculate_curl
): Calculates curl of vector fieldscalculate_divergence
): Calculates divergence of vector fieldscalculate_gradient
): Calculates gradient of scalar fieldscreate_predefined_metric
): Creates predefined spacetime metricssearch_predefined_metrics
): Searches available metricscalculate_tensor
): Calculates tensors from metricscreate_custom_metric
): Creates custom metric tensorsprint_latex_tensor
): Formats tensors in LaTeXcreate_matrix
): Creates matricesmatrix_determinant
): Calculates matrix determinantsmatrix_inverse
): Calculates matrix inversesmatrix_eigenvalues
): Calculates matrix eigenvaluesmatrix_eigenvectors
): Calculates matrix eigenvectorsconvert_to_units
): Converts between unitsquantity_simplify_units
): Simplifies units in expressionsYou can solve differential equations like a damped harmonic oscillator:
Solve the damped harmonic oscillator with forcing term:
m(d²x/dt²) + c(dx/dt) + kx = F(t)
where m is mass, c is damping coefficient, k is spring constant, and F(t) is external force.
The server will:
You can perform tensor calculations:
Compute the trace of the Ricci tensor R_μν using the inverse metric g^μν for Anti-de Sitter spacetime
to determine its constant scalar curvature R.
The server will:
This server runs Python code on your computer, including using Sympy's parse_expr
which utilizes eval()
under the hood. This means it can potentially execute arbitrary code. Consider the following:
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.