SageMath

v0.12.0
io.github.XBP-Europe/sagemath-mcp Checked 2 days ago Published 3 days ago

Stateful SageMath MCP server with 40 tools and a sandboxed Sage session per client.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

solve_equation Solve Equation

Solve an equation or system of equations

ParameterTypeDescription
equation *Equation string (e.g., 'x^2 - 1 = 0') or list of equations for systems
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…
variableVariable or list of variables to solve for

matrix_multiply Matrix Multiply

Multiply two matrices and return the result as nested lists

ParameterTypeDescription
matrix_a *arrayLeft matrix (rows of numbers). Integers stay exact; pass values from 2^53 up as decimal strings, e.g. "9007199254740993".
matrix_b *arrayRight matrix (rows of numbers). Integers stay exact.
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

matrix_operation Matrix Operation

Linear algebra on one matrix: determinant, inverse, eigenvalues, rank, reduced row echelon form, transpose. Prefer this over evaluate_sage.

ParameterTypeDescription
matrix *arrayMatrix as nested list of numbers. Integers stay exact; pass values from 2^53 up as decimal strings.
operation *stringOne of: determinant, inverse, eigenvalues, rank, rref, transpose
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

boolean_algebra_operation Boolean Algebra Operation

Boolean polynomials over GF(2): evaluate, list variables, degree, and zero/one tests. Prefer this over evaluate_sage for boolean algebra.

ParameterTypeDescription
expression *stringBoolean expression (e.g. 'x*y + x*z + y*z')
operation *stringOne of: evaluate, variables, degree, is_zero, is_one, reduce
num_variablesintegerNumber of boolean variables
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

polynomial_ring_operation Polynomial Ring Operation

Polynomial ring operations: construct rings and compute Groebner bases, ideals, quotients

ParameterTypeDescription
operation *stringOne of: groebner_basis, ideal_dimension, ideal_variety, reduce, is_groebner
polynomials *arrayPolynomials as strings, e.g. ['a^2+b', 'b^2-1']
ring_vars *arrayVariable names, e.g. ['a', 'b', 'c']
base_ringstringBase ring
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

differentiate_expression Differentiate Expression

Differentiate an expression with respect to a variable

ParameterTypeDescription
expression *stringExpression to differentiate
orderintegerOrder of differentiation (1 = first, 2 = second, etc.)
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…
variablestringVariable for differentiation

integrate_expression Integrate Expression

Integrate an expression (indefinite or definite with bounds)

ParameterTypeDescription
expression *stringExpression to integrate
lower_boundLower bound for definite integral (e.g., '0', '-oo')
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…
upper_boundUpper bound for definite integral (e.g., '1', 'oo')
variablestringIntegration variable

limit_expression Limit Expression

Compute the limit of an expression

ParameterTypeDescription
expression *stringExpression to take the limit of
directionDirection: 'plus' (right), 'minus' (left), or omit for both
pointstringPoint to approach (e.g., '0', 'oo', '-oo')
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…
variablestringVariable approaching the point

series_expansion Series Expansion

Compute a Taylor/Laurent series expansion

ParameterTypeDescription
expression *stringExpression to expand in series
orderintegerNumber of terms in the expansion
pointstringPoint around which to expand
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…
variablestringVariable for expansion

solve_ode Solve Ode

Solve an ordinary differential equation of any order, returning the general solution with arbitrary constants. Prefer this over evaluate_sage.

ParameterTypeDescription
equation *stringODE string, e.g., "diff(y(x),x) + y(x) = 0"
functionstringDependent function name (e.g., 'y')
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…
variablestringIndependent variable (e.g., 'x')

symbolic_sum Symbolic Sum

Closed form of a symbolic sum or product over an index variable, including infinite series. Prefer this over evaluate_sage for summations.

ParameterTypeDescription
expression *stringExpression to sum (e.g. '1/n^2')
lowerstringLower bound (e.g. '1')
productbooleanIf true, compute a product instead of a sum
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…
upperstringUpper bound (e.g. 'oo' for infinity)
variablestringIndex variable (e.g. 'n')

vector_calculus_operation Vector Calculus Operation

Vector calculus operations: gradient, divergence, curl, laplacian

ParameterTypeDescription
expression *Scalar field (string) for gradient/laplacian, or vector field components (list) for divergence/curl
operation *stringOne of: gradient, divergence, curl, laplacian
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…
variablesVariable names (e.g. ['x', 'y', 'z'])

evaluate_sage Evaluate Sage

