# SageMath (pypi · sagemath-mcp)

Stateful SageMath MCP server with 33 symbolic math tools and a sandboxed Sage session per client.

- Trust score: 71/100 (medium)
- Registry status: active
- Liveness: live
- Owner verified: no
- Last scored: 2026-08-17

## Components

- pypi · `sagemath-mcp`: 71/100 (this document), [markdown](https://verifymcp.io/servers/xbp-europe-sagemath-mcp/sagemath-mcp.md), [page](https://verifymcp.io/servers/xbp-europe-sagemath-mcp/sagemath-mcp)

## Channel facts

- Registry: `pypi`
- Package: `sagemath-mcp`
- Version: `0.6.1`
- Transport: `stdio`

## Trust breakdown

How this component scores in each security and reliability category. Every signal is checked automatically from public evidence about the published package, including repeated runs of it in an isolated sandbox, and we only credit what we can confirm. Scores are 0–100 per category. Scoring method: https://verifymcp.io/docs/scoring (what has changed: https://verifymcp.io/docs/scoring/changelog)

Scored 2026-08-17.

- **Supply Chain Security**: 100/100
  - No malware found by supply-chain analysis.
  - No known CVEs affecting this package version or its production dependencies.
  - Runs hatchling.build at install time, a recognised native-build step with no shell scripting around it.
  - 1 of 18 dependencies flagged as unhealthy.
- **Provenance & Transparency**: 48/100
  - Source repository is publicly reachable at the declared URL.
  - Provenance check failed: no build-provenance attestation is published.
  - Clear OSI-approved license (MIT).
  - Actively maintained (last published 0 days ago).
  - Publishes a security disclosure policy (SECURITY.md).
- **Schema Quality & AI Usability**: 75/100
  - AI-judged instruction clarity (excellent).
  - Context-footprint check failed: tool/resource definitions use about 4343 tokens (~117/item across 37 items; 37 tools + 0 resources), over budget; trim descriptions and params.
  - Usage-examples check failed: none of the tools include examples.
- **Stability & Change Management**: 10/100
  - Stability observed for 3 of 30 days with no destabilising changes; credit accrues until the full window elapses.
- **Tool Coverage**: 100/100
  - 100% of tools have a non-trivial description (not blank, and not just the tool's name).
  - 100% of tool parameters carry a description.
  - Structured output schemas are declared (100% of tools); any adoption earns full credit.
- **Capabilities**: 100/100
  - Implements a supported MCP spec version (2025-11-25); the latest is 2026-07-28.

## Install

### Claude

```bash
claude mcp add xbp-europe-sagemath-mcp -- uvx sagemath-mcp
```

### Codex

```bash
codex mcp add xbp-europe-sagemath-mcp -- uvx sagemath-mcp
```

### opencode

```json
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "xbp-europe-sagemath-mcp": {
      "type": "local",
      "command": [
        "uvx",
        "sagemath-mcp"
      ],
      "enabled": true
    }
  }
}
```

### OpenClaw

```bash
openclaw mcp add xbp-europe-sagemath-mcp --command uvx --arg sagemath-mcp
```

### Hermes

```yaml
mcp_servers:
  xbp-europe-sagemath-mcp:
    command: "uvx"
    args: ["sagemath-mcp"]
```

### Other

```json
{
  "mcpServers": {
    "xbp-europe-sagemath-mcp": {
      "command": "uvx",
      "args": [
        "sagemath-mcp"
      ]
    }
  }
}
```

## Changelog

Every change recorded for this component, newest first. Days that predate change tracking, or that we cannot explain, say so: "we were watching and nothing happened" and "we were not watching" are different claims.

### 2026-08-16 (score 71, +1)

- [security regression] Stability: 0.03 → unverified
- [functional regression] Capabilities: pass → unverified
- [functional regression] Tool coverage: 100 → unverified
- [functional] First check of Schema quality: unverified
- [functional] Package version: 0.6.0 → 0.6.1

### 2026-08-15 (score 70, +15)

- [security improvement] Malware scan: unverified → pass
- [security] Stability: Stability not yet verified: we do not have a sandbox capture of the MCP schema this version of the package serves yet.
- [functional regression] Capabilities: pass → unverified
- [functional regression] Tool coverage: 100 → unverified
- [functional improvement] Stability: unverified → 0.03
- [functional] First check of Schema quality: unverified
- [functional] Package version: 0.5.0 → 0.6.0

### 2026-08-14 (score 55)

First indexed and scored.

## MCP tools (37)

### `solve_equation` (~80 tokens)

Solve an equation or system of equations

Input parameters:

- `equation` (required): Equation string (e.g., 'x^2 - 1 = 0') or list of equations for systems
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.
- `variable`: Variable or list of variables to solve for

### `matrix_multiply` (~103 tokens)

Multiply two matrices and return the result as nested lists

Input parameters:

- `matrix_a` (array, required): Left matrix (rows of numbers). Integers stay exact; pass values from 2^53 up as decimal strings, e.g. "9007199254740993".
- `matrix_b` (array, required): Right matrix (rows of numbers). Integers stay exact.
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.

### `matrix_operation` (~113 tokens)

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

Input parameters:

- `matrix` (array, required): Matrix as nested list of numbers. Integers stay exact; pass values from 2^53 up as decimal strings.
- `operation` (string, required): One of: determinant, inverse, eigenvalues, rank, rref, transpose
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.

### `boolean_algebra_operation` (~120 tokens)

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

Input parameters:

- `expression` (string, required): Boolean expression (e.g. 'x*y + x*z + y*z')
- `num_variables` (integer): Number of boolean variables
- `operation` (string, required): One of: evaluate, variables, degree, is_zero, is_one, reduce
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.

### `polynomial_ring_operation` (~138 tokens)

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

Input parameters:

- `base_ring` (string): Base ring
- `operation` (string, required): One of: groebner_basis, ideal_dimension, ideal_variety, reduce, is_groebner
- `polynomials` (array, required): Polynomials as strings, e.g. ['a^2+b', 'b^2-1']
- `ring_vars` (array, required): Variable names, e.g. ['a', 'b', 'c']
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.

### `differentiate_expression` (~81 tokens)

Differentiate an expression with respect to a variable

Input parameters:

- `expression` (string, required): Expression to differentiate
- `order` (integer): Order of differentiation (1 = first, 2 = second, etc.)
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.
- `variable` (string): Variable for differentiation

### `integrate_expression` (~102 tokens)

Integrate an expression (indefinite or definite with bounds)

Input parameters:

- `expression` (string, required): Expression to integrate
- `lower_bound`: Lower bound for definite integral (e.g., '0', '-oo')
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.
- `upper_bound`: Upper bound for definite integral (e.g., '1', 'oo')
- `variable` (string): Integration variable

### `limit_expression` (~106 tokens)

Compute the limit of an expression

Input parameters:

- `direction`: Direction: 'plus' (right), 'minus' (left), or omit for both
- `expression` (string, required): Expression to take the limit of
- `point` (string): Point to approach (e.g., '0', 'oo', '-oo')
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.
- `variable` (string): Variable approaching the point

### `series_expansion` (~87 tokens)

Compute a Taylor/Laurent series expansion

Input parameters:

- `expression` (string, required): Expression to expand in series
- `order` (integer): Number of terms in the expansion
- `point` (string): Point around which to expand
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.
- `variable` (string): Variable for expansion

### `solve_ode` (~115 tokens)

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

Input parameters:

- `equation` (string, required): ODE string, e.g., "diff(y(x),x) + y(x) = 0"
- `function` (string): Dependent function name (e.g., 'y')
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.
- `variable` (string): Independent variable (e.g., 'x')

### `symbolic_sum` (~141 tokens)

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

Input parameters:

- `expression` (string, required): 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): Named workspace to use. Workspaces have independent variables; omit for 'default'.
- `upper` (string): Upper bound (e.g. 'oo' for infinity)
- `variable` (string): Index variable (e.g. 'n')

### `vector_calculus_operation` (~112 tokens)

Vector calculus operations: gradient, divergence, curl, laplacian

Input parameters:

- `expression` (required): Scalar field (string) for gradient/laplacian, or vector field components (list) for divergence/curl
- `operation` (string, required): One of: gradient, divergence, curl, laplacian
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.
- `variables`: Variable names (e.g. ['x', 'y', 'z'])

### `evaluate_sage` (~448 tokens)

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:

\- calculus: differentiate_expression, integrate_expression, limit_expression, series_expansion, symbolic_sum, solve_ode
\- algebra: solve_equation, simplify_expression, expand_expression, factor_expression, find_root
\- linear algebra: matrix_operation (determinant, inverse, eigenvalues, rank, rref, transpose), matrix_multiply
\- discrete: number_theory_operation, combinatorics_operation (binomial, partitions, catalan, fibonacci, bell), graph_operation, group_operation
\- specialised: elliptic_curve_operation, coding_theory_operation, polynomial_ring_operation, boolean_algebra_operation, geometry_operation, vector_calculus_operation
\- data: statistics_summary, distribution_operation
\- plots: plot_expression, plot3d_expression, plot_multi_expression

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.<a> = NumberField(x^3 - 2); K.class_number()
Multi-step work that builds on values defined earlier in the same session.

Input parameters:

- `capture_stdout` (boolean): Capture stdout emitted by Sage code
- `code` (string, required): SageMath code to execute
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.
- `timeout`: Override the evaluation timeout in seconds
- `want_latex` (boolean): Return LaTeX representation when possible

Output parameters:

- `elapsed_ms` (number): Wall-clock execution time in milliseconds.
- `latex`: LaTeX serialization of the result when requested and supported.
- `result`: String representation of the expression result if available.
- `result_type` (string)
- `stdout` (string): Captured stdout emitted during execution.

### `calculate_expression` (~53 tokens)

Evaluate a SageMath expression and return numeric/string forms

Input parameters:

- `expression` (string, required): SageMath expression to evaluate
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.

### `simplify_expression` (~46 tokens)

Simplify a mathematical expression

Input parameters:

- `expression` (string, required): Expression to simplify
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.

### `expand_expression` (~45 tokens)

Expand a mathematical expression

Input parameters:

- `expression` (string, required): Expression to expand
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.

### `factor_expression` (~62 tokens)

Factor a mathematical expression or integer

Input parameters:

- `expression` (string, required): Expression to factor (e.g., 'x^2 - 1' or '60')
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.

### `find_root` (~119 tokens)

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

Input parameters:

- `expression` (string, required): 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): Named workspace to use. Workspaces have independent variables; omit for 'default'.
- `upper_bound` (number): Right bound of search interval
- `variable` (string): Variable

