Sagemath MCP Server

MCP server wrapping SageMath's full computer algebra system — 10 symbolic-math tools for LLMs.

Local serverstdioTypeScript

What is the Sagemath MCP server?

Connect Sagemath to Claude, Cursor or any other MCP client and it stops being a tab you switch to. MCP server wrapping SageMath's full computer algebra system — 10 symbolic-math tools for LLMs. The sagemath mcp server is what makes that connection.

What the server does

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.

Available tools

The toolset is worth reading before you wire it up, because it tells you what the integration is really for:

  • 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

Installation

@justice8096/sagemath-mcp-server on npm is all you need. Most clients run it directly, so configuration is a few lines and a restart.

Where it fits

Among the developer tooling options, the useful question is rarely "what can it do" but "what does it cost you to run" — permissions, credentials, and how much of your context its toolset consumes. Sagemath's toolset — sage_evaluate, sage_solve_equation, sage_differentiate and 7 more — is a fair guide to whether it matches your workflow. It is maintained by justice8096; worth a glance at recent repository activity before you build anything load-bearing on it.

SyncDev reviews every entry in this directory against the project's own documentation before publishing, and revisits them as servers change.

Worth knowing first

  • It runs with your machine's permissions. That is convenient and also the reason to think about what you point it at before you approve a tool call.
  • With 10 tools registered it takes up a noticeable share of the context window; turn it off in projects that never touch Sagemath.
  • Keep per-call confirmation enabled while you learn its behaviour; it is the cheapest safeguard you have.

Available tools

ToolWhat it does
sage_evaluateRun an arbitrary SageMath expression.
sage_solve_equationSolve algebraic / transcendental equations symbolically.
sage_differentiateCompute derivatives (any order, any variable).
sage_integrateIndefinite and definite integrals.
sage_simplifySimplify expressions (default, full, trig, rational).
sage_factorFactor polynomials or integers.
sage_matrix_opsDeterminant, inverse, eigenvalues, rank, RREF, transpose over QQ / RR / ZZ / CC.
sage_plotPlot an expression and return a base64 PNG.
sage_latex_convertConvert a SageMath expression to LaTeX.
sage_number_theoryis_prime, next_prime, factor, euler_phi, gcd, lcm, prime_range, sigma, moebius.

How to install the Sagemath MCP server

{
  "mcpServers": {
    "sagemath": {
      "command": "sagemath-mcp"
    }
  }
}

Configuration as documented by the project. Restart the client after saving.

Example prompts to try

  • Use Sagemath to sage evaluate.
  • Use Sagemath to sage solve equation.
  • Use Sagemath to sage differentiate.

Frequently asked questions

It connects Sagemath to MCP-compatible AI assistants such as Claude and Cursor, exposing 10 tools (sage_evaluate, sage_solve_equation, sage_differentiate, and more) that the assistant can call on your behalf. Instead of copying data back and forth by hand, the assistant works with Sagemath directly.