Skip to main content
Glama
GaloisHLee
by GaloisHLee

SageMath Health Check

sagemath_health

Check SageMath availability and basic readiness for mathematical computations through the MCP SageMath Server.

Instructions

Lightweight self-check of SageMath availability and basic readiness

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okYes
detailsNo
messageYes

Implementation Reference

  • Inline handler function for the 'sagemath_health' tool. Performs a simple 'print(1+1)' evaluation to check if SageMath is responsive and returns structured health status.
    async () => {
      const health = await evaluateSage('print(1+1)', 3000);
      const ok = !health.timedOut && health.exitCode === 0;
      return {
        content: [{
          type: 'text',
          text: `${ok ? 'SageMath is responsive' : 'SageMath check failed'} (structured JSON below)\n${JSON.stringify({ ok, details: health })}`,
        }],
        structuredContent: {
          ok,
          message: ok ? 'SageMath executed a trivial script successfully.' : 'SageMath failed to execute a trivial script.',
          details: health,
        },
      };
    }
  • Input and output schema definition for the 'sagemath_health' tool using Zod.
    {
      title: 'SageMath Health Check',
      description: 'Lightweight self-check of SageMath availability and basic readiness',
      inputSchema: {},
      outputSchema: {
        ok: z.boolean(),
        message: z.string(),
        details: z.record(z.unknown()).optional(),
      },
    },
  • src/index.ts:71-98 (registration)
    Registration of the 'sagemath_health' tool on the MCP server.
    server.registerTool(
      'sagemath_health',
      {
        title: 'SageMath Health Check',
        description: 'Lightweight self-check of SageMath availability and basic readiness',
        inputSchema: {},
        outputSchema: {
          ok: z.boolean(),
          message: z.string(),
          details: z.record(z.unknown()).optional(),
        },
      },
      async () => {
        const health = await evaluateSage('print(1+1)', 3000);
        const ok = !health.timedOut && health.exitCode === 0;
        return {
          content: [{
            type: 'text',
            text: `${ok ? 'SageMath is responsive' : 'SageMath check failed'} (structured JSON below)\n${JSON.stringify({ ok, details: health })}`,
          }],
          structuredContent: {
            ok,
            message: ok ? 'SageMath executed a trivial script successfully.' : 'SageMath failed to execute a trivial script.',
            details: health,
          },
        };
      }
    );
  • Helper function 'evaluateSage' that executes SageMath code by writing to temp file and spawning process. Used by the health handler for the simple check.
    export async function evaluateSage(code: string, timeoutMs = 10000): Promise<SageRunResult & { tmpDir?: string }> {
      const sage = getSageExecutable();
      const tmpRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'mcp-sage-'));
      const scriptPath = path.join(tmpRoot, 'script.sage');
      await fs.writeFile(scriptPath, code, 'utf8');
    
      const result = await runProcess(sage, [scriptPath], timeoutMs);
    
      // Attempt cleanup
      try { await fs.rm(tmpRoot, { recursive: true, force: true }); } catch {}
    
      return { ...result };
    }
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 describes the tool as a 'lightweight self-check' which implies it's a read-only, non-destructive operation that tests availability and readiness. However, it doesn't specify what 'readiness' entails, potential error conditions, or performance characteristics like execution time.

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 that clearly communicates the core functionality without unnecessary words. It's appropriately sized for a simple health check tool and front-loads the essential information.

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 (zero parameters, has output schema), the description is reasonably complete. The output schema will handle return value documentation, so the description appropriately focuses on purpose. However, it could better address when to use this versus sibling tools for full completeness.

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 zero parameters with 100% schema description coverage. The description appropriately doesn't discuss parameters since none exist, maintaining focus on the tool's purpose. This meets the baseline expectation for parameterless tools.

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 tool's purpose: 'Lightweight self-check of SageMath availability and basic readiness.' It specifies the verb ('self-check') and resource ('SageMath'), but doesn't explicitly differentiate from sibling tools like 'sagemath_version' which might provide similar system information.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'sagemath_evaluate' or 'sagemath_version', nor does it specify scenarios where a health check is appropriate versus other diagnostic operations.

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