### `evaluate_sage_streaming` (~76 tokens)

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

Input parameters:

- `code` (string, required): SageMath code to execute
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.
- `timeout_seconds`: Override timeout in seconds

Output parameters:

- `elapsed_ms` (number): Wall-clock execution time in milliseconds.
- `latex`: LaTeX serialization of the result when requested and supported.
- `result`: String representation of the expression result if available.
- `result_type` (string)
- `stdout` (string): Captured stdout emitted during execution.

### `number_theory_operation` (~167 tokens)

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

Input parameters:

- `a` (required): 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…
- `b`: Second integer, required for gcd and lcm. Same string rule.
- `operation` (string, required): Operation: 'is_prime', 'factor_integer', 'next_prime', 'gcd', 'lcm'
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.

### `combinatorics_operation` (~204 tokens)

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

Input parameters:

- `k`: Secondary argument (for binomial, combinations). Decimal strings accepted, as for n.
- `n` (required): 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, required): 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 numb…
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.

### `graph_operation` (~151 tokens)

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

Input parameters:

- `graph` (string, required): Graph constructor: a named graph like 'PetersenGraph' or an adjacency dict like '{0:[1,2], 1:[0,2], 2:[0,1]}'
- `operation` (string, required): One of: chromatic_number, is_connected, is_planar, diameter, order, size, degree_sequence, adjacency_matrix, shortest_path (requires source and target)
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.
- `source`: Source vertex
- `target`: Target vertex

