SageMath logo

SageMath

Run sandboxed SageMath calculations through MCP, with persistent sessions for symbolic math, algebra, graphs, plots, and more.

Install SageMath

Pick your client, then add it in one click or paste the config.

STDIOPython
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "sagemath": {
      "command": "uvx",
      "args": [
        "--python",
        "3.12",
        "--from",
        "sagemath-mcp[passagemath]",
        "sagemath-mcp"
      ]
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

Install not yet sandbox-tested— the server itself is confirmed live (we called its tools/list endpoint). The stdio install command is a separate, ongoing check.

Overview

SageMath MCP server connects MCP clients to a sandboxed SageMath runtime for symbolic mathematics, algebra, calculus, number theory, linear algebra, graph theory, and plotting. Dedicated tools handle common operations such as solving equations, differentiating expressions, analyzing matrices, and factoring integers, while `evaluate_sage` supports multi-step work in a persistent session. Each client receives its own Sage worker, so variables, functions, and assumptions remain available between calls. Reach for it when an agent needs mathematical computation rather than general-purpose code execution, especially for workflows that build and inspect Sage objects over several steps.

Use cases

  • Solve symbolic equations and differential equations
  • Analyze matrices, graphs, groups, and elliptic curves
  • Build persistent multi-step SageMath calculations
  • Generate 2D and 3D mathematical plots

Key features

  • Persistent SageMath worker per MCP client
  • Deny-by-default mathematical code evaluation
  • Dedicated symbolic, algebraic, and numerical operations
  • Graph, group, number-theory, and coding-theory tools
  • Rendered 2D, multi-expression, and 3D plots
  • stdio and streamable HTTP transports

Tools40

What SageMath lets your agent do. Expand a tool for its parameters.

Verified live~9.1k tokens of context

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked 2d ago

Recent health check succeeded.

10/10 checks healthy over the last 52d

What it can do

From the 40 tools this server returned when we ran it; 40 declare their own safety hints.

Runs commands · 1Can delete or modify data · 3Read-only tools · 36
Network at startup2 connections
Files written at startup2

Observed 2026-10-22 in an isolated sandbox. A description of reach, not a security audit.

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 6d ago via OSV.dev · sagemath-mcp (PyPI)

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars18Stargazers on the source repository.
Last commit2d agoMost recent push to the default branch.
Tools exposed40Callable tools this server registers over MCP.
Directory activity1 viewsConfig copies, upvotes, and views on AllMCPs.

How SageMath works

What SageMath MCP server does

SageMath MCP server exposes a mathematical subset of SageMath through the Model Context Protocol. It covers symbolic calculus, equations, polynomial rings, Boolean algebra over GF(2), linear algebra, ordinary differential equations, number theory, combinatorics, graph and group theory, elliptic curves, coding theory, statistics, vector calculus, and rendered 2D or 3D plots.

The server is stateful per MCP client. Values assigned during one Sage evaluation remain available in later calls from that client, which makes it suitable for workflows such as constructing a matrix and then examining several of its properties, or defining a number field before querying its invariants.

How it works

A client sends tool calls over MCP. Dedicated operation tools validate common mathematical requests and return structured results for tasks such as matrix operations, root finding, integration, graph properties, and code parameters. evaluate_sage runs Sage code in the client’s persistent session and returns the result; evaluate_sage_streaming additionally sends intermediate print() output as it is produced.

The evaluation policy is deny-by-default. Ordinary mathematical Sage code is allowed, while imports, external computer algebra interfaces, and file, display, or persistence operations are refused. check_sage_health starts or reuses the worker, evaluates a basic expression, and reports readiness and latency. lookup_sage_doc provides documentation links for Sage names and indicates whether a name is available to caller code.

Setup and configuration

The recommended installation uses Python 3.12 with the passagemath extra:

Terminal
pip install "sagemath-mcp[passagemath]"
sagemath-mcp

The default transport is stdio. Streamable HTTP can be enabled on a local port:

bash
sagemath-mcp --transport streamable-http --port 8314

uvx --python 3.12 --from "sagemath-mcp[passagemath]" sagemath-mcp runs the package without a permanent installation. The Python 3.12 requirement is important for the documented wheel-based setup. macOS and Linux are supported; Windows has partial native support, with WSL or the container recommended.

A container image is available for stronger isolation. The documented deployment binds HTTP to loopback, uses a read-only filesystem with temporary filesystems, drops capabilities, enables no-new-privileges, and applies process and memory limits. A separate -passagemath image supports both amd64 and arm64. The HTTP server authenticates no clients, so it should not be exposed beyond a trusted environment.

Tools and capabilities

  • Solve equations and ordinary differential equations, and compute derivatives, integrals, limits, series, and symbolic sums.
  • Simplify, expand, factor, evaluate, and find numeric roots of expressions.
  • Multiply matrices and calculate determinants, inverses, eigenvalues, rank, reduced row echelon form, and transposes.
  • Work with polynomial rings, ideals, quotients, Boolean polynomials, number theory, combinatorics, graphs, groups, elliptic curves, and error-correcting codes.
  • Compute vector-calculus operations, statistics and distributions, and render single, multiple, or three-dimensional plots.
  • Use persistent Sage code for transformations, recurrences, continued fractions, number fields, modular arithmetic, and other multi-step calculations.

Limitations and notes

Dedicated tools run in fresh namespaces, so they cannot access variables created through evaluate_sage. Use the persistent evaluator when later steps depend on earlier definitions. For a single supported calculation, the dedicated operation is generally preferable because it validates arguments and returns a typed result rather than a representation string.

The Sage policy restricts access to non-mathematical capabilities but is not an operating-system security boundary. Running the package with local privileges is intended for trusted use; untrusted input, shared hosts, and multi-tenant deployments should use the hardened container setup. The bundled desktop package installs the Sage runtime through uv on first launch and is available for macOS and Linux.

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about SageMath

SageMath is an MCP server that connects AI clients to a sandboxed SageMath runtime. Its main tools evaluate persistent Sage code, solve equations, perform calculus and algebra, analyze matrices, graphs, groups, number theory, and generate plots. Dedicated operations return typed results for common mathematical tasks.

Install it with `pip install "sagemath-mcp[passagemath]"` using Python 3.12, then run `sagemath-mcp`. You can also use `uvx --python 3.12 --from "sagemath-mcp[passagemath]" sagemath-mcp`, or run the provided container image.

Yes, SageMath provides a desktop MCP bundle for Claude Desktop and similar hosts. Download the `.mcpb` file from the latest release and open it; the host installs the server and downloads the Sage runtime on first launch. The bundle supports macOS and Linux.

Yes, `evaluate_sage` uses a persistent session for each MCP client, so variables, functions, and assumptions remain available across calls. Dedicated operation tools use fresh namespaces and cannot access values defined in the persistent evaluator.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewSageMath AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/sagemath?style=directory)](https://allmcps.com/mcp/sagemath)
HTML Embed
<a href="https://allmcps.com/mcp/sagemath"><img src="https://allmcps.com/api/badge/sagemath?style=directory" alt="SageMath on AllMCPs" /></a>