Skip to main content
Glama
XBP-Europe
by XBP-Europe

evaluate_sage

Execute arbitrary SageMath code for any mathematical computation, including algebra, calculus, number theory, and graph theory, with state persisting between calls.

Instructions

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])

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesSageMath code to execute
timeoutNoOverride the evaluation timeout in seconds
want_latexNoReturn LaTeX representation when possible
capture_stdoutNoCapture stdout emitted by Sage code

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
latexNoLaTeX serialization of the result when requested and supported.
resultNoString representation of the expression result if available.
stdoutNoCaptured stdout emitted during execution.
elapsed_msYesWall-clock execution time in milliseconds.
result_typeYes
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It discloses a key behavioral trait: 'Variables and definitions persist across calls.' It does not cover error handling or security risks, but for an arbitrary code execution tool, the persistence disclosure is significant and goes beyond the schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with a clear purpose statement, then organized into a domain-by-domain example list. Although long, the structure makes it scannable and the examples are purposeful for an arbitrary-code tool. It is appropriately sized for the tool's complexity, though slightly verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is complex, but the description covers core context: persistence, general-purpose scope, and relationship to specialized helpers. The output schema exists to document return values, and parameters are fully documented in the schema. It doesn't mention session reset/cancel, but the sibling tools reset_sage_session and cancel_sage_session cover that.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description's lengthy domain-based examples add real semantic value for the 'code' parameter, illustrating valid SageMath syntax and showing the breadth of supported operations beyond the schema's simple 'SageMath code to execute'.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description begins with a specific verb and resource: 'Execute arbitrary SageMath code within a persistent session.' It clearly distinguishes itself from the many sibling tools by stating it is the general-purpose fallback for 'any computation not covered by the specialized helpers.'

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It explicitly says 'Use this for any computation not covered by the specialized helpers,' which tells the agent exactly when to choose this tool over the specialized siblings. This is a clear usage directive with an implied alternative set.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

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