# SageMath

An MCP server that gives your agent a sandboxed SageMath session which keeps state between calls, with 40 tools and a checker for claimed results.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 18
- Author: XBP-Europe
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/XBP-Europe/sagemath-mcp
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/mcp/sagemath

## What it does

Every MCP session gets its own Sage worker process, so variables, functions and assumptions survive from one tool call to the next. The 40 tools cover symbolic calculus, number theory, linear algebra, ODEs, plots, combinatorics, groups and elliptic curves. One of them, `verify_claim`, runs a stated result up the proof ladder and returns `proved`, `refuted`, `supported` or `undecided` with the evidence attached.

Caller code is deny-by-default: imports, external CAS interfaces, file access and display primitives are refused. The policy lets through 98.9% of SageMath's own 438,124 documented examples, and each refusal maps to a named rule. Install with `pip install "sagemath-mcp[passagemath]"` on Python 3.12: about 1 GB, no Docker, no Sage build.

On 3.13 and later `memory-allocator` gets compiled from source, which calls for a C compiler, and `uvx` without `--python` grabs the newest interpreter it can find and fails there. macOS and Linux work; native Windows is partial, so use the container or WSL. Worth knowing too: a pip install runs with your own privileges, so for untrusted input or a shared host take the container build.

## Requirements
- Needs: Python and uv (commands run via uvx)

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add sagemath-mcp -- uvx sagemath-mcp
```
uvx runs the command named after the package; if the README names another one, use uvx --from sagemath-mcp <command>

### Codex

**Platform CLI**
```bash
codex mcp add sagemath -- uvx sagemath-mcp
```
uvx runs the command named after the package; if the README names another one, use uvx --from sagemath-mcp <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "sagemath": {
            "command": "uvx",
            "args": [
                "sagemath-mcp"
            ]
        }
    }
}
```
uvx runs the command named after the package; if the README names another one, use uvx --from sagemath-mcp <command>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "sagemath": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "sagemath-mcp"
            ]
        }
    }
}
```
uvx runs the command named after the package; if the README names another one, use uvx --from sagemath-mcp <command>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add sagemath uvx sagemath-mcp
```
uvx runs the command named after the package; if the README names another one, use uvx --from sagemath-mcp <command>

## When to use it
- compute an integral or a limit without leaving the chat for a Sage REPL
- keep assumptions and variables alive across tool calls
- re-check a stated theorem with `verify_claim`
- plot a function or a group's Cayley graph from a description
- factor a large integer and inspect which divisors are prime

## Example prompts
- Factor 2^67 − 1 and tell me which of the divisors are prime
- Assume x is real and work out the limit of sin(x)/x as x goes to 0
- Run `verify_claim` on the statement that x^4+1 is irreducible over Q

## Similar
- [Zotero MCP](https://affpapa.org/en/nevibecode/mcp/zotero-mcp.md) — MCP server · ★ 5548
- [arxiv-mcp-server](https://affpapa.org/en/nevibecode/mcp/arxiv-mcp-server.md) — MCP server · ★ 3231
- [PaperBanana](https://affpapa.org/en/nevibecode/mcp/paperbanana.md) — MCP server · ★ 2417
- [MATLAB MCP Server](https://affpapa.org/en/nevibecode/mcp/matlab-mcp-server.md) — MCP server · ★ 1716
- [Hex Research](https://affpapa.org/en/nevibecode/mcp/hex-research.md) — MCP server · ★ 583
- [DocsAgent — Zotero, Obsidian & Apple Notes MCP Server](https://affpapa.org/en/nevibecode/mcp/docsagent-zotero-obsidian-apple-notes-mcp-server.md) — MCP server · ★ 578

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
