Skip to main content
Glama
math-reasoning-mcp

math-reasoning-mcp

by TeleEng

Math Reasoning MCP

Tests

Math-Aware AI Engine

A Model Context Protocol (MCP) server that gives AI agents a deterministic mathematical brain. Instead of hallucinating algebra, the agent delegates symbolic computation to a SymPy engine over JSON-RPC — getting exact, verifiable results every time.

Built for engineers, researchers, and students working in Algebra, Calculus, Signals & Systems, and Digital Signal Processing (DSP).


Why This Exists

Large Language Models are statistical text predictors. They can describe a Laplace transform, but when asked to execute one — especially a multi-step derivation involving chain rules, frequency shifts, and polynomial expansion — they routinely:

  • Drop negative signs

  • Hallucinate polynomial terms

  • Produce plausible-looking but wrong final answers

Models with built-in code execution (like Gemini) work around this by writing and running Python scripts in a proprietary sandbox. This MCP provides the same deterministic SymPy power as a universal, open standard — pluggable into any AI agent, no proprietary sandbox required.


Related MCP server: ReasonForge

Proof of Value

Problem: Compute the Laplace Transform of $f(t) = t^2 e^{-3t} \sin(2t)$ and find the system poles.

Raw LLM (no tools)

With Math MCP

Accuracy

❌ Fails on the 2nd-derivative chain rule. Wrong poles.

✅ Exact: $\frac{4(3(s+3)^2 - 4)}{((s+3)^2 + 4)^3}$, poles at $-3 \pm 2i$

Tokens

~800+ (lengthy, incorrect derivation)

~150 (two tool calls + final answer)

Time

Slow (multi-step generation)

< 2 seconds


21 Tools

📐 Core Algebra & Calculus

Tool

Description

Example

parse_latex_to_sympy

Convert LaTeX → SymPy

\frac{d}{dx} x^2 → Derivative(x**2, x)

simplify_expression

Simplify expressions

sin(x)**2 + cos(x)**2 → 1

solve_equation

Solve for a variable

s**2 + 6*s + 13 → [-3-2i, -3+2i]

evaluate_expression

Numeric evaluation

sqrt(2) + pi → 4.55...

differentiate

Symbolic derivative (nth-order)

x**3, order=2 → 6*x

integrate_expression

Symbolic integral

exp(-x) → -exp(-x)

partial_fraction_decomposition

Partial fractions

1/((s+1)*(s+2)) → 1/(s+1) - 1/(s+2)

📡 Signals & Continuous Transforms

Tool

Description

Example

laplace_transform_signal

$f(t) \to F(s)$

t**2 * exp(-3*t) → 2/(s+3)**3

inverse_laplace_transform_signal

$F(s) \to f(t)$

1/(s+3) → exp(-3*t)

fourier_transform_signal

$f(t) \to F(\omega)$

exp(-a*t**2) → sqrt(pi)*exp(-w²/(4a))/sqrt(a)

inverse_fourier_transform_signal

$F(\omega) \to f(t)$

Inverse of the above

continuous_convolution

$(f * g)(t)$ with Heaviside support

Causal signals handled automatically

💻 Discrete-Time & DSP

Tool

Description

Example

z_transform_signal

One-sided Z-transform

a**n → z/(z - a)

dtft_signal

Discrete-Time Fourier Transform

0.5**n → 1/(1 - 0.5*exp(-jW))

compute_fft

Numerical FFT (numpy)

[1,1,0,0] → [2+0j, 1-1j, 0+0j, 1+1j]

uniform_quantization

ADC quantization simulation

3.14V, 4-bit, 0–5V → Δ=0.3125, SQNR=25.84 dB

⚙️ System Analysis

Tool

Description

Example

poles_and_zeros

Poles & zeros of $H(s)$ or $H(z)$

(s-2)/((s+1)*(s+3)) → Zeros: [2], Poles: [-3,-1]

check_linearity

Prove/disprove linearity

x**2 → Linear: False with symbolic proof

check_time_invariance

Prove/disprove TI

t*x → Time-Invariant: False with reasoning

