Skip to main content
Glama
Math MCP Server

Math MCP Server

by amichae2

Math MCP Server

Math MCP Server is a Python 3.12 Model Context Protocol server that exposes a broad mathematics toolkit over stdio. It combines symbolic algebra, calculus, numerical methods, linear algebra, statistics, discrete mathematics, graph theory, rendering, and optional GPU acceleration behind MCP tools that are usable from Claude Desktop, GitHub Copilot, and other MCP-compatible hosts.

The server is designed to run on CPU-only systems by default. If CUDA and CuPy are available, the GPU tool family accelerates supported workloads automatically and otherwise falls back to CPU implementations when possible.

Installation

Editable install with uv:

uv pip install -e .

For GPU acceleration (requires CUDA 12.x and a compatible NVIDIA GPU):

uv pip install -e ".[gpu]"

Editable install with uv and optional GPU support:

uv pip install -e ".[gpu]"

Editable install with pip:

pip install -e .

Use the base install for CPU-only systems. Install the gpu extra only on machines with a compatible CUDA 12.x environment.

For development dependencies and tests:

.venv/bin/uv sync --extra dev

Related MCP server: advanced-math-mcp

Running The Server

Run directly with Python:

python -m math_mcp.server

Run through uv:

uv run python -m math_mcp.server

Run via the console script:

math-mcp-server

The server communicates over stdio, which is the expected transport for most MCP hosts.

MCP Host Configuration

Most MCP clients accept a JSON config that declares a named server, the command to run, and its arguments. A generic config looks like this:

{
	"mcpServers": {
		"math": {
			"command": "/absolute/path/to/.venv/bin/python",
			"args": ["-m", "math_mcp.server"],
			"cwd": "/absolute/path/to/math-mcp-server"
		}
	}
}

If the package is already installed in the active environment, you can use the console script instead:

{
	"mcpServers": {
		"math": {
			"command": "math-mcp-server"
		}
	}
}

Claude Desktop

Add the math server entry to your Claude Desktop MCP configuration file and point it at either the environment Python executable or the installed math-mcp-server script.

GitHub Copilot

Use the same mcpServers structure in your MCP-enabled Copilot or VS Code host configuration. The server name can remain math so it matches the packaged MCP entry point.

Other MCP Hosts

Any host that supports stdio MCP servers can run this project with the same command and args shown above.

Tool Catalog

Symbolic Tools

Tool

Description

simplify

Simplify algebraic, trigonometric, and rational expressions.

expand

Expand products, powers, and composite symbolic expressions.

factor

Factor polynomials and integers into structured symbolic factors.

solve

Solve equations, systems, and inequalities over configurable domains.

symbolic_integrate

Compute indefinite and definite symbolic integrals.

symbolic_diff

Differentiate expressions, including higher-order derivatives.

limit

Evaluate one-sided and two-sided limits.

series

Produce Taylor or Laurent-like series expansions.

symbolic_sum

Evaluate finite and infinite symbolic summations.

symbolic_product

Evaluate finite and infinite symbolic products.

dsolve

Solve ordinary differential equations symbolically.

laplace_transform

Compute Laplace transforms in the frequency domain.

inverse_laplace

Transform Laplace-domain expressions back to time-domain forms.

Numerical Tools

Tool

Description

numerical_integrate

Numerically integrate real-valued functions on finite or improper intervals.

find_root

Find roots with bracketing or open methods such as Brent or Newton.

ode_solve

Solve initial value problems for scalar or vector ODE systems.

interpolate_data

Interpolate tabular data with linear or spline-based methods.

curve_fit

Fit parametric models to observed data and report fitted parameters.

Linear Algebra Tools

Tool

Description

matrix_multiply

Multiply dense matrices and vectors.

solve_linear

Solve square linear systems with direct or iterative methods.

lstsq

Solve overdetermined systems with least-squares regression.

matrix_decompose

Compute QR, LU, Cholesky, or SVD-style decompositions.

eigen_decomp

Compute eigenvalues and eigenvectors.

matrix_info

Report determinant, rank, conditioning, definiteness, and shape metadata.

