SageMath
v0.12.0Stateful 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
| Parameter | Type | Description |
|---|---|---|
equation * | Equation string (e.g., 'x^2 - 1 = 0') or list of equations for systems | |
session | string | Workspace 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… |
variable | Variable or list of variables to solve for |
matrix_multiply Matrix Multiply
Multiply two matrices and return the result as nested lists
| Parameter | Type | Description |
|---|---|---|
matrix_a * | array | Left matrix (rows of numbers). Integers stay exact; pass values from 2^53 up as decimal strings, e.g. "9007199254740993". |
matrix_b * | array | Right matrix (rows of numbers). Integers stay exact. |
session | string | Workspace 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.
| Parameter | Type | Description |
|---|---|---|
matrix * | array | Matrix as nested list of numbers. Integers stay exact; pass values from 2^53 up as decimal strings. |
operation * | string | One of: determinant, inverse, eigenvalues, rank, rref, transpose |
session | string | Workspace 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.
| Parameter | Type | Description |
|---|---|---|
expression * | string | Boolean expression (e.g. 'x*y + x*z + y*z') |
operation * | string | One of: evaluate, variables, degree, is_zero, is_one, reduce |
num_variables | integer | Number of boolean variables |
session | string | Workspace 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
| Parameter | Type | Description |
|---|---|---|
operation * | string | One of: groebner_basis, ideal_dimension, ideal_variety, reduce, is_groebner |
polynomials * | array | Polynomials as strings, e.g. ['a^2+b', 'b^2-1'] |
ring_vars * | array | Variable names, e.g. ['a', 'b', 'c'] |
base_ring | string | Base ring |
session | string | Workspace 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
| Parameter | Type | Description |
|---|---|---|
expression * | string | Expression to differentiate |
order | integer | Order of differentiation (1 = first, 2 = second, etc.) |
session | string | Workspace 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… |
variable | string | Variable for differentiation |
integrate_expression Integrate Expression
Integrate an expression (indefinite or definite with bounds)
| Parameter | Type | Description |
|---|---|---|
expression * | string | Expression to integrate |
lower_bound | Lower bound for definite integral (e.g., '0', '-oo') | |
session | string | Workspace 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_bound | Upper bound for definite integral (e.g., '1', 'oo') | |
variable | string | Integration variable |
limit_expression Limit Expression
Compute the limit of an expression
| Parameter | Type | Description |
|---|---|---|
expression * | string | Expression to take the limit of |
direction | Direction: 'plus' (right), 'minus' (left), or omit for both | |
point | string | Point to approach (e.g., '0', 'oo', '-oo') |
session | string | Workspace 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… |
variable | string | Variable approaching the point |
series_expansion Series Expansion
Compute a Taylor/Laurent series expansion
| Parameter | Type | Description |
|---|---|---|
expression * | string | Expression to expand in series |
order | integer | Number of terms in the expansion |
point | string | Point around which to expand |
session | string | Workspace 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… |
variable | string | Variable 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.
| Parameter | Type | Description |
|---|---|---|
equation * | string | ODE string, e.g., "diff(y(x),x) + y(x) = 0" |
function | string | Dependent function name (e.g., 'y') |
session | string | Workspace 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… |
variable | string | Independent 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.
| Parameter | Type | Description |
|---|---|---|
expression * | string | Expression to sum (e.g. '1/n^2') |
lower | string | Lower bound (e.g. '1') |
product | boolean | If true, compute a product instead of a sum |
session | string | Workspace 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 | string | Upper bound (e.g. 'oo' for infinity) |
variable | string | Index variable (e.g. 'n') |
vector_calculus_operation Vector Calculus Operation
Vector calculus operations: gradient, divergence, curl, laplacian
| Parameter | Type | Description |
|---|---|---|
expression * | Scalar field (string) for gradient/laplacian, or vector field components (list) for divergence/curl | |
operation * | string | One of: gradient, divergence, curl, laplacian |
session | string | Workspace 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… |
variables | Variable 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…
| Parameter | Type | Description |
|---|---|---|
code * | string | SageMath code to execute |
capture_stdout | boolean | Capture stdout emitted by Sage code |
session | string | Workspace 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 | Override the evaluation timeout in seconds | |
want_latex | boolean | Return LaTeX representation when possible |
calculate_expression Calculate Expression
Evaluate a SageMath expression and return numeric/string forms
| Parameter | Type | Description |
|---|---|---|
expression * | string | SageMath expression to evaluate |
session | string | Workspace 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
| Parameter | Type | Description |
|---|---|---|
expression * | string | Expression to simplify |
session | string | Workspace 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
| Parameter | Type | Description |
|---|---|---|
expression * | string | Expression to expand |
session | string | Workspace 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
| Parameter | Type | Description |
|---|---|---|
expression * | string | Expression to factor (e.g., 'x^2 - 1' or '60') |
session | string | Workspace 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
| Parameter | Type | Description |
|---|---|---|
expression * | string | Expression or equation to find a root of (e.g. 'x - cos(x)', or 'E - 0.6*sin(E) = 0.75') |
lower_bound | number | Left bound of search interval |
session | string | Workspace 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_bound | number | Right bound of search interval |
variable | string | Variable |
evaluate_sage_streaming Evaluate Sage Streaming
Execute SageMath code and stream intermediate print() output line by line. Final result is returned as usual.
| Parameter | Type | Description |
|---|---|---|
code * | string | SageMath code to execute |
session | string | Workspace 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_seconds | Override 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
| Parameter | Type | Description |
|---|---|---|
session | string | Workspace 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
| Parameter | Type | Description |
|---|---|---|
symbol * | string | A 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.
| Parameter | Type | Description |
|---|---|---|
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 * | string | Operation: 'is_prime', 'factor_integer', 'next_prime', 'gcd', 'lcm' |
b | Second integer, required for gcd and lcm. Same string rule. | |
session | string | Workspace 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.
| Parameter | Type | Description |
|---|---|---|
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 * | string | One 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… |
k | Secondary argument (for binomial, combinations). Decimal strings accepted, as for n. | |
session | string | Workspace 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.)
| Parameter | Type | Description |
|---|---|---|
graph * | string | Graph constructor: a named graph like 'PetersenGraph' or an adjacency dict like '{0:[1,2], 1:[0,2], 2:[0,1]}' |
operation * | string | One of: chromatic_number, is_connected, is_planar, diameter, order, size, degree_sequence, adjacency_matrix, shortest_path (requires source and target) |
session | string | Workspace 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… |
source | Source vertex | |
target | Target vertex |
group_operation Group Operation
Group theory: construct groups and query properties (order, is_abelian, center, etc.)
| Parameter | Type | Description |
|---|---|---|
group * | string | Sage group constructor, e.g. 'SymmetricGroup(5)', 'DihedralGroup(4)', 'CyclicPermutationGroup(6)', 'AlternatingGroup(5)' |
operation * | string | One of: order, is_abelian, is_cyclic, center_order, conjugacy_classes_count, exponent |
session | string | Workspace 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.
| Parameter | Type | Description |
|---|---|---|
coefficients * | array | Curve coefficients [a1,a2,a3,a4,a6] or short Weierstrass [a,b] for y^2 = x^3 + a*x + b |
operation * | string | One of: rank, torsion_order, discriminant, j_invariant, conductor, gens |
session | string | Workspace 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.
| Parameter | Type | Description |
|---|---|---|
code_type * | string | Code constructor, e.g. 'HammingCode(GF(2),3)', 'GeneralizedReedSolomonCode(GF(7).list()[:6],3)' |
operation * | string | One of: length, dimension, minimum_distance, generator_matrix, rate |
session | string | Workspace 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
| Parameter | Type | Description |
|---|---|---|
expression * | string | Expression of two variables (e.g. 'sin(x)*cos(y)') |
image_format | string | Image format to return: 'png' (raster) or 'svg' (vector, smaller) |
session | string | Workspace 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_max | number | X upper bound |
x_range_min | number | X lower bound |
x_variable | string | First variable |
y_range_max | number | Y upper bound |
y_range_min | number | Y lower bound |
y_variable | string | Second variable |
plot_multi_expression Plot Multi Expression
Plot multiple expressions overlaid on a single 2D graph, as a rendered image
| Parameter | Type | Description |
|---|---|---|
expressions * | array | List of expressions to plot (e.g. ['sin(x)', 'cos(x)']) |
image_format | string | Image format to return: 'png' (raster) or 'svg' (vector, smaller) |
range_max | number | Upper bound of plot range |
range_min | number | Lower bound of plot range |
session | string | Workspace 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… |
variable | string | Plot variable |
plot_expression Plot Expression
Plot an expression and return it as a rendered image (PNG or SVG)
| Parameter | Type | Description |
|---|---|---|
expression * | string | Expression to plot |
image_format | string | Image format to return: 'png' (raster) or 'svg' (vector, smaller) |
range_max | number | Upper bound of plot range |
range_min | number | Lower bound of plot range |
session | string | Workspace 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… |
variable | string | Plot 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.
| Parameter | Type | Description |
|---|---|---|
operation * | string | One of: distance, polygon_area, polytope_volume, convex_hull_vertices, is_convex |
points * | array | List of points as coordinate lists |
session | string | Workspace 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
| Parameter | Type | Description |
|---|---|---|
session | string | Workspace 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
| Parameter | Type | Description |
|---|---|---|
session | string | Workspace 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
| Parameter | Type | Description |
|---|---|---|
session | string | Workspace 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
| Parameter | Type | Description |
|---|---|---|
name * | string | Workspace 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
| Parameter | Type | Description |
|---|---|---|
name * | string | Workspace 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.
| Parameter | Type | Description |
|---|---|---|
data * | array | List of numeric values |
session | string | Workspace 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
| Parameter | Type | Description |
|---|---|---|
distribution * | string | Distribution name: normal, exponential, poisson, chi_squared, student_t, uniform, beta, gamma |
operation * | string | One of: pdf, cdf, quantile, mean, variance, sample |
parameters * | array | Distribution parameters (e.g. [0, 1] for standard normal) |
n | Number of samples (for sample operation) | |
session | string | Workspace 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 | Point 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…
| Parameter | Type | Description |
|---|---|---|
claim * | string | The claim to check, as a single comparison, e.g. 'sin(x)**2 + cos(x)**2 == 1' |
precision_bits | integer | Precision of the certified interval arithmetic behind numeric verdicts |
samples | integer | Sample points per free variable sweep when the claim cannot be decided exactly |
session | string | Workspace 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 | Override the evaluation timeout in seconds |