Both check_linearity and check_time_invariance support:

  • Memoryless systems: expressions in x and t (e.g., x**2, t*x + 5)

  • Difference equations: expressions in x_n, x_n1, x_n2, n (e.g., x_n + x_n1)

check_linearity also detects affine systems (constant offset makes it non-linear).

🧮 Step-by-Step Solvers

Tool

Description

step_by_step_laplace

Derives the Laplace transform showing each property applied (linearity, frequency shift, time multiplication) with verification

step_by_step_algebra

Solves equations showing expansion, factoring, discriminant analysis, and verification of each root

These tools don't just return the answer — they show the derivation, making them ideal for education and debugging.


Testing

55 tests covering all 21 tools, edge cases, and error handling:

uv run pytest tests/ -v
tests/test_tools.py   55 passed in 4.38s

Tests cover:

  • All core algebra operations (simplify, solve, differentiate, integrate)

  • All transform tools (Laplace, Fourier, Z-transform, FFT)

  • System analysis (linearity, time-invariance) for both memoryless and memory systems

  • Affine vs. linear detection

  • Step-by-step output structure

  • Structured error handling for malformed input


Installation

Requires uv.

git clone https://github.com/TeleEng/math-reasoning-mcp.git
cd math-reasoning-mcp
uv sync

Usage

Add to your MCP client configuration:

{
  "mcpServers": {
    "math-reasoning": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "<absolute-path-to-this-repository>",
        "math-reasoning-mcp"
      ]
    }
  }
}

Compatible with any MCP client: Claude Desktop, Cursor, Windsurf, Antigravity, custom agents, etc.

Architecture

┌──────────────┐     JSON-RPC      ┌──────────────────┐
│   AI Agent   │ ◄──── MCP ──────► │  Math MCP Server │
│  (any LLM)   │   (stdio/SSE)     │   (SymPy+NumPy)  │
└──────────────┘                   └──────────────────┘
       │                                    │
  Reads files,                        Deterministic
  understands                         symbolic math
  context                             engine

Tech Stack

  • SymPy — Symbolic mathematics engine

  • NumPy — Numerical computation (FFT, quantization)

  • MCP SDK — Model Context Protocol server framework

  • uv — Fast, reproducible Python dependency management

  • pytest — Test framework (55 tests)

License

MIT

Available Tools

21 tools
check_linearityA

Checks if a system is linear using the superposition principle.

For system_type='memoryless': expression is in terms of 'x' and optionally 't'. Example: 'x**2', '3x', 'tx + 5'

For system_type='difference': expression is a difference equation in terms of 'x_n', 'x_n1' (x[n-1]), 'x_n2' (x[n-2]), 'y_n1' (y[n-1]), etc. Example: 'x_n + x_n1' (y[n] = x[n] + x[n-1])

Returns whether the system is linear with a symbolic proof.

Inputs: system_expression (required), system_type. Returns: result

check_time_invarianceA

Checks if a system is time-invariant.

For system_type='memoryless': expression is in terms of 'x' and 't'. Computes y(t-t0) and T{x(t-t0)} and checks equality.

For system_type='difference': expression is in terms of 'x_n', 'x_n1', 'n'. A system depending explicitly on 'n' is time-variant. Computes y[n-n0] and T{x[n-n0]} and checks equality.

Returns whether the system is time-invariant with a symbolic proof.

Inputs: system_expression (required), system_type. Returns: result

compute_fftB

Computes the Fast Fourier Transform (FFT) of a discrete numerical sequence using numpy. Returns complex-valued frequency bins.

Inputs: sequence (required). Returns: result

continuous_convolutionA

Computes the continuous-time convolution (f * g)(t) for causal signals. Automatically handles Heaviside (unit step) functions. Signals are assumed causal (zero for t < 0) unless they already contain Heaviside terms.

Inputs: f_t (required), g_t (required). Returns: result

differentiateB

Computes the nth-order derivative of an expression with respect to a variable.

Inputs: variable (required), expression (required), order. Returns: result

dtft_signalC

Computes the Discrete-Time Fourier Transform (DTFT) of x[n]. Returns X(W) where W is omega.

Inputs: expression (required). Returns: result

evaluate_expressionA