Statistics Tools

Tool

Description

describe

Return descriptive statistics for a sample.

distribution

Evaluate distribution PDFs, CDFs, quantiles, and related functions.

hypothesis_test

Run supported hypothesis tests and report significance details.

regression

Fit linear and polynomial regression models.

bootstrap

Estimate confidence intervals with bootstrap resampling.

random_sample

Draw samples from supported probability distributions.

Discrete Math And Number Theory Tools

Tool

Description

factor_int

Factor integers into prime powers.

is_prime

Test whether an integer is prime.

primes_range

Enumerate primes over an interval or generate the first n primes.

gcd_lcm

Compute GCD, LCM, extended GCD, or Euclidean algorithm steps.

modular

Solve modular arithmetic tasks such as inverses, powers, and congruences.

combinatorics

Evaluate permutations, combinations, Catalan numbers, and related counts.

partitions

Count integer partitions and constrained partition variants.

diophantine

Solve supported Diophantine equations over the integers.

Graph Theory Tools

Tool

Description

graph_create

Build graphs from named templates, edge lists, or adjacency matrices.

shortest_path

Compute shortest paths on weighted or unweighted graphs.

spanning_tree

Compute a spanning tree or minimum spanning tree.

graph_metrics

Report graph connectivity and structural metrics.

max_flow

Compute maximum flow on directed graphs.

GPU Tools

Tool

Description

gpu_matrix_multiply

Accelerate matrix multiplication with GPU support and CPU fallback.

gpu_fft

Compute FFTs on GPU when available.

gpu_eigen_batch

Compute batched eigenvalues for multiple matrices.

gpu_solve

Solve batched linear systems using GPU acceleration where available.

Rendering Tools

Tool

Description

to_latex

Convert symbolic expressions to LaTeX and renderable output.

render_math

Render LaTeX math to an image data URI.

plot_function

Plot explicit functions over configurable domains.

plot_implicit

Plot implicit equations and inequalities.

Hardware Requirements

  • Python 3.12 or newer.

  • CPU-only systems are fully supported for the non-GPU tool families.

  • Optional CUDA-capable NVIDIA GPU for the GPU tool family.

  • If CUDA or CuPy is unavailable, GPU tools either fall back to CPU implementations or report that GPU acceleration is not available.

  • Memory needs depend on workload size. Large symbolic expressions, large matrices, and graph algorithms can require significant RAM.

Example Queries

  • Simplify (x^2 - 1) / (x - 1).

  • Solve x^2 - 5x + 6 = 0 over the reals.

  • Compute the definite integral of sin(x) from 0 to pi.

  • Find the eigenvalues of [[4, 1], [1, 3]].

  • Fit an exponential decay model to observed time-series data.

  • Compute the bootstrap confidence interval for a sample mean.

  • Factor 123456789 into prime powers.

  • Find the shortest weighted path from node A to node D.

  • Render the equation x^2 + y^2 = 1 as an implicit plot.

  • Multiply a batch of matrices with GPU acceleration if hardware is available.

Verification

uv run python -c "from math_mcp.server import main; print('Import OK')"
uv run python -c "from math_mcp.tools.symbolic import simplify; print('Tools OK')"
uv run pytest tests/ -v

Available Tools

51 tools
bootstrapC

Estimate bootstrap confidence intervals and uncertainty.

Inputs: data (required), statistic, n_resamples, confidence_level, +2 more. Returns: object

combinatoricsC

Evaluate combinatorial number sequences and counting functions.

Inputs: operation (required), n (required), k, as_formula. Returns: object

curve_fitC

Fit a nonlinear model to data with least squares.

Inputs: model (required), x_data (required), y_data (required), parameters, +3 more. Returns: object

describeC

Compute comprehensive descriptive statistics for a dataset.

Inputs: data (required), percentiles. Returns: object

diophantineC

Solve Diophantine equations over the integers.

Inputs: equation (required), method, bound. Returns: object

distributionC

Evaluate, fit, and sample probability distributions.

Inputs: name (required), operation (required), params, x, +3 more. Returns: object

dsolveC

Solve ordinary differential equations symbolically.

Inputs: equation (required), function, ics, hint. Returns: object

eigen_decompC

Compute eigenvalues and optionally eigenvectors.

Inputs: matrix (required), compute_vectors. Returns: object

expandA
Expand a mathematical expression.

Args:
    expression: SymPy-compatible expression.
                Examples: "(x+1)**3", "(a+b)*(c+d)"

Returns:
    Standard result dictionary containing the expanded expression.

Inputs: expression (required). Returns: object

factorB
Factor a mathematical expression over the rational numbers.

Args:
    expression: SymPy-compatible polynomial or rational expression.
                Examples: "x**3 - 6*x**2 + 11*x - 6", "x**4 - 1"

Returns:
    Standard result dictionary containing the factored expression.

Inputs: expression (required). Returns: object

factor_intC

Factor an integer into prime factors.

Inputs: n (required), method. Returns: object

find_rootC

Find a root of a scalar function numerically.

Inputs: expression (required), variable, method, bracket, +3 more. Returns: object

gcd_lcmC

Compute GCD, LCM, or Euclidean algorithm steps.

Inputs: numbers (required), operation, extended. Returns: object

gpu_eigen_batchC

Compute batched eigen decompositions with GPU fallback.

Inputs: matrices (required), symmetric, eigenvalues_only. Returns: object

gpu_fftC

Compute FFTs on GPU when beneficial, otherwise on CPU.

Inputs: data (required), operation, real_input, axis, +1 more. Returns: object

gpu_matrix_multiplyC

Multiply two matrices with GPU acceleration when beneficial.

Inputs: a (required), b (required), force_cpu. Returns: object

gpu_solveC

Solve batched linear systems with GPU fallback.

Inputs: a_batch (required), b_batch (required). Returns: object

graph_createC

Create a graph from a named specification, edge list, or adjacency matrix.

Inputs: specification (required), graph_type, n, edges, +2 more. Returns: object

graph_metricsC

Compute common graph-theoretic summary metrics.

Inputs: edges (required), weights, metrics, edge_weights_attr. Returns: object

hypothesis_testC

Perform a named statistical hypothesis test.

Inputs: test (required), data1 (required), data2, params, +2 more. Returns: object

interpolateC

Interpolate scattered one-dimensional data.

Inputs: x_data (required), y_data (required), method, x_eval, +2 more. Returns: object

inverse_laplaceC

Compute the inverse Laplace transform.

Inputs: expression (required), s_var, t_var. Returns: object

is_primeC

Test whether an integer is prime.

Inputs: n (required), rigorous. Returns: object

laplace_transformC

Compute the Laplace transform of a time-domain expression.

Inputs: expression (required), t_var, s_var, noconds. Returns: object

limitC

Compute limits of expressions.

Inputs: expression (required), variable, point, direction. Returns: object

lstsqC

Compute a least-squares solution to Ax ≈ b.

Inputs: a (required), b (required), method, regularization. Returns: object

matrix_decomposeC

Compute standard matrix decompositions.

Inputs: matrix (required), decomposition. Returns: object

matrix_infoC

Compute structural and numerical information about a matrix.

Inputs: matrix (required). Returns: object

matrix_multiplyC

Multiply two matrices A @ B.

Inputs: a (required), b (required). Returns: object

max_flowC

Compute maximum flow in a capacitated directed graph.

Inputs: edges (required), source (required), sink (required), capacities (required). Returns: object

modularD

Perform modular arithmetic operations.

Inputs: operation (required), a (required), b, mod, +1 more. Returns: object

numerical_integrateC

Numerically integrate a scalar function.

Inputs: expression (required), variable, lower, upper, +5 more. Returns: object

ode_solveC

Solve an initial value problem numerically.

Inputs: dydt (required), y0 (required), t_span (required), variable, +7 more. Returns: object

partitionsC

Count or list integer partitions.

Inputs: n (required), operation, k. Returns: object

plot_functionC

Plot one or more functions as 2D curves.

