Skip to main content
Glama
GaloisHLee
by GaloisHLee

SageMath Version

sagemath_version

Retrieve the version details of the local SageMath installation to verify compatibility and ensure proper setup for mathematical computations.

Instructions

Get local SageMath version information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
stderrYes
stdoutYes
exitCodeYes
timedOutYes
durationMsYes

Implementation Reference

  • src/index.ts:14-39 (registration)
    Registers the sagemath_version MCP tool, defining its schema and a thin handler wrapper that calls getSageVersion and formats the MCP response.
    server.registerTool(
      'sagemath_version',
      {
        title: 'SageMath Version',
        description: 'Get local SageMath version information',
        inputSchema: {},
        outputSchema: {
          stdout: z.string(),
          stderr: z.string(),
          exitCode: z.number().nullable(),
          durationMs: z.number(),
          timedOut: z.boolean(),
        },
      },
      async () => {
        const result = await getSageVersion();
        const structured = result as unknown as Record<string, unknown>;
        return {
          content: [{
            type: 'text',
            text: `SageMath version response (structured JSON below)\n${JSON.stringify(structured)}`,
          }],
          structuredContent: structured,
        };
      }
    );
  • Core handler logic for sagemath_version: spawns the SageMath executable with '--version' argument using the runProcess utility, returning stdout, stderr, exit code, etc.
    export async function getSageVersion(timeoutMs = 5000): Promise<SageRunResult> {
      const sage = getSageExecutable();
      return runProcess(sage, ['--version'], timeoutMs);
    }
  • Input schema (empty) and output schema using Zod for validation of sagemath_version tool response fields.
    {
      title: 'SageMath Version',
      description: 'Get local SageMath version information',
      inputSchema: {},
      outputSchema: {
        stdout: z.string(),
        stderr: z.string(),
        exitCode: z.number().nullable(),
        durationMs: z.number(),
        timedOut: z.boolean(),
      },
    },
  • TypeScript interface defining the structure of SageMath execution results, matching the tool's output schema.
    export interface SageRunResult {
      stdout: string;
      stderr: string;
      exitCode: number | null;
      durationMs: number;
      timedOut: boolean;
    }
  • Utility function to spawn and manage SageMath child processes with timeout, stdout/stderr capture, and error handling.
    async function runProcess(cmd: string, args: string[], timeoutMs: number): Promise<SageRunResult> {
      const start = Date.now();
      let stdout = '';
      let stderr = '';
      let timedOut = false;
    
      return new Promise<SageRunResult>((resolve) => {
        let child: ReturnType<typeof spawn> | undefined;
        try {
          child = spawn(cmd, args, { stdio: ['ignore', 'pipe', 'pipe'] });
        } catch (err: any) {
          resolve({
            stdout: '',
            stderr: `Failed to spawn process: ${err?.message || String(err)}`,
            exitCode: null,
            durationMs: Date.now() - start,
            timedOut: false,
          });
          return;
        }
    
        const t = setTimeout(() => {
          timedOut = true;
          try { child?.kill('SIGKILL'); } catch {}
        }, Math.max(1, timeoutMs));
    
        // Handle asynchronous spawn errors (e.g., command not found)
        child.on('error', (err) => {
          clearTimeout(t);
          resolve({
            stdout: '',
            stderr: `Process error: ${err?.message || String(err)}`,
            exitCode: null,
            durationMs: Date.now() - start,
            timedOut,
          });
        });
    
        child.stdout?.on('data', (d) => { stdout += d.toString(); });
        child.stderr?.on('data', (d) => { stderr += d.toString(); });
    
        child.on('close', (code) => {
          clearTimeout(t);
          resolve({
            stdout,
            stderr,
            exitCode: code,
            durationMs: Date.now() - start,
            timedOut,
          });
        });
      });
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It indicates a read-only operation ('Get') but doesn't disclose behavioral traits such as performance characteristics, error handling, or what specific information is returned. It's minimally adequate but lacks depth.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It's front-loaded with the core purpose, making it easy to understand quickly. Every part of the sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (0 parameters, no annotations, but with an output schema), the description is reasonably complete for its purpose. However, it could benefit from more context about the output format or usage scenarios, especially with sibling tools present.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters with 100% schema description coverage, so the schema fully documents the input structure. The description adds no parameter details, which is acceptable here, but doesn't compensate for any gaps since there are none. Baseline is 4 for zero parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and resource ('local SageMath version information'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'sagemath_health' which might also provide version-related information, preventing a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'sagemath_health' or 'sagemath_evaluate'. The description implies usage for retrieving version info but lacks explicit context, prerequisites, or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/GaloisHLee/mcp-server-sagemath'

If you have feedback or need assistance with the MCP directory API, please join our Discord server