Run SageMath code in a persistent session; variables persist across calls. Caller code is deny-by-default -- ordinary mathematics is allowed, but imports, external CAS interfaces and file/display/persistence calls are refused. Write Sage code without import statements: Sage's mathematical functions are already available. Use matrix(RDF, ...) and vector(RDF, ...) instead of importing NumPy or SciPy. Do not call reset() inside code; use reset_sage_session to clear the session. The bare pari interface is unavailable; use Sage's native functions. For a Bessel zero, use find_root(bessel_J(0, x), a…

ParameterTypeDescription
code *stringSageMath code to execute
capture_stdoutbooleanCapture stdout emitted by Sage code
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…
timeoutOverride the evaluation timeout in seconds
want_latexbooleanReturn LaTeX representation when possible

calculate_expression Calculate Expression

Evaluate a SageMath expression and return numeric/string forms

ParameterTypeDescription
expression *stringSageMath expression to evaluate
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

simplify_expression Simplify Expression

Simplify a mathematical expression

ParameterTypeDescription
expression *stringExpression to simplify
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

expand_expression Expand Expression

Expand a mathematical expression

ParameterTypeDescription
expression *stringExpression to expand
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

factor_expression Factor Expression

Factor a mathematical expression or integer

ParameterTypeDescription
expression *stringExpression to factor (e.g., 'x^2 - 1' or '60')
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

find_root Find Root

Find a numeric root of an expression or equation in a given interval

ParameterTypeDescription
expression *stringExpression or equation to find a root of (e.g. 'x - cos(x)', or 'E - 0.6*sin(E) = 0.75')
lower_boundnumberLeft bound of search interval
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…
upper_boundnumberRight bound of search interval
variablestringVariable

evaluate_sage_streaming Evaluate Sage Streaming

Execute SageMath code and stream intermediate print() output line by line. Final result is returned as usual.

ParameterTypeDescription
code *stringSageMath code to execute
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…
timeout_secondsOverride timeout in seconds

check_sage_health Check Sage Health

Probe whether SageMath evaluation works right now: starts (or reuses) the workspace's worker, evaluates 1+1, and reports readiness and latency. Reports failure in the result instead of erroring, so it is always safe to call

ParameterTypeDescription
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

lookup_sage_doc Lookup Sage Doc

Documentation links for a SageMath name, plus whether this server offers that name to evaluate_sage caller code

ParameterTypeDescription
symbol *stringA SageMath name, e.g. 'EllipticCurve' or 'desolve'

number_theory_operation Number Theory Operation

Number theory: primality testing, integer factorisation, the next prime above n, gcd and lcm. Prefer this over evaluate_sage for any of these.

ParameterTypeDescription
a *Primary integer. Pass values above 2^53 as a decimal STRING: JSON numbers are IEEE doubles in JavaScript-based clients, so 10^30 arrives as 1000000000000000019884624838656 and the answer is silently w…
operation *stringOperation: 'is_prime', 'factor_integer', 'next_prime', 'gcd', 'lcm'
bSecond integer, required for gcd and lcm. Same string rule.
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

combinatorics_operation Combinatorics Operation

Combinatorics: binomial coefficients, permutations, combinations, integer partitions, factorial, Catalan, Fibonacci and Bell numbers. Prefer this over evaluate_sage for any of these.

ParameterTypeDescription
n *Primary integer argument. Values at or above 2^53 must be passed as a decimal string, e.g. "9007199254740993", because a JSON number that large has already been rounded by the client.
operation *stringOne of: binomial (n choose k), permutations (n!), combinations (n choose k), partitions (COUNT of integer partitions of n), factorial (n!), catalan (nth Catalan number), fibonacci (nth Fibonacci numbe…
kSecondary argument (for binomial, combinations). Decimal strings accepted, as for n.
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

graph_operation Graph Operation

Graph theory: create named graphs and compute properties (chromatic_number, is_connected, diameter, etc.)

ParameterTypeDescription
graph *stringGraph constructor: a named graph like 'PetersenGraph' or an adjacency dict like '{0:[1,2], 1:[0,2], 2:[0,1]}'
operation *stringOne of: chromatic_number, is_connected, is_planar, diameter, order, size, degree_sequence, adjacency_matrix, shortest_path (requires source and target)
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…
sourceSource vertex
targetTarget vertex

group_operation Group Operation

Group theory: construct groups and query properties (order, is_abelian, center, etc.)

ParameterTypeDescription
group *stringSage group constructor, e.g. 'SymmetricGroup(5)', 'DihedralGroup(4)', 'CyclicPermutationGroup(6)', 'AlternatingGroup(5)'
operation *stringOne of: order, is_abelian, is_cyclic, center_order, conjugacy_classes_count, exponent
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

elliptic_curve_operation Elliptic Curve Operation

Elliptic curves over Q: rank, torsion order, discriminant, j-invariant, conductor and generators, from Weierstrass coefficients. Prefer this over evaluate_sage for curve invariants.

ParameterTypeDescription
coefficients *arrayCurve coefficients [a1,a2,a3,a4,a6] or short Weierstrass [a,b] for y^2 = x^3 + a*x + b
operation *stringOne of: rank, torsion_order, discriminant, j_invariant, conductor, gens
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

coding_theory_operation Coding Theory Operation

Error-correcting codes: length, dimension, minimum distance, rate and generator matrix for Hamming and generalized Reed-Solomon codes. Prefer this over evaluate_sage for code parameters.

ParameterTypeDescription
code_type *stringCode constructor, e.g. 'HammingCode(GF(2),3)', 'GeneralizedReedSolomonCode(GF(7).list()[:6],3)'
operation *stringOne of: length, dimension, minimum_distance, generator_matrix, rate
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

plot3d_expression Plot3D Expression

Plot a 3D surface of a two-variable expression as a rendered image

ParameterTypeDescription
expression *stringExpression of two variables (e.g. 'sin(x)*cos(y)')
image_formatstringImage format to return: 'png' (raster) or 'svg' (vector, smaller)
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…
x_range_maxnumberX upper bound
x_range_minnumberX lower bound
x_variablestringFirst variable
y_range_maxnumberY upper bound
y_range_minnumberY lower bound
y_variablestringSecond variable

plot_multi_expression Plot Multi Expression

Plot multiple expressions overlaid on a single 2D graph, as a rendered image

ParameterTypeDescription
expressions *arrayList of expressions to plot (e.g. ['sin(x)', 'cos(x)'])
image_formatstringImage format to return: 'png' (raster) or 'svg' (vector, smaller)
range_maxnumberUpper bound of plot range
range_minnumberLower bound of plot range
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…
variablestringPlot variable

plot_expression Plot Expression

Plot an expression and return it as a rendered image (PNG or SVG)

ParameterTypeDescription
expression *stringExpression to plot
image_formatstringImage format to return: 'png' (raster) or 'svg' (vector, smaller)
range_maxnumberUpper bound of plot range
range_minnumberLower bound of plot range
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…
variablestringPlot variable

geometry_operation Geometry Operation

Computational geometry on point sets: euclidean distance, polygon area, polytope volume, convex hull vertices and convexity tests. Prefer this over evaluate_sage for these.

ParameterTypeDescription
operation *stringOne of: distance, polygon_area, polytope_volume, convex_hull_vertices, is_convex
points *arrayList of points as coordinate lists
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

reset_sage_session Reset Sage Session

Reset the SageMath session state for the current MCP session

ParameterTypeDescription
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

interrupt_sage_session Interrupt Sage Session

Interrupt a running Sage computation while keeping variables defined so far

ParameterTypeDescription
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

cancel_sage_session Cancel Sage Session

Cancel any running Sage computation and restart the worker

ParameterTypeDescription
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

start_sage_session Start Sage Session

Start a named Sage workspace with its own independent variables

ParameterTypeDescription
name *stringWorkspace name, e.g. 'curves' or 'scratch'

list_sage_sessions List Sage Sessions

List the named Sage workspaces belonging to this client

stop_sage_session Stop Sage Session

Stop a named Sage workspace and release its worker

ParameterTypeDescription
name *stringWorkspace name to stop

statistics_summary Statistics Summary

Descriptive statistics for a list of numbers: mean, median, population and sample variance and standard deviation, min and max. Prefer this over evaluate_sage for summary statistics.

ParameterTypeDescription
data *arrayList of numeric values
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…

distribution_operation Distribution Operation

Probability distribution operations: PDF, CDF, quantile, mean, variance, sampling

ParameterTypeDescription
distribution *stringDistribution name: normal, exponential, poisson, chi_squared, student_t, uniform, beta, gamma
operation *stringOne of: pdf, cdf, quantile, mean, variance, sample
parameters *arrayDistribution parameters (e.g. [0, 1] for standard normal)
nNumber of samples (for sample operation)
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…
xPoint for pdf/cdf/quantile evaluation

verify_claim Verify Claim

Independently re-check a stated mathematical claim and report how far the evidence goes: proved, refuted, supported or undecided. Use this to verify your own algebra before presenting it. The claim is a single comparison in Sage syntax -- an equality, an inequality, or anything that evaluates to True/False: integral(x^2/(e^x-1), x, 0, oo) == 2*zeta(3) sin(x)^2 + cos(x)^2 == 1 pi < 22/7 e^pi != pi^e The check climbs a ladder: Sage's symbolic prover, the exact difference ((lhs-rhs).simplify_full().is_zero()), exact arithmetic over QQbar/AA when the claim is constant, then certified in…

ParameterTypeDescription
claim *stringThe claim to check, as a single comparison, e.g. 'sin(x)**2 + cos(x)**2 == 1'
precision_bitsintegerPrecision of the certified interval arithmetic behind numeric verdicts
samplesintegerSample points per free variable sweep when the claim cannot be decided exactly
sessionstringWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the sam…
timeoutOverride the evaluation timeout in seconds