math-mcp
math-mcp is an MCP server that gives an LLM a set of reliable, deterministic math tools — no mental arithmetic required.
Evaluate expressions (
evaluate): sandboxed AST evaluation of+ - * / // % **, parentheses, constants (pi,e,tau) and functions (sqrt,sin,log,factorial,gcd,hypot, …).Statistics (
descriptive_statistics): count, sum, min, max, mean, median, variance, population/sample standard deviation.Number theory:
is_prime,prime_factorization,gcd_lcm,solve_quadratic(real or complex roots),convert_base(bases 2–36).Linear algebra:
matrix_multiply,matrix_transpose,matrix_determinant,matrix_inverse,solve_linear_system.Symbolic math (SymPy):
simplify_expression,expand_expression,factor_expression,differentiate(any order),integrate,definite_integral(incl.oobounds),limit(left/right/two-sided),taylor_series,solve_symbolic_equation.Resources: mathematical constants to 50 digits at
math://constantsandmath://constants/{name}(pi,e,tau,phi,gamma).Prompts: reusable templates
solve_step_by_stepandsolve_linear_system_prompt.Run it over stdio via
math-mcporpython -m math_mcp, and wire it into any MCP client (e.g. Claude Desktop) — all computation is real code, never Pythoneval.
Provides symbolic math tools powered by SymPy, including simplifying, expanding, factoring expressions, computing derivatives and indefinite integrals, and solving symbolic equations (e.g. x**2 = 4 → ["-2", "2"]).
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., "@math-mcp what are the roots of x² - 3x + 2 = 0?"
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.
math-mcp
A small Model Context Protocol (MCP) server that gives an LLM a set of reliable math tools — expression evaluation, statistics, number theory, linear algebra, and symbolic math — instead of asking it to do arithmetic in its head.
Every tool runs real, deterministic code. The expression evaluator is
sandboxed: it parses input into an AST and only allows a whitelist of
operators, constants, and functions. It never calls Python's eval. Symbolic
tools parse input with SymPy's tokenizing parser (also no eval).
Tools
Numeric & number theory
Tool | Description |
| Evaluate an expression like |
| Count, sum, min, max, mean, median, variance and standard deviation (population and sample) of a list of numbers. |
| Test whether an integer is prime. |
| Factor a positive integer into primes with exponents. |
| Greatest common divisor and least common multiple of two or more integers. |
| Roots of |
| Convert an integer between bases 2–36. |
Linear algebra
Matrices are lists of rows, e.g. [[1, 2], [3, 4]].
Tool | Description |
| Matrix product |
| Transpose of a matrix. |
| Determinant of a square matrix. |
| Inverse of a square, non-singular matrix. |
| Solve |
Symbolic (SymPy)
Tool | Description |
| Simplify, e.g. |
| Expand, e.g. |
| Factor, e.g. |
| Derivative w.r.t. a variable (any order). |
| Indefinite integral w.r.t. a variable. |
| Definite integral over |
| Limit as a variable approaches a point ( |
| Taylor series about a point, up to N terms. |
| Solve an equation, e.g. |
Related MCP server: precision-math-mcp
Resources & prompts
Beyond tools, the server exposes:
Resources — mathematical constants to 50 digits:
math://constants(an index) andmath://constants/{name}forpi,e,tau,phi(golden ratio) andgamma(Euler–Mascheroni).Prompts — reusable templates a client can offer to the user:
solve_step_by_stepandsolve_linear_system_prompt.
Install
Requires Python 3.10+.
Once published to PyPI (distribution name math-mcp-ay):
pip install math-mcp-ayThe import package is math_mcp and the command is math-mcp regardless of
the distribution name.
From source (for development):
git clone https://github.com/AbderY/math-mcp.git
cd math-mcp
pip install -e ".[dev]"Run
The server speaks MCP over stdio:
math-mcp
# or
python -m math_mcpUse with an MCP client
Add it to your client's MCP configuration. For example (Claude Desktop /
claude_desktop_config.json, or any MCP client that launches servers):
{
"mcpServers": {
"math": {
"command": "math-mcp"
}
}
}If math-mcp is not on your PATH, use the interpreter form instead:
{
"mcpServers": {
"math": {
"command": "python",
"args": ["-m", "math_mcp"]
}
}
}Examples
evaluate("2 ** 10 + factorial(5)")→1144.0descriptive_statistics([2, 4, 4, 4, 5, 5, 7, 9])→ mean5.0,pstdev2.0prime_factorization(360)→2³ · 3² · 5solve_quadratic(1, -3, 2)→ roots1.0and2.0convert_base("ff", 16, 2)→"11111111"matrix_inverse([[4, 7], [2, 6]])→[[0.6, -0.7], [-0.2, 0.4]]solve_linear_system([[1, 1], [1, -1]], [3, 1])→[2.0, 1.0]differentiate("x**3", "x", 2)→"6*x"definite_integral("exp(-x)", "x", "0", "oo")→"1"limit("sin(x)/x", "x", "0")→"1"taylor_series("exp(x)", "x", "0", 4)→"x**3/6 + x**2/2 + x + 1"solve_symbolic_equation("x**2 = 4")→["-2", "2"]
Development
pip install -e ".[dev]"
pytestReleasing to PyPI
Publishing is automated via GitHub Actions using PyPI Trusted Publishing (OIDC), so no API token is stored in the repo.
One-time setup on pypi.org:
Create (or claim) the project name
math-mcp-ay.Under the project's Publishing settings, add a trusted publisher:
Owner:
AbderY, repository:math-mcpWorkflow:
publish.ymlEnvironment:
pypi
Then, to release: bump the version in pyproject.toml and
src/math_mcp/__init__.py, tag it, and publish a GitHub Release. The
publish.yml workflow builds the sdist + wheel and uploads them to PyPI.
License
Available Tools
21 toolsconvert_baseA
Convert an integer number from one base to another.
number is given as a string in from_base (2-36); the result is a
string in to_base (2-36). Example: ("ff", 16, 2) -> "11111111".
Inputs: number (required), to_base (required), from_base (required). Returns: result
definite_integralB
Definite integral of expression from lower to upper.
Bounds are expressions, so oo / -oo / pi are accepted.
Inputs: expression (required), lower, upper, variable. Returns: result
descriptive_statisticsA
Return summary statistics for a list of numbers.
Includes count, sum, min, max, mean, median, population and sample
standard deviation, and variance. Requires at least one value (sample
stdev/variance require at least two and are null otherwise).
Inputs: numbers (required). Returns: object
differentiateB
Differentiate expression w.r.t. variable (optionally to a higher order).
Inputs: expression (required), order, variable. Returns: result
evaluateA
Evaluate a mathematical expression and return its numeric value.
Supports + - * / // % **, parentheses, the constants pi, e,
tau and functions such as sqrt, sin, cos, log,
exp, factorial, gcd, hypot. Evaluation is sandboxed: no
Python eval is used and only whitelisted names are allowed.
Example: "sqrt(2) * sin(pi / 4)" -> 1.0.
Inputs: expression (required). Returns: result
expand_expressionA
Expand a symbolic expression, e.g. (x + 1)**2 -> x**2 + 2*x + 1.
Inputs: expression (required). Returns: result
factor_expressionA
Factor a symbolic expression, e.g. x**2 - 1 -> (x - 1)*(x + 1).
Inputs: expression (required). Returns: result
gcd_lcmA
Return the greatest common divisor and least common multiple.
Accepts two or more integers, e.g. [12, 18, 24].
Inputs: numbers (required). Returns: object
integrateB
Return the indefinite integral of expression w.r.t. variable.
Inputs: expression (required), variable. Returns: result
is_primeA
Return whether the integer n is a prime number.
Uses trial division up to sqrt(n). Values below 2 are not prime.
Inputs: n (required). Returns: result
limitA
Limit of expression as variable -> point (oo allowed).
direction: "+" (right), "-" (left) or "+-" (two-sided).
Inputs: expression (required), point, variable, direction. Returns: result
matrix_determinantB
Return the determinant of a square matrix.
Inputs: matrix (required). Returns: result
matrix_inverseB
Return the inverse of a square, non-singular matrix.
Inputs: matrix (required). Returns: result
matrix_multiplyA
Return the matrix product A @ B.
Columns of A must match rows of B. Matrices are lists of rows.
Inputs: a (required), b (required). Returns: result
matrix_transposeB
Return the transpose of a matrix.
Inputs: matrix (required). Returns: result
prime_factorizationA
Return the prime factorization of a positive integer n.
The result is a list of {"prime": p, "exponent": k} entries, ordered
by prime. prime_factorization(360) -> 2^3 * 3^2 * 5^1.
Inputs: n (required). Returns: result
simplify_expressionB
Simplify a symbolic expression, e.g. sin(x)**2 + cos(x)**2 -> 1.
Inputs: expression (required). Returns: result
solve_linear_systemA
Solve A x = b for x, where A is square and non-singular.
Inputs: a (required), b (required). Returns: result
solve_quadraticA
Solve a*x^2 + b*x + c = 0 and return its roots.
Reports the discriminant and the (real or complex) roots. Requires
a != 0; use a linear solve otherwise.
Inputs: a (required), b (required), c (required). Returns: object
solve_symbolic_equationB
Solve an equation for a variable, e.g. "x**2 = 4" -> ["-2", "2"].
Accepts a bare expression (assumed = 0) or an explicit = equation.
Inputs: equation (required), variable. Returns: result
taylor_seriesB
Taylor series of expression about point up to order terms (O-term dropped).
Inputs: expression (required), order, point, variable. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 21 tools
Most tools target clearly distinct mathematical operations, but a few boundaries overlap: solve_quadratic is a special case of solve_symbolic_equation, matrix_inverse is closely related to solve_linear_system, and evaluate vs simplify_expression could be confused by less careful agents. Descriptions generally clarify the intended use, so misselection is unlikely but possible.
All names use snake_case and are domain-readable, which is a strong baseline. However, the set mixes verb phrases (evaluate, differentiate, integrate), noun phrases (taylor_series, descriptive_statistics, definite_integral), and bare operation names (limit), so the pattern is not fully predictable.
21 tools is above the ideal 3-15 range, but the math domain is broad and each tool covers a distinct operation across calculus, algebra, matrices, number theory, and statistics. The count is slightly heavy yet still reasonable for a comprehensive math toolkit.
The surface covers core algebra, calculus, linear algebra, number theory, statistics, and base conversion with no obvious dead ends. Minor gaps remain, such as matrix addition/eigenvalues, general polynomial manipulation beyond quadratic solving, complex arithmetic, and numerical root-finding.
Maintenance
Related MCP Connectors
500+ deterministic tools for AI agents: math, conversion, validation, hashing, encoding, date/time.
Free deterministic tools for math, data transforms, dates, text, statistics, finance, and units.
AI-callable calculators and engineering models with real formulas. No hallucinated math.
Loan & mortgage calculator, compound interest, ROI, crypto prices, FX conversion for AI agents.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables LLMs to perform accurate mathematical calculations by evaluating expressions using mathjs. Supports basic arithmetic, functions, constants, and complex mathematical operations through natural language requests.-
- AlicenseNot gradedqualityDmaintenanceProvides LLMs with accurate mathematical computation through a real calculator powered by math.js, offering tools for arithmetic, algebra, calculus, unit conversion, and more.232 npm3MIT

TinyFn MCP Serverofficial
AlicenseNot gradedqualityCmaintenanceProvides over 500 deterministic tools for math, conversions, validation, hashing, and more, enabling AI agents to perform accurate calculations and data transformations without hallucination.1MIT- AlicenseAqualityDmaintenanceEnables safe math expression evaluation, unit conversion, statistical analysis, number formatting, and percentage calculations for AI agents via MCP.549 npmMIT