Math MCP Server
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 Server Solve x^2 - 4 = 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.
@yasogan/math-mcp
A comprehensive Model Context Protocol server that exposes 8 mathematical tools to any MCP-compatible AI agent. Provides arithmetic, symbolic algebra, calculus, matrix operations, statistics, probability distributions, and unit conversions — no code required from the agent side.
Contents
Related MCP server: Calculator MCP Server
Installation
Using npx (recommended)
No installation required — run directly:
{
"mcpServers": {
"math": {
"command": "npx",
"args": ["-y", "@yasogan/math-mcp"]
}
}
}Local installation
npm install -g @yasogan/math-mcp
# or
pnpm add -g @yasogan/math-mcpThen use directly:
{
"mcpServers": {
"math": {
"command": "@yasogan/math-mcp"
}
}
}Client configuration
Client | Config Location |
Claude Desktop |
|
OpenCode |
|
Zed |
|
Cursor |
|
Quick Start
Example prompt to an AI agent:
"What's the determinant of a 3x3 matrix [[1,2,3],[4,5,6],[7,8,9]]?"
The agent will call:
matrix({ op: "determinant", a: [[1,2,3],[4,5,6],[7,8,9]] })→ Returns 0
Tool Reference
evaluate
Purpose: Evaluate mathematical expressions using either numeric (mathjs) or symbolic (Algebrite) computation.
Parameter | Type | Required | Description |
| string | Yes | The mathematical expression to evaluate |
|
| No | Default: |
Numeric mode examples:
// Arithmetic
evaluate({ expression: "2^10 + sqrt(144)" }); // → 1036
evaluate({ expression: "factorial(10)" }); // → 3628800
evaluate({ expression: "gcd(48, 18)" }); // → 6
// Trigonometry
evaluate({ expression: "sin(pi/6)" }); // → 0.5
evaluate({ expression: "cos(45 deg)" }); // → 0.70710678
evaluate({ expression: "atan2(1, 1)" }); // → 0.78539816
// Complex numbers
evaluate({ expression: "(2+3i)*(1-i)" }); // → 5+i
evaluate({ expression: "abs(3+4i)" }); // → 5
// Matrices
evaluate({ expression: "det([[1,2],[3,4]])" }); // → -2
evaluate({ expression: "inv([[2,0],[0,4]])" }); // → [[0.5,0],[0,0.25]]
// BigNumber precision
evaluate({ expression: "bignumber(2)^100" }); // → 1.2676506002282294e30 (exact)
// Units
evaluate({ expression: "180 km/h to m/s" }); // → 50 m/sSymbolic mode examples:
// Derivatives (symbolic)
evaluate({ expression: "diff(x^3 + 2*x, x)", mode: "symbolic" }); // → 3*x^2+2
// Integrals (symbolic)
evaluate({ expression: "integrate(x^2, x)", mode: "symbolic" }); // → 1/3*x^3
// Simplification
evaluate({ expression: "expand((x+1)*(x-1))", mode: "symbolic" }); // → x^2-1solve
Purpose: Solve algebraic equations for a specified variable. Returns all roots including complex ones.
Parameter | Type | Required | Description |
| string | Yes | Equation containing exactly one |
| string | Yes | Variable to solve for (e.g., |
Examples:
// Quadratic equation — returns both roots
solve({ equation: "x^2 - 5x + 6 = 0", variable: "x" });
// → { result: "2, 3", numeric: 2, latex: "x = 2, x = 3" }
// Cubic with complex roots
solve({ equation: "x^3 - 1 = 0", variable: "x" });
// → { result: "1, (-0.5)+(-0.8660254037844386*i), (-0.5)+(0.8660254037844386*i)", ... }
// Find specific root
solve({ equation: "x^2 - 4 = 0", variable: "x" });
// → { result: "2, -2", numeric: 2, latex: "x = 2, x = -2" }Constraints:
Only polynomial equations supported
Exactly one
=requiredNo inequalities (
<,>,<=,>=)
simplify
Purpose: Simplify algebraic expressions using mathematical rules (combine like terms, evaluate constants, apply trig identities).
Parameter | Type | Required | Description |
| string | Yes | Expression to simplify |
Examples:
simplify({ expression: "sin(x)^2 + cos(x)^2" }); // → 1
simplify({ expression: "2*x + 3*x" }); // → 5*x
simplify({ expression: "3 + 4 * 2" }); // → 11
simplify({ expression: "(x+1)^2 - (x^2 + 2*x + 1)" }); // → 0
simplify({ expression: "exp(ln(x))" }); // → xfactor
Purpose: Factor polynomial expressions into irreducible components.
Parameter | Type | Required | Description |
| string | Yes | Expression to factor |
Examples:
factor({ expression: "x^2 - 4" }); // → (x+2)*(x-2)
factor({ expression: "x^3 - 6*x^2 + 11*x - 6" }); // → (x-1)*(x-2)*(x-3)
factor({ expression: "12" }); // → 2^2*3
factor({ expression: "x^2 + 5*x + 6" }); // → (x+2)*(x+3)
factor({ expression: "a^2 - b^2" }); // → (a+b)*(a-b)expand
Purpose: Expand factored or compound expressions into polynomial form.
Parameter | Type | Required | Description |
| string | Yes | Expression to expand |
Examples:
expand({ expression: "(x+1)^3" }); // → x^3+3*x^2+3*x+1
expand({ expression: "(a+b)*(a-b)" }); // → a^2-b^2
expand({ expression: "(x+2)*(x-2)" }); // → x^2-4
expand({ expression: "2*(x+y)" }); // → 2*x+2*ymatrix
Purpose: Perform matrix and vector operations.
Parameter | Type | Required | Description |
| string | Yes | Operation name |
| number[][] | Yes | First matrix/vector |
| number[][] | No | Second matrix/vector (required for binary ops) |
Supported operations:
Operation | Description | Requires |
| Matrix multiplication A × B | Yes |
| Matrix addition A + B | Yes |
| Matrix subtraction A - B | Yes |
| Matrix inverse A⁻¹ | No |
| Matrix transpose Aᵀ | No |
| Determinant |A| | No |
| Eigenvalues of A | No |
| Eigenvectors of A | No |
| Matrix rank | No |
| Frobenius norm ‖A‖ | No |
| Matrix trace | No |
| Dot product of vectors | Yes |
| Cross product of 3D vectors | Yes |
Examples:
// Determinant
matrix({
op: "determinant",
a: [
[1, 2],
[3, 4],
],
});
// → -2
// Inverse
matrix({
op: "inverse",
a: [
[4, 7],
[2, 6],
],
});
// → [[0.6,-0.7],[-0.2,0.4]]
// Eigenvalues
matrix({
op: "eigenvalues",
a: [
[2, 1],
[1, 2],
],
});
// → [3, 1]
// Matrix multiplication
matrix({
op: "multiply",
a: [
[1, 2],
[3, 4],
],
b: [
[5, 6],
[7, 8],
],
});
// → [[19,22],[43,50]]
// Dot product
matrix({ op: "dot", a: [[1, 2, 3]], b: [[4, 5, 6]] });
// → 32
// Cross product (3D vectors)
matrix({ op: "cross", a: [[1, 0, 0]], b: [[0, 1, 0]] });
// → [0, 0, 1]Note: SVD is not supported. Use eigenvalues for similar decomposition.
statistics
Purpose: Descriptive statistics, probability distributions, and linear regression.
Parameter | Type | Required | Description |
| string | Yes | Operation name |
| number[] | Conditional* | Array of numbers (required for descriptive stats & regression) |
| object | Conditional* | Distribution parameters (required for distributions) |
Descriptive operations (use data):
Operation | Description | Notes |
| Arithmetic mean | |
| Median value | |
| Most frequent value | Returns first if multiple |
| Sample standard deviation | Uses n-1 denominator |
| Sample variance | Uses n-1 denominator |
| Minimum value | |
| Maximum value | |
| Sum of all values | |
| Quantile value | Requires |
| Median absolute deviation | |
| Sample skewness | Requires n ≥ 3 |
| Sample kurtosis | Requires n ≥ 4 |
Distribution operations (use args):
Operation | Parameters | Description |
|
| Probability density |
|
| Cumulative distribution |
|
| Inverse CDF (quantile) |
|
| Probability mass |
|
| Cumulative distribution |
|
| Probability mass |
|
| Cumulative distribution |
|
| Student's t PDF |
|
| Student's t CDF |
|
| Chi-squared PDF |
|
| Chi-squared CDF |
Regression operations (use data):
Operation | Description |
| Simple linear regression (y = mx + b), x auto-indexed as [0,1,2,...] |
Examples:
// Descriptive statistics
statistics({ op: "mean", data: [4, 8, 15, 16, 23, 42] }); // → 18
// Standard deviation
statistics({ op: "std", data: [2, 4, 4, 4, 5, 5, 7, 9] });
// → 2.138
// Quantile (75th percentile)
statistics({ op: "quantile", data: [1, 2, 3, 4, 5], args: { prob: 0.75 } });
// → 4
// Normal PDF
statistics({
op: "normal_pdf",
args: { x: 0, mean: 0, std: 1 },
});
// → 0.398942
// Normal CDF (probability below z-score)
statistics({
op: "normal_cdf",
args: { x: 1.96, mean: 0, std: 1 },
});
// → 0.975
// Inverse normal (find z-score for 97.5th percentile)
statistics({
op: "normal_inv",
args: { p: 0.975, mean: 0, std: 1 },
});
// → 1.959964
// Binomial probability (exactly 3 heads in 10 flips)
statistics({
op: "binomial_pmf",
args: { k: 3, n: 10, p: 0.5 },
});
// → 0.117188
// Poisson (events in time interval)
statistics({
op: "poisson_pmf",
args: { k: 3, lambda: 2 },
});
// → 0.180447
// Linear regression
statistics({
op: "linear_regression",
data: [2, 4, 6, 8, 10],
});
// → { slope: 2, intercept: 0 }units
Purpose: Convert between physical units of the same dimension.
Parameter | Type | Required | Description |
| string | Yes | Format: |
Supported unit categories:
Category | Units |
Length |
|
Mass |
|
Temperature |
|
Pressure |
|
Energy |
|
Speed |
|
Area |
|
Volume |
|
Time |
|
Examples:
units({ expression: "5 km to miles" }); // → 3.10686 miles
units({ expression: "100 degF to degC" }); // → 37.7778 degC
units({ expression: "1 atm to Pa" }); // → 101325 Pa
units({ expression: "60 mph to km/h" }); // → 96.5606 km/h
units({ expression: "1000 kg to lb" }); // → 2204.62 lb
units({ expression: "1 year to days" }); // → 365.242 daysExpression Syntax Guide
Arithmetic Operators
Symbol | Operation | Example |
| Addition |
|
| Subtraction |
|
| Multiplication |
|
| Division |
|
| Exponentiation |
|
| Modulo |
|
Functions
sqrt(x); // Square root
abs(x); // Absolute value
log(x); // Natural logarithm
log10(x); // Base-10 logarithm
exp(x); // e^x
factorial(n); // n!
gcd(a, b); // Greatest common divisor
lcm(a, b); // Least common multiple
floor(x); // Round down
ceil(x); // Round up
round(x); // Round to nearestTrigonometry
(sin(x), cos(x), tan(x)); // Standard functions
(asin(x), acos(x), atan(x)); // Inverses
atan2(y, x); // Two-argument atan
(sinh(x), cosh(x), tanh(x)); // Hyperbolic
(deg, rad); // Unit conversionConstants
pi; // 3.14159...
e; // 2.71828...
i; // Imaginary unitSpecial Values
(Infinity, -Infinity);
NaN;Development
# Install dependencies
pnpm install
# Build TypeScript
pnpm build
# Run tests
pnpm test
# Run in development (no build required)
pnpm dev
# Run in development with watch
pnpm test:watchTech stack: TypeScript, MCP SDK, mathjs, Algebrite, Vitest
License
MIT
Available Tools
8 toolsevaluateA
Evaluates any mathematical expression using mathjs. Supports arithmetic, trigonometry (sin, cos, tan, pi, e), algebra, calculus (derivative, integrate), complex numbers (2+3i), fractions, BigNumber precision (bignumber()), matrices (det, inv, transpose), logic, and units. Use mode='symbolic' for exact symbolic results via Algebrite. Examples: '2^10', 'sin(pi/4)', 'det([[1,2],[3,4]])', 'derivative("x^3", "x")', 'integrate(x^2, x, 0, 1)'
Inputs: expression (required), mode.
expandB
Expands a factored or compound expression using Algebrite. Examples: '(x+1)^3', '(a+b)(a-b)', '(x+2)(x-2)'
Inputs: expression (required).
factorA
Factors a polynomial expression using Algebrite. Returns the factored form. Examples: 'x^2 - 4' → '(x+2)(x-2)', 'x^3 - 6x^2 + 11*x - 6', '12' → prime factorization
Inputs: expression (required).
matrixC
Performs matrix operations. Ops: multiply, add, subtract, inverse, transpose, determinant, eigenvalues, eigenvectors, rank, norm, trace, cross (3D vectors), dot (vectors). SVD is not currently supported. Binary ops (multiply/add/subtract) require both 'a' and 'b'. Inputs are 2D number arrays. Examples: op='determinant', a=[[1,2],[3,4]]
Inputs: op (required), a (required), b.
simplifyA
Simplifies a mathematical expression using mathjs rules. Combines like terms, applies trig identities (sin²+cos²=1), and reduces constants. Examples: 'sin(x)^2 + cos(x)^2', '2x + 3x', '3 + 4 * 2'
Inputs: expression (required).
solveA
Solves an equation for a variable. Format equation as 'lhs = rhs' (e.g. 'x^2 - 4 = 0'). Returns all solutions including complex ones. Examples: 'x^2 - 4 = 0' with variable 'x', 'x^3 - 6x^2 + 11x - 6 = 0' with variable 'x'
Inputs: equation (required), variable (required).
statisticsA
Computes descriptive statistics and probability distributions. Descriptive ops use 'data' array: mean, median, mode, std, variance, min, max, sum, quantile (needs args.prob), mad, skewness (n≥3), kurtosis (n≥4). Distribution ops use 'args': normal_pdf/cdf/inv, binomial_pmf/cdf, poisson_pmf/cdf, t_pdf/cdf, chi2_pdf/cdf. Also: linear_regression (uses 'data' as y-values and auto-indexes x as [0,1,2,...,n-1]). Args vary by op — e.g. normal_pdf needs {x, mean, std}, binomial_pmf needs {k, n, p}
Inputs: op (required), data, args.
unitsA
Converts between units. Format: ' to '. Supported: length (km, miles, m, ft, in), mass (kg, lb, g, oz), temperature (degC, degF, K), pressure (Pa, atm, bar, psi), energy (J, kWh, cal), speed (km/h, mph, m/s), area (m^2, acre, ft^2). Examples: '5 km to miles', '100 degF to degC', '1 atm to Pa'
Inputs: expression (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Most tools have distinct purposes: evaluate for general evaluation, expand for expansion, factor for factoring, etc. However, evaluate is quite broad and could be confused with simplify or expand for certain expressions, though descriptions mitigate this.
Tool names are all single words but lack a consistent pattern: some are verbs (evaluate, expand, factor, simplify, solve), while others are nouns (matrix, statistics, units). The naming is readable but not uniform.
With 8 tools covering arithmetic, algebra, matrices, statistics, and unit conversion, the count feels well-scoped for a math server. Each tool serves a clear purpose without redundancy.
The tool set covers core mathematical operations including symbolic manipulation, matrix operations, statistics, and units. Minor gaps exist, such as no dedicated tool for solving systems of equations or advanced calculus like limits, but agents can often work around these using existing tools.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Tested financial & practical calculators as free, no-auth MCP tools for AI agents.
The Mercado Pago MCP Server implements the Model Context Protocol to provide AI agents and LLMs with access to Mercado Pago's APIs and tools within compatible development environments. It acts as an intermediary that translates Mercado Pago resources into executable functions (tools) that AI applications can invoke to perform actions and automate flows. The server simplifies integration, enables using documentation to implement or improve code, and optimizes operations through natural language interactions without manual implementations.
Related MCP Servers
- AlicenseAqualityCmaintenanceA Model Context Protocol server that provides basic mathematical and statistical functions to LLMs, enabling them to perform accurate numerical calculations through a simple API.13191MIT
- AlicenseNot gradedqualityDmaintenanceA Python-based MCP server that provides a suite of basic arithmetic tools, including addition, square roots, and percentage calculations, for AI assistants. It enables models to perform precise mathematical operations through the Model Context Protocol.MIT
- AlicenseCqualityDmaintenanceA comprehensive MCP server that turns any AI assistant into a powerful mathematical computation engine, providing 52 advanced functions, 158 unit conversions, financial calculations, and secure AST-based evaluation.1816MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server providing 150+ mathematical functions across arithmetic, trigonometry, statistics, unit conversions, and more, consolidated into 15 powerful tools for seamless integration with VS Code Copilot and other MCP-compatible clients.MIT