sagemath-mcp-server MCP Server
MCP server wrapping SageMath's full computer algebra system — 10 symbolic-math tools for LLMs.
sagemath-mcp-server scores 67 (Good), licensed CC0-1.0 and written in TypeScript. It installs as a local process. It declares 10 tools. Filed under Uncategorized. GitHub shows 1 stars. Package registries report about 483 downloads a week. Install configs are generated for 10 clients. Being listed in the registry is not the same as being vendor-official.
Good trust
67 of 100 from six public signals. Nobody can buy a point.
- Listed in the official MCP registry.
- OSI-style license: cc0-1.0.
License, quality and maintenance
Quality: Grade A
86/100 for listing completeness. Lost points: 2 of 10 tools barely described, short summary, no docs link.
How quality is graded
Where the 67 comes from
22 + 20 + 1 + 10 + 4 + 10 = 67. Each factor is capped, so no single signal can carry a listing.
Active in the official MCP registry, plus a known vendor namespace.
Registry: 22 of 30 points.How recently the repository saw a commit or release.
Maintenance: 20 of 20 points.GitHub stars and weekly downloads, on a log scale.
Popularity: 1 of 20 points.A clear, OSI-style open-source license.
License: 10 of 10 points.Not archived, a secure install path, a pinned version.
Security: 4 of 10 points.A real summary, a README with depth, listed tools.
Docs: 10 of 10 points.Install
Pick your client, copy the config, paste it in.
Needs Cursor or VS Code installed on this device. The button opens the app and asks you to confirm before it adds the server.
{ "mcpServers": { "justice8096-sagemath-mcp-server": { "command": "npx", "args": [ "-y", "@justice8096/sagemath-mcp-server@1.0.1" ], "env": { "SAGE_TIMEOUT": "", "SAGE_DOCKER_IMAGE": "", "TRANSPORT": "", "PORT": "", "API_KEY": "YOUR_API_KEY" } } }}
Environment variables
| Name | Required | Notes |
|---|---|---|
SAGE_TIMEOUT | Optional | Per-call SageMath timeout in milliseconds. Default 30000. |
SAGE_DOCKER_IMAGE | Optional | Docker image used when SageMath is not installed locally. Default sagemath/sagemath:latest. |
TRANSPORT | Optional | Transport mode: 'stdio' (default) or 'http'. |
PORT | Optional | HTTP port when TRANSPORT=http. Default 3000. |
API_KEYSecret | Optional | If set, HTTP transport requires matching API_KEY header. Ignored for stdio. |
Tools10Tool docs quality grade D
All capabilitiesCompute derivatives (any order, any variable).
sage_evaluatetoolRun an arbitrary SageMath expression.
sage_factortoolFactor polynomials or integers.
sage_integratetoolIndefinite and definite integrals.
Convert a SageMath expression to LaTeX.
sage_matrix_opstoolDeterminant, inverse, eigenvalues, rank, RREF, transpose over QQ / RR / ZZ / CC.
isprime, nextprime, factor, eulerphi, gcd, lcm, primerange, sigma, moebius.
sage_plottoolPlot an expression and return a base64 PNG.
sage_simplifytoolSimplify expressions (default, full, trig, rational).
Solve algebraic / transcendental equations symbolically.
About
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
| Tool | Description |
|---|---|
sage_evaluate | Run an arbitrary SageMath expression. |
sage_solve_equation | Solve algebraic / transcendental equations symbolically. |
sage_differentiate | Compute derivatives (any order, any variable). |
sage_integrate | Indefinite and definite integrals. |
sage_simplify | Simplify expressions (default, full, trig, rational). |
sage_factor | Factor polynomials or integers. |
sage_matrix_ops | Determinant, inverse, eigenvalues, rank, RREF, transpose over QQ / RR / ZZ / CC. |
sage_plot | Plot an expression and return a base64 PNG. |
sage_latex_convert | Convert a SageMath expression to LaTeX. |
sage_number_theory | is_prime, next_prime, factor, euler_phi, gcd, lcm, prime_range, sigma, moebius. |
All tools follow the same schema pattern (see src/schemas/common.ts).
Every tool except sage_evaluate accepts plain mathematics only: numbers, variable names, operators, brackets, and a fixed list of math functions (see src/services/expression-guard.ts). Anything else is refused with a message that points to sage_evaluate, which runs any SageMath code.
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
npm install -g @justice8096/sagemath-mcp-server
# requires `sage` on PATH — see https://doc.sagemath.org/html/en/installation/
sagemath-mcp
Option 2: Docker (no local SageMath required)
docker compose up
# uses the official sagemath/sagemath image; the server runs inside the container
Option 3: from source
git clone https://github.com/justice8096/sagemath-mcp-server.git
cd sagemath-mcp-server
npm install
npm run build
npm start
Configuring an MCP client
Claude Desktop / Claude Code (stdio transport)
Add to ~/.claude.json (or the equivalent Claude Desktop config):
{
"mcpServers": {
"sagemath": {
"command": "sagemath-mcp"
}
}
}
Remote / HTTP transport
The HTTP transport requires an API key. The server will not start in HTTP mode without one.
export API_KEY="$(openssl rand -hex 32)"
TRANSPORT=http npm start
The server listens on 127.0.0.1:3000 by default. Point an MCP HTTP client at http://127.0.0.1:3000/mcp and send the key in an X-API-Key header or as Authorization: Bearer <key>.
To accept connections from other machines, set HOST=0.0.0.0 and put TLS in front of the port. Read the Security section first: anyone holding the key can run code on the host.
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 (loopback by default,
API_KEYrequired). - 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
| Env var | Default | Purpose |
|---|---|---|
TRANSPORT | stdio | stdio or http. |
HOST | 127.0.0.1 | Interface the HTTP transport listens on. |
PORT | 3000 | HTTP port when TRANSPORT=http. |
API_KEY | (none) | Required when TRANSPORT=http, at least 16 characters. Sent by clients as X-API-Key or Authorization: Bearer. |
SAGE_EXECUTION_MODE | auto | auto uses Docker when it is installed and running, otherwise a local sage. local or docker forces one. |
SAGE_TIMEOUT | 120000 | Per-call SageMath timeout in milliseconds. The process is killed when it expires. The first call on a host can be slow; lower this once you know how your host behaves. |
SAGE_DOCKER_IMAGE | sagemath/sagemath:latest | Image used in Docker mode. |
SAGE_DOCKER_NETWORK | none | Docker network for each call. none gives the container no network. |
SAGE_DOCKER_MEMORY | 2g | Memory limit for each container. |
Security
SageMath code is Python. sage_evaluate runs any SageMath code, so it can open files, start processes and use the network. Treat access to that tool as the ability to run code. The other nine tools accept plain mathematics only and cannot run code.
- Docker is the default. When Docker is installed and running, each call runs in a throwaway container with no network, no Linux capabilities, and memory and process limits. Without Docker the server uses a local
sage, and the code runs as your user, with your files. SetSAGE_EXECUTION_MODE=dockerto rule out that fallback. - No shell. The program reaches SageMath as a single process argument. Shell characters in tool arguments have no effect. Versions up to 1.0.1 built a shell command line and were open to command injection; upgrade.
- HTTP needs a key. The HTTP transport refuses to start without
API_KEYand listens on loopback by default. - Math-only tools. The nine structured tools check their expressions against an allow-list before anything runs. Quotes, attribute access, keywords and unknown function calls are refused.
- Prompt injection. A model that reads untrusted content can be steered into calling these tools.
sage_evaluateis marked as not read-only so that clients ask before running it. The other nine are read-only. - See
SECURITY.mdandTHREAT_MODEL.mdfor the full posture, andCHANGELOG.mdfor the 1.1.0 security fixes. - Audit reports are 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.1.1. Version 1.1.0 was a security release: versions up to 1.0.1 are vulnerable; see CHANGELOG.md. 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.
Frequently asked questions
What is sagemath-mcp-server MCP Server?
MCP server wrapping SageMath's full computer algebra system — 10 symbolic-math tools for LLMs.
How do I install sagemath-mcp-server MCP Server in Claude Desktop, Cursor, or VS Code?
Pick your client in the Install section on this page and copy the generated config into the client's config file. Step-by-step guides: Claude Desktop, Cursor, and VS Code. sagemath-mcp-server MCP Server runs locally from the npm package @justice8096/sagemath-mcp-server with the command npx -y @justice8096/sagemath-mcp-server@1.0.1.
Is sagemath-mcp-server MCP Server free and open source?
Yes. sagemath-mcp-server MCP Server is released under the CC0-1.0 license, an OSI-approved open-source license, so you can use, modify, and self-host it under those terms.
Does sagemath-mcp-server MCP Server support remote (HTTP) connections?
No remote endpoint is listed for sagemath-mcp-server MCP Server. It runs locally on your machine over stdio, started by your MCP client.
What tools does sagemath-mcp-server MCP Server provide?
sagemath-mcp-server MCP Server provides 10 tools, including sage_differentiate, sage_evaluate, sage_factor, and sage_integrate. See the full tool list for descriptions and parameters.
How is sagemath-mcp-server MCP Server's trust score calculated?
sagemath-mcp-server MCP Server scores 67 out of 100 (Good). The score adds six capped public signals: registry status, maintenance, popularity, license, documentation, and security. Nobody can pay for points. Read the methodology for the full formula.
Reviews
No reviews yet—Be the first to review
No published reviews yet. Used it? Tell the next person how it went.
Sign inA verified email is required to review this server.
Add badge to your README
Paste either snippet into the repository README. The image links to this listing.