Get the FREE Ultimate OpenClaw Setup Guide →

mcp -sagemath

MCP server from GaloisHLee/mcp-server-sagemath

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio galoishlee-mcp-server-sagemath node /absolute/path/to/mcp-server-sagemath/dist/index.js

How to use

This MCP SageMath Server exposes three tools to interact with a local SageMath installation: sagemath_version, sagemath_evaluate, and sagemath_health. The server supports two transport modes: the default STDIO mode for tight integration and an optional HTTP mode (enabled via environment variable MCP_TRANSPORT). When using HTTP, the server exposes a GET /mcp endpoint for streaming JSON-RPC data and a POST /mcp endpoint for standard JSON-RPC over HTTP. Before querying tools, you can run sagemath_health to quickly verify SageMath is available. Use sagemath_version to check the installed SageMath version, and sagemath_evaluate to execute SageMath scripts and capture stdout and stderr.

How to install

Prerequisites:

  • Node.js 18+ (recommended 20+).
  • SageMath installed locally and accessible from the command line (sage can be invoked).

Installation steps:

  1. Ensure Node.js is installed on your system.
  2. Clone or download the MCP SageMath server repository.
  3. In the project root, install dependencies:
    npm install
    
  4. Verify SageMath path configuration (optional). You can set SAGE_PATH via environment or in the config file if supported by your setup. Example in code: export const config = { sagePath: "/opt/sage/bin/sage" }.
  5. Run the server in STDIO mode by starting the built distribution (or development mode, if applicable):
    npm run build
    node dist/index.js
    
  6. (Optional) Run in HTTP mode by enabling MCP_TRANSPORT and starting the server:
    MCP_TRANSPORT=http PORT=3000 npm run dev
    

Additional notes

Tips and considerations:

  • The sagemath_evaluate tool runs arbitrary SageMath code; use caution and consider sandboxing when exposed over HTTP.
  • SageMath path can be configured via config.sagePath, via SAGE_PATH environment variable, or fallback to the system sage command in PATH.
  • When deploying HTTP mode, consider network restrictions, authentication, and rate limiting to protect the service.
  • The health check runs print(1+1) and can be used as a quick startup sanity probe before other tool calls.
  • The server is designed to be stateless across HTTP requests to avoid issues related to session persistence.
  • If SageMath is unavailable, the server will return structured errors instead of crashing.

Related MCP Servers

Sponsor this space

Reach thousands of developers