### `group_operation` (~122 tokens)

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

Input parameters:

- `group` (string, required): Sage group constructor, e.g. 'SymmetricGroup(5)', 'DihedralGroup(4)', 'CyclicPermutationGroup(6)', 'AlternatingGroup(5)'
- `operation` (string, required): One of: order, is_abelian, is_cyclic, center_order, conjugacy_classes_count, exponent
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.

### `elliptic_curve_operation` (~144 tokens)

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

Input parameters:

- `coefficients` (array, required): Curve coefficients [a1,a2,a3,a4,a6] or short Weierstrass [a,b] for y^2 = x^3 + a*x + b
- `operation` (string, required): One of: rank, torsion_order, discriminant, j_invariant, conductor, gens
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.

### `coding_theory_operation` (~135 tokens)

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.

Input parameters:

- `code_type` (string, required): Code constructor, e.g. 'HammingCode(GF(2),3)', 'GeneralizedReedSolomonCode(GF(7).list()[:6],3)'
- `operation` (string, required): One of: length, dimension, minimum_distance, generator_matrix, rate
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.

### `plot3d_expression` (~137 tokens)

Plot a 3D surface of a two-variable expression as base64 PNG

Input parameters:

- `expression` (string, required): Expression of two variables (e.g. 'sin(x)*cos(y)')
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.
- `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` (~103 tokens)

