loda-lang

LODA API MCP Server

Community loda-lang
Updated

LODA MCP Server

LODA API MCP Server

A Model Context Protocol (MCP) server for the LODA Language API, providing seamless access to the LODA language and integer sequences from the On-Line Encyclopedia of Integer Sequencesยฎ (OEISยฎ).

๐ŸŒŸ Overview

LODA (Lexicographical Order Descent Assembly) is an assembly language and computational model for integer sequences. This MCP server enables you to:

  • ๐Ÿ” Explore integer sequences with rich metadata and formatting
  • ๐Ÿ”ง Discover LODA programs that compute specific sequences
  • โšก Execute programs in real-time and compute sequence terms
  • ๐Ÿ“Š Monitor project statistics

โœจ Features

Core Capabilities

  • OEIS-style Sequence Integration: Access any sequence with A-number formatting
  • Program Discovery: Find and search LODA programs for sequences
  • Real-time Execution: Run LODA programs and see results instantly
  • Robust Error Handling: Comprehensive validation and error messages

Available Tools

Tool Description Primary Use Case
get_sequence Get details about an integer sequence by ID Research mathematical sequences
search_sequences Search for integer sequences Find sequences by keyword or ID
get_program Get details about a LODA program by ID Analyze program implementations
search_programs Search for LODA programs Find programs by keyword or ID
eval_program Evaluate a LODA program Test and validate program correctness
submit_program Submit a new LODA program Contribute new implementations
get_stats View LODA project statistics Understand project scope and growth
get_submitters List all submitters and their number of programs See top contributors

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18.0.0 or higher
  • npm 8.0.0 or higher

Installation

  1. Create and set up project:

    mkdir loda-mcp && cd loda-mcp
    mkdir src
    
    # Copy the TypeScript code to src/index.ts
    # Copy package.json and tsconfig.json to project root
    
  2. Install dependencies:

    npm install
    
  3. Build the server:

    npm run build
    
  4. Test the installation:

    npm run test-connection  # Test API connectivity
    npm start                # Start the server
    

Development Workflow

# Development with auto-rebuild
npm run dev

# Type checking
npm run type-check

# Clean build
npm run clean && npm run build

โš™๏ธ Configuration

Claude Desktop Integration

Add to your Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "loda-api": {
      "command": "node",
      "args": ["/absolute/path/to/your/loda-mcp/build/index.js"],
      "env": {
        "LODA_API_BASE_URL": "https://api.loda-lang.org/v2"
      }
    }
  }
}

Environment Variables

Variable Description Default
LODA_API_BASE_URL LODA API endpoint override https://api.loda-lang.org/v2

๐Ÿ“– Usage Examples

๐Ÿ”ข Exploring OEIS Sequences

"Show me details about OEIS sequence 45"
โ†’ Gets Fibonacci sequence (A000045) with full metadata

"What is OEIS sequence 1?"  
โ†’ Gets A000001 (groups of order n) with terms and description

๐Ÿ”ง Working with LODA Programs

"Find all LODA programs for sequence 45"
โ†’ Shows all programs that compute Fibonacci numbers, sorted by length

"Get LODA program 12345"
โ†’ Retrieves specific program with code and metadata

โšก Running Programs

"Run this LODA program and compute 10 terms:
mov $0,1
lpb $1
  add $0,$1
  sub $1,1
lpe"
โ†’ Executes program and shows computed sequence values

โ›๏ธ Mining New Programs

"Start mining programs for OEIS sequence 142857 with max length 50"
โ†’ Begins mining operation and returns operation ID

"Check status of mining operation 987"  
โ†’ Shows current status and any discovered programs

๐Ÿ“Š Project Statistics

"What are the current LODA project statistics?"
โ†’ Shows number of sequences, programs, and contributors

๐Ÿ”ง API Reference

Tool Schemas

All tools use strict JSON schemas with proper validation. Example schemas:

