Symbolic Algebra MCP Server
Provides symbolic mathematics tools backed by SymPy, enabling algebraic equation solving, integration, differentiation, vector and tensor calculus, ODE/PDE solving, simplification, substitution, factorization, expansion, limits, series expansions, and inequality solving.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Symbolic Algebra MCP Server solve the equation x^2 - 5x + 6 = 0 for x"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Symbolic Algebra MCP Server (lag-sympy-mcp)
This is a maintained fork of sdiehl/sympy-mcp, which is no longer maintained upstream (Apache License 2.0). It adds algebra and calculus tools (factor_expression, expand_expression, cancel_expression, apart_expression, limit_expression, series_expansion, solve_inequality) and a safe expression parser; see MODIFICATIONS.md.
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$.
Related MCP server: Symath-MCP
Usage
You need uv first.
Homebrew :
brew install uvCurl :
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/laguchoritarik/lag-sympy-mcp.git
cd lag-sympy-mcp
uv sync
# Install the server to Claude Desktop
uv run mcp install server.py
# Run the server
uv run mcp run server.pyYou should see the server available in the Claude Desktop app now. For other clients, see below.
Claude Code setup
claude mcp add --scope user sympy-mcp -- uv --directory /ABSOLUTE_PATH_TO/lag-sympy-mcp run mcp run server.pyReplace /ABSOLUTE_PATH_TO/lag-sympy-mcp with the absolute path of your clone, then check the connection with claude mcp list.
If you want to do general relativity calculations, you need to install the einsteinpy library.
uv sync --group relativityAvailable Tools
The sympy-mcp server provides the following tools for symbolic mathematics:
Tool | Tool ID | Description |
Variable Introduction |
| Introduces a variable with specified assumptions and stores it |
Multiple Variables |
| Introduces multiple variables with specified assumptions simultaneously |
Expression Parser |
| Parses an expression string using available local variables and stores it |
LaTeX Printer |
| Prints a stored expression in LaTeX format, along with variable assumptions |
Algebraic Solver |
| Solves an equation algebraically for a given variable over a given domain |
Linear Solver |
| Solves a system of linear equations |
Nonlinear Solver |
| Solves a system of nonlinear equations |
Function Variable |
| Introduces a function variable for use in differential equations |
ODE Solver |
| Solves an ordinary differential equation |
PDE Solver |
| Solves a partial differential equation |
Standard Metric |
| Creates a predefined spacetime metric (e.g. Schwarzschild, Kerr, Minkowski) |
Metric Search |
| Searches available predefined metrics |
Tensor Calculator |
| Calculates tensors from a metric (Ricci, Einstein, Weyl tensors) |
Custom Metric |
| Creates a custom metric tensor from provided components and symbols |
Tensor LaTeX |
| Prints a stored tensor expression in LaTeX format |
Simplifier |
| Simplifies a mathematical expression using SymPy's canonicalize function |
Substitution |
| Substitutes a variable with an expression in another expression |
Integration |
| Integrates an expression with respect to a variable |
Differentiation |
| Differentiates an expression with respect to a variable |
Coordinates |
| Creates a 3D coordinate system for vector calculus operations |
Vector Field |
| Creates a vector field in the specified coordinate system |
Curl |
| Calculates the curl of a vector field |
Divergence |
| Calculates the divergence of a vector field |
Gradient |
| Calculates the gradient of a scalar field |
Unit Converter |
| Converts a quantity to given target units |
Unit Simplifier |
| Simplifies a quantity with units |
Matrix Creator |
| Creates a SymPy matrix from the provided data |
Determinant |
| Calculates the determinant of a matrix |
Matrix Inverse |
| Calculates the inverse of a matrix |
Eigenvalues |
| Calculates the eigenvalues of a matrix |
Eigenvectors |
| Calculates the eigenvectors of a matrix |
Factorization |
| Factors an expression over Q (optionally over Q(i) or GF(p)) |
Expansion |
| Expands products and integer powers of sums |
Rational Cancellation |
| Puts a rational expression in canonical form p/q with common factors cancelled |
Partial Fractions |
| Computes the partial fraction decomposition of a rational expression |
Limit |
| Computes a limit at a finite point or at ±∞ (two-sided or one-sided) |
Series Expansion |
| Computes a Taylor/Laurent expansion with or without the O(...) remainder |
Inequality Solver |
| Solves an inequality (or And/Or of inequalities) in one real variable |
By default variables are predefined with assumptions (similar to how the symbols() function works in SymPy). Unless otherwise specified the defaut assumptions is that a variable is complex, commutative, term over the complex field $\mathbb{C}$.
Property | Value |
| true |
| true |
| true |
| false |
Algebra and Calculus Tools
These tools work on expressions already stored with introduce_expression and return a new
expression key (print it with print_latex_expression), except solve_inequality, which returns
the LaTeX of the solution set, like solve_algebraically. factor_expression, expand_expression,
cancel_expression and apart_expression apply to both sides of an equation and to each entry of
a matrix.
Tool | Parameters | Example input → output |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Notes:
limit_expressionreports an error, rather than a value, when the limit does not exist: one-sided limits that differ (1/x,Abs(x)/xat 0) or oscillation (sin(x)atoo).Inequalities are solved over the reals. Write a double inequality
a < f(x) < basAnd(a < f(x), f(x) < b); Python's chained comparison is not supported by SymPy.The
pointarguments oflimit_expressionandseries_expansionare not passed toparse_expr. They are parsed with Python'sastmodule against an allow-list: numbers, introduced variables,oo/inf/infinity/zoo/pi/E/I,+ - * / ** ^, and the functionssqrt,exp,log,sin,cos,tan,Rational. Anything else (attribute access, subscripts, strings, keyword arguments, other calls, very large exact powers, inputs over 256 characters) is rejected before evaluation.
Claude Desktop Setup
Normally the mcp install command will automatically add the server to the claude_desktop_config.json file. If it doesn't you need to find the config file and add the following:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
Add the following to the mcpServers object, replacing /ABSOLUTE_PATH_TO_SYMPY_MCP/server.py with the absolute 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"
]
}
}
}Cursor Setup
In your ~/.cursor/mcp.json, add the following, where ABSOLUTE_PATH_TO_SYMPY_MCP is 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 Setup
VS Code and VS Code Insiders now support MCPs in agent mode. For VS Code, you may need to enable Chat > Agent: Enable in the settings.
One-click Setup:
OR manually add the config to your settings.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.
HTTP Transport (Streamable HTTP / SSE)
The server supports MCP over HTTP using the streamable-http transport introduced in MCP spec 2025-03-26. This replaces the legacy SSE transport and exposes a single /mcp endpoint 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 9000The legacy --transport sse flag is still supported for backward compatibility.
A /healthcheck endpoint is also exposed that runs a full MCP protocol round-trip (initialize → tools/list → session teardown) and returns {"status": "ok", "tool_count": N}.
Running in Container
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-mcpOr use Docker Compose from the docker/ directory:
cd docker
docker compose up -d --buildAlternatively, you can pull the pre-built image from GitHub Container Registry:
# Pull the latest image
docker pull ghcr.io/laguchoritarik/lag-sympy-mcp:main
# Run the container
docker run -p 8081:8081 --rm ghcr.io/laguchoritarik/lag-sympy-mcp:mainTo configure Claude Desktop to launch the Docker container, edit your claude_desktop_config.json file:
{
"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/laguchoritarik/lag-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_many to 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_function to define x(t):
{
"func_name": "x"
}Assistant: (Internal tool call) introduce_expression to create the differential equation:
{
"expr_str": "Eq(m*Derivative(x(t), t, t) + c*Derivative(x(t), t) + k*x(t), F(t))"
}Assistant: (Internal tool call) print_latex_expression to display the equation nicely:
{
"expr_key": "expr_12"
}Result:
$$ 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_function to define F(t):
{
"func_name": "F"
}Assistant: (Internal tool call) dsolve_ode to solve the differential equation:
{
"expr_key": "expr_12",
"func_name": "x"
}Result:
$$ 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_metric to create the Anti-de Sitter metric:
{
"metric_name": "AntiDeSitter"
}Assistant: (Internal tool call) calculate_tensor to calculate the Ricci tensor:
{
"metric_key": "metric_AntiDeSitter",
"tensor_type": "RICCI_TENSOR",
"simplify_result": true
}Assistant: (Internal tool call) print_latex_tensor to display the Ricci tensor:
{
"tensor_key": "riccitensor_metric_AntiDeSitter"
}Result:
$$ \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_tensor to calculate the Ricci scalar:
{
"metric_key": "metric_AntiDeSitter",
"tensor_type": "RICCI_SCALAR",
"simplify_result": true
}Assistant: (Internal tool call) print_latex_tensor to display the Ricci scalar:
{
"tensor_key": "ricciscalar_metric_AntiDeSitter"
}Result:
$$ -12 $$
Example Interaction 3: Coupled ODE System (Fluid Dynamics)
This example demonstrates solving a coupled system of ODEs and verifying the solution against an algebraic steady-state analysis, a task where LLMs typically hallucinate without a CAS to ground each step.
User:
Use the sympy-mcp tools to solve this symbolically. Do not compute by hand.
Two cylindrical tanks are connected by a pipe. Tank 1 has cross-sectional area A₁ = 2 m² and receives a constant inflow of Q = 0.5 m³/s. Water drains from Tank 1 into Tank 2 through a pipe with flow rate proportional to the height difference: q₁₂ = k·(h₁ - h₂) where k = 0.3 m²/s. Tank 2 has cross-sectional area A₂ = 1 m² and drains to the outside at rate q₂ = k·h₂ with the same k.
Set up and solve the coupled system of ODEs for the water heights h₁(t) and h₂(t), starting from empty tanks (h₁(0) = 0, h₂(0) = 0). Then find the steady-state heights as t → ∞ by solving the equilibrium equations algebraically, and verify they match the long-term solution of the ODEs.
Assistant: (Internal tool chain)
intro_many: introducet,k,A1,A2,Qwith real/positive assumptionsintroduce_function× 2: introduceh1(t)andh2(t)as unknown functionsintroduce_expression× 2: encode the mass-balance ODEs:
$$A_1 \frac{dh_1}{dt} = Q - k(h_1 - h_2), \quad A_2 \frac{dh_2}{dt} = k(h_1 - h_2) - k h_2$$
substitute_expression: substitute numeric values fork,A1,A2,Qdsolve_ode× 2: solve the coupled system; apply initial conditions viasubstitute_expressionintroduce_expression× 2: encode equilibrium equations (derivatives set to zero)solve_linear_system: solve the 2×2 algebraic system forh1*,h2*print_latex_expression: display both the time-domain solution and the steady-state values
Security Disclaimer
This server runs on your computer and gives the language model access to run Python logic. Notably it uses Sympy's parse_expr to parse mathematical expressions, which is uses eval under the hood, effectively allowing arbitrary code execution. By running the server, you are trusting the code that Claude generates. Running in the Docker image is slightly safer, but it's still a good idea to review the code before running it.
parse_expr call sites
The following tools pass client-supplied strings to parse_expr with SymPy's default global
namespace (which includes Python builtins such as __import__, open, eval, exec):
introduce_expression(expr_str)integrate_expression(lower_bound,upper_bound)create_vector_field(component strings)create_matrix(string entries)convert_to_units(target unit strings)create_custom_metric(component strings)
For example introduce_expression("__import__('os').getpid()") executes the call. Passing
global_dict={} is not a mitigation: eval re-inserts the complete __builtins__ module into
an empty globals dictionary, and object attribute traversal (obj.__class__.__mro__...) remains
available regardless of the namespace. SymPy documents parse_expr/sympify as unsafe on untrusted
input. Resource exhaustion is also possible (e.g. 10**10**10), and no time limit is applied to any
tool. With the HTTP transports the server binds to 0.0.0.0 by default, which exposes these
risks to the network; prefer --mcp-host 127.0.0.1 or the stdio transport.
The algebra/calculus tools added in this fork (factor_expression, expand_expression,
cancel_expression, apart_expression, limit_expression, series_expansion,
solve_inequality) never call parse_expr, sympify or eval themselves; their only string
inputs are parsed by the allow-list parser described above. They still operate on expressions that
were created through introduce_expression, so they do not remove the risk of that entry point.
License
Copyright 2025 Stephen Diehl.
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.
Available Tools
39 toolsapart_expressionA
Computes the partial fraction decomposition of a rational expression using SymPy's apart.
Args:
expr_key: The key of the expression (previously introduced) to decompose.
var_name: The variable (previously introduced) to decompose with respect to.
Required when the expression has several variables.
Example:
intro("x", [Assumption.REAL], [])
expr_key = introduce_expression("1/(x**2 - 1)")
result_key = apart_expression(expr_key, "x")
# -1/(2(x + 1)) + 1/(2(x - 1))
Returns:
A key for the decomposed expression.
Inputs: expr_key (required), var_name. Returns: result
calculate_curlA
Calculates the curl of a vector field using SymPy's curl function.
Args:
vector_field_key: The key of the vector field expression.
Example:
# First create a coordinate system
create_coordinate_system("R")
# Create a vector field F = (y, -x, 0)
vector_field = create_vector_field("R", "R_y", "-R_x", "0")
# Calculate curl
curl_result = calculate_curl(vector_field)
# Returns (0, 0, -2)
Returns:
A key for the curl expression.
Inputs: vector_field_key (required). Returns: result
calculate_divergenceA
Calculates the divergence of a vector field using SymPy's divergence function.
Args:
vector_field_key: The key of the vector field expression.
Example:
# First create a coordinate system
create_coordinate_system("R")
# Create a vector field F = (x, y, z)
vector_field = create_vector_field("R", "R_x", "R_y", "R_z")
# Calculate divergence
div_result = calculate_divergence(vector_field)
# Returns 3
Returns:
A key for the divergence expression.
Inputs: vector_field_key (required). Returns: result
calculate_gradientA
Calculates the gradient of a scalar field using SymPy's gradient function.
Args:
scalar_field_key: The key of the scalar field expression.
Example:
# First create a coordinate system
create_coordinate_system("R")
# Create a scalar field f = x^2 + y^2 + z^2
scalar_field = introduce_expression("R_x**2 + R_y**2 + R_z**2")
# Calculate gradient
grad_result = calculate_gradient(scalar_field)
# Returns (2x, 2y, 2z)
Returns:
A key for the gradient vector field expression.
Inputs: scalar_field_key (required). Returns: result
calculate_tensorC
Calculates a tensor from a metric using einsteinpy.symbolic.
Inputs: metric_key (required), tensor_type (required), simplify_result. Returns: result
cancel_expressionA
Puts a rational expression in canonical form p/q with common factors cancelled.
Uses SymPy's cancel function. Cancellation is formal: (x**2 - 1)/(x - 1)
becomes x + 1, even though the original is undefined at x = 1.
Args:
expr_key: The key of the expression (previously introduced) to cancel.
Example:
intro("x", [Assumption.REAL], [])
expr_key = introduce_expression("(x**2 - 1)/(x**2 - 2*x + 1)")
result_key = cancel_expression(expr_key)
# (x + 1)/(x - 1)
Returns:
A key for the simplified rational expression.
Inputs: expr_key (required). Returns: result
convert_to_unitsA
Converts a quantity to the given target units using sympy.physics.units.convert_to.
Args:
expr_key: The key of the expression (previously introduced) to convert.
target_units: List of unit names as strings (e.g., ["meter", "1/second"]).
unit_system: Optional unit system (from UnitSystem enum). Defaults to SI.
The following units are available by default:
SI base units: meter, second, kilogram, ampere, kelvin, mole, candela
Length: kilometer, millimeter
Mass: gram
Energy: joule
Force: newton
Pressure: pascal
Power: watt
Electric: coulomb, volt, ohm, farad, henry
Constants: speed_of_light, gravitational_constant, planck
IMPORTANT: For compound units like meter/second, you must separate the numerator and
denominator into separate units in the list. For example:
- For meter/second: use ["meter", "1/second"]
- For newton*meter: use ["newton", "meter"]
- For kilogram*meter²/second²: use ["kilogram", "meter**2", "1/second**2"]
Example:
# Convert speed of light to kilometers per hour
expr_key = introduce_expression("speed_of_light")
result = convert_to_units(expr_key, ["kilometer", "1/hour"])
# Returns approximately 1.08e9 kilometer/hour
# Convert gravitational constant to CGS units
expr_key = introduce_expression("gravitational_constant")
result = convert_to_units(expr_key, ["centimeter**3", "1/gram", "1/second**2"], UnitSystem.CGS)
SI prefixes (femto, pico, nano, micro, milli, centi, deci, deca, hecto, kilo, mega, giga, tera)
can be used directly with base units.
Returns:
A key for the converted expression, or an error message.
Inputs: expr_key (required), target_units (required), unit_system. Returns: result
create_coordinate_systemA
Creates a 3D coordinate system for vector calculus operations.
Args:
name: The name for the coordinate system.
coord_names: Optional list of coordinate names (3 names for x, y, z).
If not provided, defaults to [name+'_x', name+'_y', name+'_z'].
Example:
# Create a coordinate system
coord_sys = create_coordinate_system("R")
# Creates a coordinate system R with coordinates R_x, R_y, R_z
# Create a coordinate system with custom coordinate names
coord_sys = create_coordinate_system("C", ["rho", "phi", "z"])
Returns:
The name of the created coordinate system.
Inputs: name (required), coord_names. Returns: result
create_custom_metricC
Creates a custom metric tensor from provided components and symbols.
Inputs: symbols (required), components (required), config. Returns: result
create_matrixA
Creates a SymPy matrix from the provided data.
Args:
matrix_data: A list of lists representing the rows and columns of the matrix.
Each element can be a number or a string expression.
matrix_var_name: Optional name for storing the matrix. If not provided, a
sequential name will be generated.
Example:
# Create a 2x2 matrix with numeric values
matrix_key = create_matrix([[1, 2], [3, 4]], "M")
# Create a matrix with symbolic expressions (assuming x, y are defined)
matrix_key = create_matrix([["x", "y"], ["x*y", "x+y"]])
Returns:
A key for the stored matrix.
Inputs: matrix_data (required), matrix_var_name. Returns: result
create_predefined_metricC
Creates a predefined spacetime metric.
Inputs: metric_name (required). Returns: result
create_vector_fieldA
Creates a vector field in the specified coordinate system.
Args:
coord_sys_name: The name of the coordinate system to use.
component_x: String expression for the x-component of the vector field.
component_y: String expression for the y-component of the vector field.
component_z: String expression for the z-component of the vector field.
Example:
# First create a coordinate system
create_coordinate_system("R")
# Create a vector field F = (y, -x, z)
vector_field = create_vector_field("R", "R_y", "-R_x", "R_z")
Returns:
A key for the vector field expression.
Inputs: component_x (required), component_y (required), component_z (required), coord_sys_name (required). Returns: result
differentiate_expressionA
Differentiates an expression with respect to a variable using SymPy's diff function.
Args:
expr_key: The key of the expression (previously introduced) to differentiate.
var_name: The name of the variable to differentiate with respect to.
order: The order of differentiation (default is 1 for first derivative).
Example:
# Introduce a variable
intro("x", [Assumption.REAL], [])
# Create an expression to differentiate: x^3
expr_key = introduce_expression("x**3")
# First derivative
first_deriv = differentiate_expression(expr_key, "x")
# Returns 3x²
# Second derivative
second_deriv = differentiate_expression(expr_key, "x", 2)
# Returns 6x
Returns:
A key for the differentiated expression.
Inputs: expr_key (required), var_name (required), order. Returns: result
dsolve_odeA
Solves an ordinary differential equation using SymPy's dsolve function.
Args:
expr_key: The key of the expression (previously introduced) containing the differential equation.
func_name: The name of the function (previously introduced) to solve for.
hint: Optional solving method from ODEHint enum. If None, SymPy will try to determine the best method.
Example:
# First introduce a variable and a function
intro("x", [Assumption.REAL], [])
introduce_function("f")
# Create a second-order ODE: f''(x) + 9*f(x) = 0
expr_key = introduce_expression("Derivative(f(x), x, x) + 9*f(x)")
# Solve the ODE
result = dsolve_ode(expr_key, "f")
# Returns solution with sin(3*x) and cos(3*x) terms
Returns:
A LaTeX string representing the solution. Returns an error message string if issues occur.
Inputs: expr_key (required), func_name (required), hint. Returns: result
expand_expressionA
Expands an expression algebraically using SymPy's expand function.
Distributes products and expands integer powers of sums. Equations are expanded side by side.
Args:
expr_key: The key of the expression (previously introduced) to expand.
Example:
intro("x", [Assumption.REAL], [])
expr_key = introduce_expression("(x + 1)**3")
result_key = expand_expression(expr_key)
# x^3 + 3x^2 + 3x + 1
Returns:
A key for the expanded expression.
Inputs: expr_key (required). Returns: result
factor_expressionA
Factors a polynomial or rational expression using SymPy's factor function.
By default the factorization is over the rationals. Equations are factored side by side.
Args:
expr_key: The key of the expression (previously introduced) to factor.
gaussian: If True, factor over the Gaussian rationals Q(i), e.g. x**2 + 1 = (x - i)(x + i).
modulus: Optional prime p to factor over the finite field GF(p).
Example:
intro("x", [Assumption.REAL], [])
expr_key = introduce_expression("x**6 - 1")
result_key = factor_expression(expr_key)
# (x - 1)(x + 1)(x^2 - x + 1)(x^2 + x + 1)
Returns:
A key for the factored expression.
Inputs: expr_key (required), modulus, gaussian. Returns: result
integrate_expressionA
Integrates an expression with respect to a variable using SymPy's integrate function.
Args:
expr_key: The key of the expression (previously introduced) to integrate.
var_name: The name of the variable to integrate with respect to.
lower_bound: Optional lower bound for definite integration.
upper_bound: Optional upper bound for definite integration.
Example:
# Introduce a variable
intro("x", [Assumption.REAL], [])
# Create an expression to integrate: x^2
expr_key = introduce_expression("x**2")
# Indefinite integration
indefinite_result = integrate_expression(expr_key, "x")
# Returns x³/3
# Definite integration from 0 to 1
definite_result = integrate_expression(expr_key, "x", "0", "1")
# Returns 1/3
Returns:
A key for the integrated expression.
Inputs: expr_key (required), var_name (required), lower_bound, upper_bound. Returns: result
introC
Introduces a sympy variable with specified assumptions and stores it.
Takes a variable name and a list of positive and negative assumptions.
Inputs: var_name (required), neg_assumptions (required), pos_assumptions (required). Returns: result
introduce_expressionA
Parses a sympy expression string using available local variables and stores it. Assigns it to either a temporary name (expr_0, expr_1, etc.) or a user-specified global name.
Uses Sympy parse_expr to parse the expression string.
Applies default Sympy canonicalization rules unless canonicalize is False.
For equations (x^2 = 1) make the input string "Eq(x^2, 1") not "x^2 == 1"
Examples:
{expr_str: "Eq(x^2 + y^2, 1)"}
{expr_str: "Matrix(((25, 15, -5), (15, 18, 0), (-5, 0, 11)))"}
{expr_str: "pi+e", "expr_var_name": "z"}
Inputs: expr_str (required), canonicalize, expr_var_name. Returns: result
introduce_functionA
Introduces a SymPy function variable and stores it.
Takes a function name and creates a SymPy Function object for use in defining differential equations.
Example:
{func_name: "f"} will create the function f(x), f(t), etc. that can be used in expressions
Returns:
The name of the created function.
Inputs: func_name (required). Returns: result
intro_manyA
Introduces multiple sympy variables with specified assumptions and stores them.
Takes a list of VariableDefinition objects for the 'variables' parameter.
Each object in the list specifies:
- var_name: The name of the variable (string).
- pos_assumptions: A list of positive assumption strings (e.g., ["real", "positive"]).
- neg_assumptions: A list of negative assumption strings (e.g., ["complex"]).
The JSON payload for the 'variables' argument should be a direct list of these objects, for example:
```json
[
{
"var_name": "x",
"pos_assumptions": ["real", "positive"],
"neg_assumptions": ["complex"]
},
{
"var_name": "y",
"pos_assumptions": [],
"neg_assumptions": ["commutative"]
}
]
```
The assumptions must be consistent, so a real number is not allowed to be non-commutative.
Prefer this over intro() for multiple variables because it's more efficient.
Inputs: variables (required). Returns: result
limit_expressionA
Computes the limit of an expression as a variable tends to a point, using SymPy's limit.
Args:
expr_key: The key of the expression (previously introduced).
var_name: The variable (previously introduced) that tends to the point.
point: The limit point, e.g. "0", "1/2", "pi/2", "oo" (+infinity), "-oo".
Parsed without eval: only numbers, introduced variables, oo/inf/pi/E/I,
arithmetic operators and sqrt/exp/log/sin/cos/tan/Rational are accepted.
direction: "+-" for the two-sided limit (default), "+" from the right, "-" from the left.
Ignored for limits at +oo or -oo.
Example:
intro("x", [Assumption.REAL], [])
expr_key = introduce_expression("sin(x)/x")
result_key = limit_expression(expr_key, "x", "0")
# 1
expr_key = introduce_expression("(1 + 1/x)**x")
result_key = limit_expression(expr_key, "x", "oo")
# e
Returns:
A key for the limit. Returns an error message if the limit does not exist
(one-sided limits differ, or the expression oscillates).
Inputs: point (required), expr_key (required), var_name (required), direction. Returns: result
matrix_determinantB
Calculates the determinant of a matrix using SymPy's det method.
Args:
matrix_key: The key of the matrix to calculate the determinant for.
Example:
# Create a matrix
matrix_key = create_matrix([[1, 2], [3, 4]])
# Calculate its determinant
det_key = matrix_determinant(matrix_key)
# Results in -2
Returns:
A key for the determinant expression.
Inputs: matrix_key (required). Returns: result
matrix_eigenvaluesA
Calculates the eigenvalues of a matrix using SymPy's eigenvals method.
Args:
matrix_key: The key of the matrix to calculate eigenvalues for.
Example:
# Create a matrix
matrix_key = create_matrix([[1, 2], [2, 1]])
# Calculate its eigenvalues
evals_key = matrix_eigenvalues(matrix_key)
Returns:
A key for the eigenvalues expression (usually a dictionary mapping eigenvalues to their multiplicities).
Inputs: matrix_key (required). Returns: result
matrix_eigenvectorsA
Calculates the eigenvectors of a matrix using SymPy's eigenvects method.
Args:
matrix_key: The key of the matrix to calculate eigenvectors for.
Example:
# Create a matrix
matrix_key = create_matrix([[1, 2], [2, 1]])
# Calculate its eigenvectors
evecs_key = matrix_eigenvectors(matrix_key)
Returns:
A key for the eigenvectors expression (usually a list of tuples (eigenvalue, multiplicity, [eigenvectors])).
Inputs: matrix_key (required). Returns: result
matrix_inverseA
Calculates the inverse of a matrix using SymPy's inv method.
Args:
matrix_key: The key of the matrix to invert.
Example:
# Create a matrix
matrix_key = create_matrix([[1, 2], [3, 4]])
# Calculate its inverse
inv_key = matrix_inverse(matrix_key)
Returns:
A key for the inverted matrix.
Inputs: matrix_key (required). Returns: result
pdsolve_pdeA
Solves a partial differential equation using SymPy's pdsolve function.
Args:
expr_key: The key of the expression (previously introduced) containing the PDE.
If the expression is not an equation (Eq), it will be interpreted as
PDE = 0.
func_name: The name of the function (previously introduced) to solve for.
This should be a function of multiple variables.
Example:
# First introduce variables and a function
intro("x", [Assumption.REAL], [])
intro("y", [Assumption.REAL], [])
introduce_function("f")
# Create a PDE: 1 + 2*(ux/u) + 3*(uy/u) = 0
expr_key = introduce_expression(
"Eq(1 + 2*Derivative(f(x, y), x)/f(x, y) + 3*Derivative(f(x, y), y)/f(x, y), 0)"
)
# Solve the PDE
result = pdsolve_pde(expr_key, "f")
# Returns solution with exponential terms and arbitrary function
Returns:
A LaTeX string representing the solution. Returns an error message string if issues occur.
Inputs: expr_key (required), func_name (required), hint. Returns: result
print_latex_expressionA
Prints a stored expression in LaTeX format, along with variable assumptions.
Inputs: expr_key (required). Returns: result
print_latex_tensorC
Prints a stored tensor expression in LaTeX format.
Inputs: tensor_key (required). Returns: result
quantity_simplify_unitsB
Simplifies a quantity with units using sympy's built-in simplify method for Quantity objects.
Args:
expr_key: The key of the expression (previously introduced) to simplify.
unit_system: Optional unit system (from UnitSystem enum). Not used with direct simplify method.
The following units are available by default:
SI base units: meter, second, kilogram, ampere, kelvin, mole, candela
Length: kilometer, millimeter
Mass: gram
Energy: joule
Force: newton
Pressure: pascal
Power: watt
Electric: coulomb, volt, ohm, farad, henry
Constants: speed_of_light, gravitational_constant, planck
Example:
# Simplify force expressed in base units
expr_key = introduce_expression("kilogram*meter/second**2")
result = quantity_simplify_units(expr_key)
# Returns newton (as N = kg·m/s²)
# Simplify a complex expression with mixed units
expr_key = introduce_expression("joule/(kilogram*meter**2/second**2)")
result = quantity_simplify_units(expr_key)
# Returns a dimensionless quantity (1)
# Simplify electrical power expression
expr_key = introduce_expression("volt*ampere")
result = quantity_simplify_units(expr_key)
# Returns watt
Example with Speed of Light:
# Introduce the speed of light
c_key = introduce_expression("speed_of_light")
# Convert to kilometers per hour
km_per_hour_key = convert_to_units(c_key, ["kilometer", "1/hour"])
# Simplify to get the numerical value
simplified_key = quantity_simplify_units(km_per_hour_key)
# Print the result
print_latex_expression(simplified_key)
# Shows the numeric value of speed of light in km/h
Returns:
A key for the simplified expression, or an error message.
Inputs: expr_key (required), unit_system. Returns: result
reset_stateA
Resets the state of the SymPy MCP server.
Clears all stored variables, functions, expressions, metrics, tensors,
coordinate systems, and resets the expression counter.
Then reinitializes unit variables.
Runs after all tool calls for a given computation are done to reset the state for the next computation.
Returns:
A message confirming the reset.
Inputs: no named parameters. Returns: result
search_predefined_metricsC
Searches for predefined metrics in einsteinpy.symbolic.predefined.
Inputs: query (required). Returns: result
series_expansionA
Computes a Taylor/Laurent/Puiseux expansion (développement limité) using SymPy's series.
Args:
expr_key: The key of the expression (previously introduced) to expand.
var_name: The variable (previously introduced) of the expansion.
point: The expansion point, e.g. "0", "1", "pi/2", "oo". Parsed without eval
with the same rules as limit_expression. Defaults to "0".
order: Terms up to (var - point)**(order - 1) are kept, followed by O((var - point)**order).
Must be between 1 and 50. Defaults to 6.
remove_order_term: If True, drop the O(...) remainder and return the truncated polynomial.
Example:
intro("x", [Assumption.REAL], [])
expr_key = introduce_expression("exp(x)")
result_key = series_expansion(expr_key, "x", "0", 4)
# 1 + x + x^2/2 + x^3/6 + O(x^4)
Returns:
A key for the expansion.
Inputs: expr_key (required), var_name (required), order, point, +1 more. Returns: result
simplify_expressionA
Simplifies a mathematical expression using SymPy's simplify function.
Args:
expr_key: The key of the expression (previously introduced) to simplify.
Example:
# Introduce variables
intro("x", [Assumption.REAL], [])
intro("y", [Assumption.REAL], [])
# Create an expression to simplify: sin(x)^2 + cos(x)^2
expr_key = introduce_expression("sin(x)**2 + cos(x)**2")
# Simplify the expression
simplified = simplify_expression(expr_key)
# Returns 1
Returns:
A key for the simplified expression.
Inputs: expr_key (required). Returns: result
solve_algebraicallyA
Solves an equation (expression = 0) algebraically for a given variable.
Args:
expr_key: The key of the expression (previously introduced) to be solved.
solve_for_var_name: The name of the variable (previously introduced) to solve for.
domain: The domain to solve in: Domain.COMPLEX, Domain.REAL, Domain.INTEGERS, or Domain.NATURALS. Defaults to Domain.COMPLEX.
Returns:
A LaTeX string representing the set of solutions. Returns an error message string if issues occur.
Inputs: expr_key (required), solve_for_var_name (required), domain. Returns: result
solve_inequalityA
Solves an inequality in one real variable using SymPy's solveset over the reals.
The inequality is introduced with introduce_expression, e.g. "x**2 - 1 > 0",
"(x - 1)/(x + 2) <= 0", or a combination "And(x > 0, x**2 < 4)" / "Or(...)".
For a double inequality a < f(x) < b use "And(a < f(x), f(x) < b)".
Args:
expr_key: The key of the inequality (previously introduced).
var_name: The variable (previously introduced) to solve for.
Example:
intro("x", [Assumption.REAL], [])
expr_key = introduce_expression("x**2 - 1 > 0")
solve_inequality(expr_key, "x")
# \left(-\infty, -1\right) \cup \left(1, \infty\right)
Returns:
A LaTeX string representing the solution set. Returns an error message string if issues occur.
Inputs: expr_key (required), var_name (required). Returns: result
solve_linear_systemA
Solves a system of linear equations using SymPy's linsolve.
Args:
expr_keys: The keys of the expressions (previously introduced) forming the system.
var_names: The names of the variables to solve for.
domain: The domain to solve in (Domain.COMPLEX, Domain.REAL, etc.). Defaults to Domain.COMPLEX.
Returns:
A LaTeX string representing the solution set. Returns an error message string if issues occur.
Inputs: expr_keys (required), var_names (required), domain. Returns: result
solve_nonlinear_systemA
Solves a system of nonlinear equations using SymPy's nonlinsolve.
Args:
expr_keys: The keys of the expressions (previously introduced) forming the system.
var_names: The names of the variables to solve for.
domain: The domain to solve in (Domain.COMPLEX, Domain.REAL, etc.). Defaults to Domain.COMPLEX.
Returns:
A LaTeX string representing the solution set. Returns an error message string if issues occur.
Inputs: expr_keys (required), var_names (required), domain. Returns: result
substitute_expressionA
Substitutes a variable in an expression with another expression using SymPy's subs method.
Args:
expr_key: The key of the expression to perform substitution on.
var_name: The name of the variable to substitute.
replacement_expr_key: The key of the expression to substitute in place of the variable.
Example:
# Create variables x and y
intro("x", [], [])
intro("y", [], [])
# Create expressions
expr1 = introduce_expression("x**2 + y**2")
expr2 = introduce_expression("sin(x)")
# Substitute y with sin(x) in x^2 + y^2
result = substitute_expression(expr1, "y", expr2)
# Results in x^2 + sin^2(x)
Returns:
A key for the resulting expression after substitution.
Inputs: expr_key (required), var_name (required), replacement_expr_key (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 39 tools
Most tools map to distinct SymPy operations (solve, simplify, factor, integrate, matrix, vector, units), so selection is generally clear. Some overlaps remain: intro vs intro_many, introduce_expression can also create matrices despite create_matrix, and solve_algebraically overlaps conceptually with system solvers, though descriptions mostly clarify.
Most names follow readable action-oriented patterns such as solve_*, create_*, calculate_*, and *_expression. Deviations are minor but visible: intro/intro_many, noun-first matrix_* operations, and quantity_simplify_units break the otherwise consistent verb-first convention.
At 39 tools the server is heavily over-scoped relative to a typical MCP tool surface, spanning algebra, calculus, ODE/PDE, matrices, vector calculus, units, and tensors. Even though many tools correspond to real SymPy functions, the count is high enough to burden tool selection and discoverability.
The surface covers a broad symbolic algebra lifecycle: variables, expressions, manipulation, solving, calculus, ODE/PDE, matrices, vector calculus, units, and tensors. Minor gaps exist, such as individual listing/deletion of stored objects, numeric evaluation, and fuller matrix arithmetic beyond inverse/determinant/eigen operations.
Maintenance
Related MCP Connectors
Unofficial Math.js MCP — wraps the mathjs.org API (free, no auth)
Scientific compute for AI agents: symbolic, numerical, quantum, chemistry, ODE. Paid via x402.
This MCP server enables users to perform scientific computations regarding linear algebra and vect…
Exact arithmetic, algebra, calculus, physics, chemistry and finance with a checkable formula.
Related MCP Servers
- AlicenseAqualityDmaintenanceA mathematical computation service that enables users to perform symbolic calculations including basic arithmetic, algebra, calculus, equation solving, and matrix operations through the MCP protocol.16MIT
- AlicenseAqualityDmaintenanceA symbolic mathematics MCP server supporting calculus, linear algebra, number theory, statistics, and unit conversion via natural language.8MIT
- AlicenseNot gradedqualityBmaintenanceProvides a token-efficient exact math engine for AI agents, enabling computation of derivatives, integrals, equations, and optimized Python/NumPy code via a single MCP tool.56 PyPI8MIT
- AlicenseNot gradedqualityBmaintenanceExposes the full SageMath computer algebra system to LLM clients through MCP tools for symbolic mathematics, solving, calculus, plotting, and number theory.475 npm1Creative Commons Zero v1.0 Universal