Skip to main content
Glama
loda-lang

LODA API MCP Server

Official
by loda-lang

eval_program

Execute LODA assembly programs to compute mathematical integer sequences from OEIS, generating specified terms with optional offset for sequence analysis.

Instructions

Evaluate a LODA program and return sequence terms.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesLODA program code
oNoOffset (optional)
tNoNumber of terms

Implementation Reference

  • The primary handler function for the 'eval_program' tool. It validates the input arguments, calls the LODA API client to evaluate the program, formats the result or error, and returns it in the MCP response format.
    private async handleEvalProgram(args: { code: string; t?: number; o?: number }) { const { code, t, o } = args; if (!code || typeof code !== 'string') { throw new McpError(ErrorCode.InvalidParams, "code is required"); } const result = await this.apiClient.evalProgram(code, t, o); return { content: [ { type: "text", text: result.status === "success" ? `Result: ${result.terms.join(', ')}` : `Error: ${result.message}${result.terms && result.terms.length ? `\nPartial result: ${result.terms.join(', ')}` : ''}` } ], ...result }; }
  • Input schema definition for the 'eval_program' tool, specifying the required 'code' parameter and optional 't' (terms) and 'o' (offset) parameters with validation rules.
    inputSchema: { type: "object", properties: { code: { type: "string", description: "LODA program code in plain text format." }, t: { type: "number", description: "Number of terms to compute" , minimum: 1, maximum: 10000 }, o: { type: "number", description: "The starting index (offset) for evaluating the sequence program. Overrides #offset directive or defaults to 0." } }, required: ["code"], additionalProperties: false }
  • src/index.ts:415-416 (registration)
    Switch statement case that registers and routes incoming calls to the 'eval_program' tool handler within the CallToolRequestSchema handler.
    case "eval_program": return this.handleEvalProgram(safeArgs as { code: string; t?: number; o?: number });
  • Supporting API client method in LODAApiClient that performs the actual HTTP POST request to the LODA API endpoint /programs/eval to evaluate the provided program code.
    async evalProgram(code: string, t?: number, o?: number): Promise<Result> { const params = new URLSearchParams(); if (t !== undefined) params.append('t', String(t)); if (o !== undefined) params.append('o', String(o)); return this.makeRequest(`/programs/eval${params.size ? '?' + params.toString() : ''}`, { method: 'POST', headers: { 'Content-Type': 'text/plain' }, body: code, }); }
  • src/index.ts:282-295 (registration)
    Tool registration object in the ListTools response, defining the name, description, and input schema for 'eval_program'.
    { name: "eval_program", description: "Evaluate a LODA program to generate the corresponding integer sequence. The request body should contain the program code in plain text format. Optionally specify the number of terms and offset.", inputSchema: { type: "object", properties: { code: { type: "string", description: "LODA program code in plain text format." }, t: { type: "number", description: "Number of terms to compute" , minimum: 1, maximum: 10000 }, o: { type: "number", description: "The starting index (offset) for evaluating the sequence program. Overrides #offset directive or defaults to 0." } }, required: ["code"], additionalProperties: false } },

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/loda-lang/loda-mcp'

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