SageMath — Claude Code MCP server: what it does, how to install
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.
claude mcp add sagemath-mcp -- uvx sagemath-mcpWhat SageMath 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.
What it helps with
- 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 for the agent
- 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_claimon the statement that x^4+1 is irreducible over Q
How to install SageMath
Platform CLI
claude mcp add sagemath-mcp -- uvx sagemath-mcpuvx runs the command named after the package; if the README names another one, use uvx --from sagemath-mcp <command>
Platform CLI
codex mcp add sagemath -- uvx sagemath-mcpuvx runs the command named after the package; if the README names another one, use uvx --from sagemath-mcp <command>
Config file
{
"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>
Config file
{
"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>
Platform CLI
gemini mcp add sagemath uvx sagemath-mcpuvx runs the command named after the package; if the README names another one, use uvx --from sagemath-mcp <command>
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about SageMath
How do I install SageMath MCP in Claude Code?
Run claude mcp add sagemath-mcp -- uvx sagemath-mcp. That registers the server as sagemath-mcp and launches it through uvx.
What does SageMath MCP do?
It hands the agent 40 SageMath tools inside a sandbox: symbolic work, claim verification, plots. Session state carries over between calls.
Which Python version does it need?
Python 3.12 — the version CI tests and the newest where every dependency ships a wheel. From 3.13 on, memory-allocator is compiled from source and needs a C compiler.