Evaluates a symbolic expression to a numeric result (floating-point).

Inputs: expression (required). Returns: result

fourier_transform_signalB

Computes the continuous Fourier transform of a signal f(t). Returns F(w).

Inputs: expression (required). Returns: result

integrate_expressionA

Computes the indefinite integral of an expression with respect to a variable.

Inputs: variable (required), expression (required). Returns: result

inverse_fourier_transform_signalA

Computes the Inverse Fourier transform of F(w). Returns f(t).

Inputs: expression (required). Returns: result

inverse_laplace_transform_signalB

Computes the Inverse Laplace transform of F(s). Returns f(t).

Inputs: expression (required). Returns: result

laplace_transform_signalA

Computes the Laplace transform of a causal signal f(t). Returns F(s) and the convergence condition.

Inputs: expression (required). Returns: result

parse_latex_to_sympyA

Parses a LaTeX math string into a SymPy expression string, which can be used in other tools.

Inputs: latex_str (required). Returns: result

partial_fraction_decompositionB

Performs Partial Fraction Decomposition on a rational function (crucial for inverse transforms).

Inputs: variable (required), expression (required). Returns: result

poles_and_zerosA

Finds the poles and zeros of a system transfer function H(s) or H(z).

Inputs: variable (required), transfer_function (required). Returns: result

simplify_expressionC

Simplifies a mathematical expression using algebraic identities.

Inputs: expression (required). Returns: result

solve_equationB

Solves an equation for a given variable. Pass equation as 'lhs - rhs' (set equal to 0) or use Eq(lhs, rhs).

Inputs: equation (required), variable (required). Returns: result

step_by_step_algebraA

Solves an equation step-by-step, showing intermediate algebraic manipulations. Returns the solution process including factoring, simplification, and final roots.

Inputs: variable (required), expression (required). Returns: result

step_by_step_laplaceA

Solves the Laplace transform of f(t) step-by-step, showing each transformation property applied (linearity, frequency shift, time multiplication). Returns both the derivation steps and the final answer.

Inputs: expression (required). Returns: result

uniform_quantizationA

Simulates uniform quantization of a continuous value. Returns the quantized value, quantization error, step size (Δ), and theoretical maximum SQNR.

Inputs: bits (required), v_max (required), v_min (required), value (required). Returns: result

z_transform_signalA

Computes the one-sided Z-transform of a discrete signal x[n]. Returns X(z).

Inputs: expression (required). Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 21 tools

    Disambiguation4/5

    Each tool targets a distinct operation or transform family, and the descriptions clearly separate direct computation from step-by-step variants. The main ambiguity is between solve_equation/step_by_step_algebra and laplace_transform_signal/step_by_step_laplace, but the stated outputs make the distinction usable.

    Naming Consistency3/5

    Transform and check tool families are consistent (laplace_transform_signal, inverse_laplace_transform_signal, check_linearity, check_time_invariance), but the overall set mixes verb_noun names, bare verbs like differentiate, and noun-phrase names like poles_and_zeros and uniform_quantization. The naming is readable and snake_case throughout, but not a uniform verb_noun pattern.

    Tool Count3/5

    With 21 tools, the server is on the heavy side and overlaps somewhat with redundant step-by-step variants. Most tools do serve distinct math or signals purposes, but the count sits in the borderline 16-25 range rather than being tightly scoped.

    Completeness3/5

    Core algebra, calculus, convolution, and major transforms are covered, including inverse Laplace and Fourier transforms. However, there are notable gaps such as inverse Z-transform, inverse DTFT, definite integration, limits, and series support, which leave dead ends for some signal workflows.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides a suite of deterministic math tools powered by SymPy to handle algebra, calculus, linear algebra, and statistics via the Model Context Protocol. It enables smaller language models to delegate complex computations to a verified symbolic backend for accurate and reliable results.
      Apache 2.0
    • A
      license
      A
      quality
      D
      maintenance
      A secure mathematical computation sandbox that enables LLMs to perform symbolic math operations like algebra, calculus, and equation solving via SymPy. It features low-latency execution through pre-warmed process pools and provides standardized JSON outputs for reliable agent integration.
      1
      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