Inputs: expression (required), variable, x_range, num_points, +6 more. Returns: object

plot_implicitC

Plot implicit equations or inequalities in x and y.

Inputs: equation (required), x_range, y_range, grid_size, +2 more. Returns: object

primes_rangeC

List primes in a range or generate the first N primes.

Inputs: start (required), end (required), limit. Returns: object

random_sampleC

Generate random samples from NumPy distributions.

Inputs: distribution, params, size, dimensions, +1 more. Returns: object

regressionC

Perform regression analysis for linear, polynomial, or logistic models.

Inputs: x (required), y (required), model, degree, +3 more. Returns: object

render_mathB

Render arbitrary LaTeX math to a PNG data URI.

Inputs: latex (required), fontsize, dpi. Returns: object

seriesC

Compute Taylor or Laurent series expansions.

Inputs: expression (required), variable, point, order. Returns: object

shortest_pathC

Compute shortest paths on an edge-list graph.

Inputs: edges (required), source (required), target, weights, +2 more. Returns: object

simplifyA
Simplify a mathematical expression algebraically.

Args:
    expression: A SymPy-compatible expression string.
                Examples: "(x**2 - 1)/(x - 1)", "sin(x)**2 + cos(x)**2"

Returns:
    Standard result dictionary containing the simplified expression.

Inputs: expression (required). Returns: object

solveA
Solve equations or systems of equations symbolically.

Args:
    equation: Equation string or comma-separated system.
    variables: Optional variable names to solve for.
    domain: "real", "complex", "integer", or "positive".
    show_steps: Whether to include a short human-readable explanation.

Inputs: equation (required), variables, domain, show_steps. Returns: object

solve_linearC

Solve a square linear system Ax = b.

Inputs: a (required), b (required), method. Returns: object

spanning_treeC

Compute a minimum or maximum spanning tree.

Inputs: edges (required), weights, maximize, edge_weights_attr. Returns: object

symbolic_diffC

Compute symbolic derivatives of arbitrary order.

Inputs: expression (required), variable, order, show_steps. Returns: object

symbolic_integrateC

Compute symbolic indefinite or definite integrals.

Inputs: expression (required), variable, limits, show_steps, +1 more. Returns: object

symbolic_productC

Compute symbolic finite or infinite products.

Inputs: expression (required), index, start, end. Returns: object

symbolic_sumC

Compute symbolic finite or infinite summations.

Inputs: expression (required), index, start, end. Returns: object

to_latexC

Convert a mathematical expression to LaTeX and render it.

Inputs: expression (required), style. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.5/5.0

    Scored across 51 tools

    Disambiguation3/5

    Many tools have distinct purposes, but there is overlap between symbolic and numeric solvers (solve, solve_linear, find_root, dsolve, ode_solve) and between fitting tools (regression, curve_fit, lstsq). Descriptions often clarify, but an agent could still misselect.

    Naming Consistency3/5

    Tool names follow a mix of patterns: single verbs (factor, simplify), verb_noun (factor_int, find_root), and noun_verb (graph_create, matrix_decompose). Some use abbreviations (gpu_fft) or adjectives (max_flow). The inconsistency is notable across 51 tools.

    Tool Count2/5

    With 51 tools, the set is large and contains redundancies (e.g., multiple ODE solvers, multiple rendering tools). While the domain is broad, the granularity could be reduced for better usability.

    Completeness4/5

    The tool set covers a wide range of mathematical domains: symbolic, numeric, statistical, linear algebra, graph theory, number theory, transforms, and plotting. Minor gaps exist (e.g., optimization, special functions) but overall it's very comprehensive.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides a comprehensive set of mathematical functions as MCP tools, enabling language models to perform calculations including arithmetic, trigonometry, logarithms, and more.
      1
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables advanced mathematics operations including linear algebra, vector math, symbolic computation, and calculus through MCP tools. Designed for use with Claude and other MCP-compatible LLMs.
      19
      2
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Provides 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 PyPI
      8
      MIT
    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      MCP server providing Claude with advanced mathematical capabilities including symbolic math, statistics, and matrix operations.
      -