get_sequence
{
  "id": "A000045"
}
search_sequences
{
  "q": "Fibonacci",
  "limit": 5
}
get_program
{
  "id": "A000045"
}
search_programs
{
  "q": "Fibonacci",
  "limit": 5
}
eval_program
{
  "code": "mov $1,10\npow $1,$0\nmov $0,$1\ndiv $0,9",
  "t": 10
}
submit_program
{
  "id": "A000045",
  "code": "mov $2,1\nlpb $0\n  sub $0,2\n  add $2,$1\n  add $1,$2\nlpe\nmul $0,$2\nadd $0,$1"
}
get_stats
{}
get_submitters
{}

Response Format

All responses include:

  • Rich formatting with emojis and visual structure
  • Clear status indicators
  • Contextual information and helpful tips
  • Proper error messages with actionable guidance

๐Ÿ—๏ธ Architecture

Core Components

LODAMCPServer
โ”œโ”€โ”€ LODAApiClient       # HTTP client for LODA API
โ”œโ”€โ”€ Tool Handlers       # Individual tool implementations  
โ”œโ”€โ”€ Validation Layer    # Input validation and sanitization
โ””โ”€โ”€ Error Management    # Comprehensive error handling

Error Handling Strategy

  • Input Validation: Strict parameter checking with clear error messages
  • Network Resilience: Retry logic and connection error handling
  • API Error Translation: Convert HTTP errors to meaningful user messages
  • Graceful Degradation: Partial results when possible

๐Ÿ” Troubleshooting

Common Issues

Issue Solution
Server won't start Check Node.js version (18+), verify build completed
API connection failed Test with npm run test-connection, check firewall
Tool not found Verify tool name spelling, check MCP client connection
Invalid parameters Check parameter types match schema exactly
Mining timeout Use shorter max_runtime, check sequence exists

Debug Mode

# Enable verbose logging
DEBUG=* npm start

# Test specific tool
echo '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"get_stats","arguments":{}},"id":1}' | npm start

Health Checks

# Test API connectivity
npm run test-connection

# Verify tool listing  
echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | npm start

๐Ÿค Contributing

Development Setup

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make changes with proper TypeScript types
  4. Test thoroughly: npm run type-check
  5. Submit a pull request

Code Standards

  • TypeScript: Strict mode with full type coverage
  • Error Handling: Always use McpError for user-facing errors
  • Validation: Validate all inputs before API calls
  • Documentation: Clear JSDoc comments for public methods
  • Formatting: Consistent emoji usage and output structure

๐Ÿ”— Resources

๐Ÿ“„ API Endpoints

Based on the official OpenAPI v2 specification:

Endpoint Method Description
/sequences/{id} GET Get integer sequence details
/sequences/search GET Search integer sequences
/programs/{id} GET Get LODA program details
/programs/search GET Search LODA programs
/programs/eval POST Evaluate a LODA program
/programs/{id}/submit POST Submit a new LODA program
/stats/summary GET Get statistics summary
/stats/submitters GET List all submitters

๐Ÿ“ License

Apache 2.0

๐Ÿ™ Acknowledgments

  • LODA Project Team - For creating this amazing mathematical tool
  • OEIS Contributors - For maintaining the world's most important sequence database
  • MCP Community - For the excellent protocol and SDK
  • Mathematical Community - For continuous sequence discoveries and research

Made with โค๏ธ for mathematical discovery and algorithmic research

MCP Server ยท Populars

MCP Server ยท New

    D4Vinci

    Sponsors

    ๐Ÿ•ท๏ธ An undetectable, powerful, flexible, high-performance Python library to make Web Scraping Easy and Effortless as it should be!

    Community D4Vinci
    FarhanAliRaza

    claude-context-local

    Code search MCP for Claude Code. Make entire codebase the context for any coding agent. Embeddings are created and stored locally. No API cost.

    Community FarhanAliRaza
    awslabs

    AWS Knowledge MCP Server

    AWS MCP Servers โ€” helping you get the most out of AWS, wherever you use MCP.

    Community awslabs
    cert-manager

    cert-manager

    Automatically provision and manage TLS certificates in Kubernetes

    Community cert-manager
    nesquikm

    ๐Ÿฆ† MCP Rubber Duck

    An MCP server that acts as a bridge to query multiple OpenAI-compatible LLMs with MCP tool access. Just like rubber duck debugging, explain your problems to various AI "ducks" who can actually research and get different perspectives!

    Community nesquikm