{
  "markdown": "# SageMath MCP Server\n\n[![License: CC0-1.0](https://img.shields.io/badge/License-CC0%201.0-lightgrey.svg)](https://creativecommons.org/publicdomain/zero/1.0/)\n[![npm](https://img.shields.io/npm/v/@justice8096/sagemath-mcp-server.svg)](https://www.npmjs.com/package/@justice8096/sagemath-mcp-server)\n\nA [Model Context Protocol](https://modelcontextprotocol.io) server that exposes [SageMath](https://www.sagemath.org/) — 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.\n\n## Why\n\nLLMs 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.\n\n## Tools\n\n| Tool | Description |\n|---|---|\n| `sage_evaluate` | Run an arbitrary SageMath expression. |\n| `sage_solve_equation` | Solve algebraic / transcendental equations symbolically. |\n| `sage_differentiate` | Compute derivatives (any order, any variable). |\n| `sage_integrate` | Indefinite and definite integrals. |\n| `sage_simplify` | Simplify expressions (`default`, `full`, `trig`, `rational`). |\n| `sage_factor` | Factor polynomials or integers. |\n| `sage_matrix_ops` | Determinant, inverse, eigenvalues, rank, RREF, transpose over `QQ` / `RR` / `ZZ` / `CC`. |\n| `sage_plot` | Plot an expression and return a base64 PNG. |\n| `sage_latex_convert` | Convert a SageMath expression to LaTeX. |\n| `sage_number_theory` | `is_prime`, `next_prime`, `factor`, `euler_phi`, `gcd`, `lcm`, `prime_range`, `sigma`, `moebius`. |\n\nAll tools follow the same schema pattern (see [`src/schemas/common.ts`](src/schemas/common.ts)).\n\n## Installation\n\nThe server needs either a local SageMath install or Docker available on the host so it can spawn a SageMath process.\n\n### Option 1: npm + local SageMath\n\n```bash\nnpm install -g @justice8096/sagemath-mcp-server\n# requires `sage` on PATH — see https://doc.sagemath.org/html/en/installation/\nsagemath-mcp\n```\n\n### Option 2: Docker (no local SageMath required)\n\n```bash\ndocker compose up\n# uses the official sagemath/sagemath image; the server runs inside the container\n```\n\n### Option 3: from source\n\n```bash\ngit clone https://github.com/justice8096/sagemath-mcp-server.git\ncd sagemath-mcp-server\nnpm install\nnpm run build\nnpm start\n```\n\n## Configuring an MCP client\n\n### Claude Desktop / Claude Code (stdio transport)\n\nAdd to `~/.claude.json` (or the equivalent Claude Desktop config):\n\n```json\n{\n  \"mcpServers\": {\n    \"sagemath\": {\n      \"command\": \"sagemath-mcp\"\n    }\n  }\n}\n```\n\n### Remote / HTTP transport\n\n```bash\nTRANSPORT=http API_KEY=your-secret-key npm start\n```\n\nThen point an MCP HTTP client at `http://<host>:3000/mcp` with the matching `API_KEY` header.\n\n## Architecture\n\n- **TypeScript** wrapper, runtime is Node.js ≥ 18.\n- **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](https://www.gnu.org/licenses/gpl-faq.en.html). Embedding via FFI would propagate copyleft; subprocess execution does not.\n- **Dual transport** — stdio (Claude Desktop, Claude Code, local MCP clients) and Streamable HTTP (remote deployment, optional `API_KEY` env var).\n- **i18n** — English, Spanish, French via [`src/i18n.ts`](src/i18n.ts) and [`locales/`](locales).\n- **Multi-format build** — `build.ts` emits Claude plugin, OpenAI function-calling, n8n node, MCP server descriptor, CLI tool, and YAML prompt-library outputs from the same source manifest.\n\n## Configuration\n\n| Env var | Default | Purpose |\n|---|---|---|\n| `TRANSPORT` | `stdio` | `stdio` or `http`. |\n| `PORT` | `3000` | HTTP port when `TRANSPORT=http`. |\n| `API_KEY` | (none) | If set, HTTP requests must include matching `API_KEY` header. |\n| `SAGE_TIMEOUT` | `30000` | Per-call SageMath timeout in milliseconds. |\n| `SAGE_DOCKER_IMAGE` | `sagemath/sagemath:latest` | Image used when SageMath isn't installed locally. |\n\n## Security\n\n- All SageMath input is sanitized to strip shell metacharacters before subprocess execution; see [`src/services/sage-executor.ts`](src/services/sage-executor.ts).\n- HTTP transport requires `API_KEY` if set — there is no default credential.\n- See [`SECURITY.md`](SECURITY.md) and [`THREAT_MODEL.md`](THREAT_MODEL.md) for the full posture.\n- Pre-commit audit suite under [`audits/`](audits/): SAST/DAST scan, supply-chain audit, CWE mapping, LLM-compliance report, contribution analysis.\n\n## License\n\nThis wrapper is released under [CC0-1.0](LICENSE) (public domain). SageMath itself remains GPL-3.0; the subprocess execution model keeps the licenses independent. See [`SECURITY.md`](SECURITY.md) and the project's [compliance analysis](https://github.com/justice8096/sagemath-mcp-server/blob/main/audits/llm-compliance-report.md) for the legal reasoning.\n\n## Status\n\n`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.\n",
  "bytes": 5489,
  "sha": "5695f3f1b450701afae5a9dafe5c2a439b763156ebe748345a9ae3c1d1ae68c1",
  "repo_slug": "justice8096/sagemath-mcp-server",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_justice8096_sagemath_mcp_serve_bcd61a52/readme"
}