
Sagemath Mcp Server
io.github.justice8096Published by GitHub account justice8096v1.0.1Updated Oct 25, 2026
MCP server wrapping SageMath's full computer algebra system — 10 symbolic-math tools for LLMs.
Overview
A local MCP server that wraps SageMath, giving an assistant 10 tools for exact symbolic math: solving, calculus, factoring, matrices, number theory, plots andLa
- What you can do
- Run arbitrary SageMath expressions and solve algebraic or transcendental equations symbolically. Compute derivatives and indefinite or definite integrals, and simplify expressions in several modes. Factor polynomials and integers, and do matrix operations such as determinant, inverse, eigenvalues, rank and RREF. Perform number-theory operations like primality tests, next prime, Euler phi, gcd, lcm and prime ranges. Plot expressions as base64 PNG images and convert expressions to LaTeX.
- When to use it
- Use it when an assistant needs reliable exact or symbolic computation rather than mental arithmetic: multi-step algebra, calculus, matrix work, number theory, or producing LaTeX and plots for math write-ups.
- Requirements
- Runs locally as a Node.js 18 or newer process, installed from npm. Needs either a local SageMath install with sage on PATH or Docker to run the SageMath image. Optional environment variables: TRANSPORT, PORT, API_KEY, SAGE_TIMEOUT and SAGE_DOCKER_IMAGE.
Installation
In SourceWeft
- Open Sagemath Mcp Server in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
SageMath MCP Server
A Model Context Protocol server that exposes SageMath — a 100+ package computer algebra system — to LLM clients such as Claude. Where most "math MCPs" wrap a single library (SymPy, mathjs), this one subprocess-wraps the entire SageMath stack so the model has access to genuine symbolic mathematics, not arithmetic.
Why
LLMs are bad at exact arithmetic, brittle with multi-step algebra, and unreliable when symbolic manipulation matters. The right pattern is to keep the conceptual reasoning in the model and delegate mechanical computation to a tool — the same trick a person with dyscalculia uses with a calculator. SageMath gives you the broadest tool surface for that delegation: factoring, integration, eigenvalues, number theory, LaTeX rendering, and plotting all behind one interface.
Tools
All tools follow the same schema pattern (see src/schemas/common.ts).
Installation
The server needs either a local SageMath install or Docker available on the host so it can spawn a SageMath process.
Option 1: npm + local SageMath
Option 2: Docker (no local SageMath required)
Option 3: from source
Configuring an MCP client
Claude Desktop / Claude Code (stdio transport)
Add to ~/.claude.json (or the equivalent Claude Desktop config):
Remote / HTTP transport
Then point an MCP HTTP client at http://<host>:3000/mcp with the matching API_KEY header.
Architecture
- TypeScript wrapper, runtime is Node.js ≥ 18.
- Subprocess wrapping — the wrapper code is CC0; SageMath remains GPL-3.0 and runs as a separate process, which is the canonical safe interaction model per the GNU GPL FAQ on aggregation. Embedding via FFI would propagate copyleft; subprocess execution does not.
- Dual transport — stdio (Claude Desktop, Claude Code, local MCP clients) and Streamable HTTP (remote deployment, optional
API_KEYenv var). - i18n — English, Spanish, French via
src/i18n.tsandlocales/. - Multi-format build —
build.tsemits Claude plugin, OpenAI function-calling, n8n node, MCP server descriptor, CLI tool, and YAML prompt-library outputs from the same source manifest.
Configuration
Security
- All SageMath input is sanitized to strip shell metacharacters before subprocess execution; see
src/services/sage-executor.ts. - HTTP transport requires
API_KEYif set — there is no default credential. - See
SECURITY.mdandTHREAT_MODEL.mdfor the full posture. - Pre-commit audit suite under
audits/: SAST/DAST scan, supply-chain audit, CWE mapping, LLM-compliance report, contribution analysis.
License
This wrapper is released under CC0-1.0 (public domain). SageMath itself remains GPL-3.0; the subprocess execution model keeps the licenses independent. See SECURITY.md and the project's compliance analysis for the legal reasoning.
Status
v1.0.0 — public release. The wrapper layer is stable; the SageMath surface is feature-rich and stable upstream. File issues at https://github.com/justice8096/sagemath-mcp-server/issues.
Source: README.md at commit da1a377
Tools
0Version history
1- v1.0.1LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts