- Home
- MCP servers
- SageMath
SageMath
- typescript
8
GitHub Stars
typescript
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
You can run a local SageMath service that integrates with the Model Context Protocol (MCP). This server lets you query the SageMath version, execute SageMath scripts, and quickly health-check the SageMath environment, all through either a STDIO-based local process or an HTTP endpoint for remote clients.
How to use
Choose your preferred transport and connect with an MCP client. You can run the server locally in STDIO mode for direct usage or enable HTTP mode to accept remote JSON-RPC requests. Once connected, start by verifying SageMath is available, then perform script evaluations as needed.
How to install
Prerequisites: install Node.js 18+ (Node.js 20+ recommended) and ensure SageMath is installed and accessible from the command line.
Install dependencies for the project from your workspace root.
npm install
Configuration and usage details
You can configure how SageMath is located on your system. The server searches in this order: a configured path, then SAGE_PATH environment variable, then the system PATH with the sage command. By default, it reads SAGE_PATH if you don’t set a specific path.
Example explicit path configuration in code (if you want to fix the SageMath executable path):
export const config = {
sagePath: "/opt/sage/bin/sage",
};
Testing and running modes
STDIO (default): build and run the local process, then test with a client that talks via STDIO.
HTTP (optional): enable an HTTP transport and test with an HTTP client. The default endpoint is http://localhost:3000/mcp, adjustable via PORT.
Regular test commands shown in examples include running a test client to exercise the STDIO or HTTP interface.
Available tools
sagemath_version
Outputs stdout, stderr, exitCode, durationMs, timedOut to determine whether SageMath is installed and to reveal the version.
sagemath_evaluate
Accepts a SageMath code string and optional timeoutMs, writes code to a temporary file, executes SageMath, and returns stdout, stderr, exitCode, durationMs, timedOut.
sagemath_health
Performs a lightweight self-check by running print(1+1); returns ok, message, and details including stdout/stderr/exitCode to verify SageMath readiness.