Plot multiple expressions overlaid on a single 2D graph

Input parameters:

- `expressions` (array, required): List of expressions to plot (e.g. ['sin(x)', 'cos(x)'])
- `range_max` (number): Upper bound of plot range
- `range_min` (number): Lower bound of plot range
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.
- `variable` (string): Plot variable

### `plot_expression` (~88 tokens)

Plot an expression and return a base64-encoded PNG image

Input parameters:

- `expression` (string, required): Expression to plot
- `range_max` (number): Upper bound of plot range
- `range_min` (number): Lower bound of plot range
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.
- `variable` (string): Plot variable

### `geometry_operation` (~106 tokens)

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

Input parameters:

- `operation` (string, required): One of: distance, polygon_area, polytope_volume, convex_hull_vertices, is_convex
- `points` (array, required): List of points as coordinate lists
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.

### `reset_sage_session` (~44 tokens)

Reset the SageMath session state for the current MCP session

Input parameters:

- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.

Output parameters:

- `message` (string)

### `interrupt_sage_session` (~44 tokens)

Interrupt a running Sage computation while keeping variables defined so far

Input parameters:

- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.

Output parameters:

- `message` (string)

### `cancel_sage_session` (~42 tokens)

Cancel any running Sage computation and restart the worker

Input parameters:

- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.

Output parameters:

- `message` (string)

### `start_sage_session` (~41 tokens)

Start a named Sage workspace with its own independent variables

Input parameters:

- `name` (string, required): Workspace name, e.g. 'curves' or 'scratch'

Output parameters:

- `message` (string)

### `list_sage_sessions` (~21 tokens)

List the named Sage workspaces belonging to this client

### `stop_sage_session` (~31 tokens)

Stop a named Sage workspace and release its worker

Input parameters:

- `name` (string, required): Workspace name to stop

Output parameters:

- `message` (string)

### `statistics_summary` (~76 tokens)

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.

Input parameters:

- `data` (array, required): List of numeric values
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.

### `distribution_operation` (~146 tokens)

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

Input parameters:

- `distribution` (string, required): Distribution name: normal, exponential, poisson, chi_squared, student_t, uniform, beta, gamma
- `n`: Number of samples (for sample operation)
- `operation` (string, required): One of: pdf, cdf, quantile, mean, variance, sample
- `parameters` (array, required): Distribution parameters (e.g. [0, 1] for standard normal)
- `session` (string): Named workspace to use. Workspaces have independent variables; omit for 'default'.
- `x`: Point for pdf/cdf/quantile evaluation

## Diagnostics

Captured diagnostic sections: Provenance, Install scripts, Dependencies. The full working is on the page: https://verifymcp.io/servers/xbp-europe-sagemath-mcp/sagemath-mcp#diagnostics

## Score history

- 2026-08-17: 71
- 2026-08-16: 71
- 2026-08-15: 70
- 2026-08-14: 55

## Links

- PyPI project: https://pypi.org/project/sagemath-mcp/
- Socket report: https://socket.dev/pypi/package/sagemath-mcp
- Repository: https://github.com/XBP-Europe/sagemath-mcp
- Changelog RSS feed: https://verifymcp.io/servers/xbp-europe-sagemath-mcp/sagemath-mcp.xml
- Changelog JSON feed: https://verifymcp.io/servers/xbp-europe-sagemath-mcp/sagemath-mcp.json
- HTML version of this page: https://verifymcp.io/servers/xbp-europe-sagemath-mcp/sagemath-mcp
