SageMath MCP Server
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| SAGEMATH_MCP_STARTUP | No | Sage code executed during session bootstrap. | from sage.all import * |
| SAGEMATH_MCP_IDLE_TTL | No | Seconds of inactivity before a session is culled. | 900 |
| SAGEMATH_MCP_MAX_STDOUT | No | Maximum characters of stdout returned per call. | 100000 |
| SAGEMATH_MCP_PURE_PYTHON | No | When set to 1, load math stdlib instead of Sage modules. | unset |
| SAGEMATH_MCP_SAGE_BINARY | No | Path to the sage executable. | sage |
| SAGEMATH_MCP_EVAL_TIMEOUT | No | Per-evaluation timeout in seconds. | 30 |
| SAGEMATH_MCP_SHUTDOWN_GRACE | No | Grace period before a stuck worker is terminated. | 2 |
| SAGEMATH_MCP_SECURITY_ENABLED | No | Enable/disable AST-based code validation. | true |
| SAGEMATH_MCP_FORCE_PYTHON_WORKER | No | Use the pure-Python worker (helpful for tests/CI). | false |
| SAGEMATH_MCP_SECURITY_MAX_SOURCE | No | Maximum source length in characters. | 8000 |
| SAGEMATH_MCP_SECURITY_ALLOW_IMPORTS | No | Permit import statements when set to true. | false |
| SAGEMATH_MCP_SECURITY_FORBID_GLOBAL | No | Block global statements when true. | true |
| SAGEMATH_MCP_SECURITY_MAX_AST_DEPTH | No | Maximum AST depth allowed. | 75 |
| SAGEMATH_MCP_SECURITY_MAX_AST_NODES | No | Maximum AST node count allowed. | 2500 |
| SAGEMATH_MCP_SECURITY_LOG_VIOLATIONS | No | Emit warnings when code is blocked. | true |
| SAGEMATH_MCP_SECURITY_ALLOWED_IMPORTS | No | Comma-separated allowlist of importable modules. | math,cmath,statistics,base64,io,sage,sage.all |
| SAGEMATH_MCP_SECURITY_FORBID_NONLOCAL | No | Block nonlocal statements when true. | true |
| SAGEMATH_MCP_SECURITY_ALLOWED_IMPORT_PREFIXES | No | Comma-separated prefixes treated as safe namespaces. | sage. |
Capabilities
Features and capabilities supported by this server
| Capability | Details |
|---|---|
| tools | {
"listChanged": true
} |
| logging | {} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
| extensions | {
"io.modelcontextprotocol/ui": {}
} |
| experimental | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| evaluate_sageA | Execute arbitrary SageMath code within a persistent session. Variables and definitions persist across calls. Use this for any computation not covered by the specialized helpers. Examples by domain: Combinatorics: binomial(10, 3); Permutations(4).cardinality(); Combinations([1,2,3,4], 2).list() Graph theory: G = graphs.PetersenGraph(); G.chromatic_number() Number theory: prime_range(100); euler_phi(60); continued_fraction(pi, nterms=10) Geometry: polytopes.cube().volume(); EllipticCurve([0,0,1,-1,0]).rank() Probability: RealDistribution('gaussian', 1).cum_distribution_function(1.96) Group theory: SymmetricGroup(5).order(); AlternatingGroup(4).is_abelian() Polynomial rings: R.<a,b> = PolynomialRing(QQ); (a+b)^3 Coding theory: codes.HammingCode(GF(2), 3).minimum_distance() Symbolic sums: var('n'); sum(1/n^2, n, 1, oo) Transforms: laplace(sin(t), t, s); inverse_laplace(1/(s^2+1), s, t) Modular arithmetic: Mod(17, 5); power_mod(3, 100, 97) Vector calculus: var('x y z'); f = x^2+y^2+z^2; diff(f,x), diff(f,y), diff(f,z) Numeric root finding: find_root(x - cos(x), 0, 1) Recurrences: desolve_rsolve(f(n+2)-f(n+1)-f(n), f, [0, 1]) |
| reset_sage_sessionB | Reset the SageMath session state for the current MCP session |
| cancel_sage_sessionA | Cancel any running Sage computation and restart the worker |
| calculate_expressionC | Evaluate a SageMath expression and return numeric/string forms |
| solve_equationB | Solve an equation or system of equations |
| differentiate_expressionA | Differentiate an expression with respect to a variable |
| integrate_expressionA | Integrate an expression (indefinite or definite with bounds) |
| statistics_summaryB | Compute descriptive statistics for a dataset |
| matrix_multiplyB | Multiply two matrices and return the result as nested lists |
| simplify_expressionC | Simplify a mathematical expression |
| expand_expressionC | Expand a mathematical expression |
| factor_expressionB | Factor a mathematical expression or integer |
| limit_expressionC | Compute the limit of an expression |
| series_expansionA | Compute a Taylor/Laurent series expansion |
| matrix_operationC | Perform a matrix operation (det, inverse, eigenvalues, ...) |
| solve_odeC | Solve an ordinary differential equation |
| number_theory_operationC | Number theory operations: is_prime, factor_integer, next_prime, gcd, lcm |
| symbolic_sumB | Compute a symbolic sum or product over an index variable |
| combinatorics_operationC | Combinatorics: binomial, permutations, combinations, partitions, and more |
| plot3d_expressionB | Plot a 3D surface of a two-variable expression as base64 PNG |
| distribution_operationC | Probability distribution operations: PDF, CDF, quantile, mean, variance, sampling |
| find_rootB | Find a numeric root of an expression in a given interval |
| plot_multi_expressionA | Plot multiple expressions overlaid on a single 2D graph |
| vector_calculus_operationB | Vector calculus operations: gradient, divergence, curl, laplacian |
| plot_expressionC | Plot an expression and return a base64-encoded PNG image |
| graph_operationB | Graph theory: create named graphs and compute properties (chromatic_number, is_connected, diameter, etc.) |
| group_operationA | Group theory: construct groups and query properties (order, is_abelian, center, etc.) |
| elliptic_curve_operationB | Elliptic curve operations: rank, torsion, discriminant, j_invariant, rational points |
| coding_theory_operationB | Coding theory: construct error-correcting codes and compute properties |
| boolean_algebra_operationC | Boolean algebra: operations on boolean polynomials |
| polynomial_ring_operationB | Polynomial ring operations: construct rings and compute Groebner bases, ideals, quotients |
| geometry_operationB | Geometry: distances, areas, volumes, convex hulls for points and polytopes |
| evaluate_sage_streamingA | Execute SageMath code and stream intermediate print() output line by line. Final result is returned as usual. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/XBP-Europe/sagemath-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server