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. |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
This server publishes no instructions, or was last inspected before Glama recorded them.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| 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 |
|---|---|
| solve_equationB | Solve an equation or system of equations |
| matrix_multiplyA | Multiply two matrices and return the result as nested lists |
| matrix_operationA | Linear algebra on one matrix: determinant, inverse, eigenvalues, rank, reduced row echelon form, transpose. Prefer this over evaluate_sage. |
| boolean_algebra_operationA | Boolean polynomials over GF(2): evaluate, list variables, degree, and zero/one tests. Prefer this over evaluate_sage for boolean algebra. |
| polynomial_ring_operationB | Polynomial ring operations: construct rings and compute Groebner bases, ideals, quotients |
| differentiate_expressionB | Differentiate an expression with respect to a variable |
| integrate_expressionA | Integrate an expression (indefinite or definite with bounds) |
| limit_expressionC | Compute the limit of an expression |
| series_expansionC | Compute a Taylor/Laurent series expansion |
| solve_odeA | Solve an ordinary differential equation of any order, returning the general solution with arbitrary constants. Prefer this over evaluate_sage. |
| symbolic_sumA | Closed form of a symbolic sum or product over an index variable, including infinite series. Prefer this over evaluate_sage for summations. |
| vector_calculus_operationC | Vector calculus operations: gradient, divergence, curl, laplacian |
| evaluate_sageA | Run arbitrary SageMath code in a persistent session; variables persist across calls. LAST RESORT. A dedicated tool exists for most tasks and should be preferred: it validates arguments and returns a typed result instead of a repr string. Reach for one of these first:
Use evaluate_sage only for what those do not cover, for example: Transforms: var('t s'); laplace(sin(t), t, s); inverse_laplace(1/(s^2+1), s, t) Modular arithmetic: Mod(17, 5); power_mod(3, 100, 97) Recurrences: var('n'); f = function('f'); desolve_rec(f(n+2)-f(n+1)-f(n), f, [0, 1]) Continued fractions: continued_fraction(pi).convergents()[:10] Number fields: K. = NumberField(x^3 - 2); K.class_number() Multi-step work that builds on values defined earlier in the same session. |
| calculate_expressionB | Evaluate a SageMath expression and return numeric/string forms |
| simplify_expressionC | Simplify a mathematical expression |
| expand_expressionC | Expand a mathematical expression |
| factor_expressionB | Factor a mathematical expression or integer |
| find_rootA | Find a numeric root of an expression in a given interval |
| evaluate_sage_streamingA | Execute SageMath code and stream intermediate print() output line by line. Final result is returned as usual. |
| number_theory_operationA | Number theory: primality testing, integer factorisation, the next prime above n, gcd and lcm. Prefer this over evaluate_sage for any of these. |
| combinatorics_operationA | Combinatorics: binomial coefficients, permutations, combinations, integer partitions, factorial, Catalan, Fibonacci and Bell numbers. Prefer this over evaluate_sage for any of these. |
| graph_operationA | 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_operationA | Elliptic curves over Q: rank, torsion order, discriminant, j-invariant, conductor and generators, from Weierstrass coefficients. Prefer this over evaluate_sage for curve invariants. |
| coding_theory_operationA | 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. |
| plot3d_expressionA | Plot a 3D surface of a two-variable expression as base64 PNG |
| plot_multi_expressionA | Plot multiple expressions overlaid on a single 2D graph |
| plot_expressionB | Plot an expression and return a base64-encoded PNG image |
| geometry_operationA | Computational geometry on point sets: euclidean distance, polygon area, polytope volume, convex hull vertices and convexity tests. Prefer this over evaluate_sage for these. |
| reset_sage_sessionC | Reset the SageMath session state for the current MCP session |
| interrupt_sage_sessionA | Interrupt a running Sage computation while keeping variables defined so far |
| cancel_sage_sessionB | Cancel any running Sage computation and restart the worker |
| start_sage_sessionA | Start a named Sage workspace with its own independent variables |
| list_sage_sessionsA | List the named Sage workspaces belonging to this client |
| stop_sage_sessionA | Stop a named Sage workspace and release its worker |
| statistics_summaryA | 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. |
| distribution_operationB | Probability distribution operations: PDF, CDF, quantile, mean, variance, sampling |
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