mcp -sagemath
MCP server from GaloisHLee/mcp-server-sagemath
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:
- Ensure Node.js is installed on your system.
- Clone or download the MCP SageMath server repository.
- In the project root, install dependencies:
npm install - 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" }.
- Run the server in STDIO mode by starting the built distribution (or development mode, if applicable):
npm run build node dist/index.js - (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
iterm
A Model Context Protocol server that executes commands in the current iTerm session - useful for REPL and CLI assistance
mcp
Octopus Deploy Official MCP Server
furi
CLI & API for MCP management
editor
MCP Server for Phaser Editor
DoorDash
MCP server from JordanDalton/DoorDash-MCP-Server
mcp
MCP сервер для автоматического создания и развертывания приложений в Timeweb Cloud