Skip to main content
Glama

Logic Lab

Python translations of creative coding examples using py5. Each simulation is organized by domain, demonstrating core computational creativity concepts: physics, steering behaviors, genetic algorithms, neural networks, fractals, cellular automata, tiling patterns, and mathematical systems.

MCP Server

Logic Lab is available as an MCP server for AI agents. Agents can search the Logic Lab manifest, find algorithms by visual intent or category, read short summaries, and fetch bounded source snippets for selected examples.

Glama MCP Server

Option 1: Quick Start

If you just want to use the MCP server directly via Glama or your AI agent without cloning the repository, you can run it remotely using uvx.

Add the following to your AI tool's MCP

configuration:

{
  "mcpServers": {
    "logic-lab": {
      "command": "uvx",
      "args": [
        "--from",
        "logic-lab",
        "logic-lab-mcp"
      ]
    }
  }
}

Option 2: Manual Installation (For local development)

Requires uv. Clone this repository locally if you want to modify the algorithms or run the server from your local source.

git clone https://github.com/asamiile/logic-lab.git
cd logic-lab
uv sync

Registration (Local)

After manual installation, register the local server with your AI tool using the logic-lab-mcp command:

Claude Code:

claude mcp add logic-lab -- logic-lab-mcp

Codex:

codex mcp add logic-lab -- logic-lab-mcp

GitHub Copilot in VS Code (.vscode/mcp.json or user MCP settings):

{
  "servers": {
    "logic-lab": {
      "type": "stdio",
      "command": "logic-lab-mcp"
    }
  }
}

Cursor (.cursor/mcp.json or ~/.cursor/mcp.json):

{
  "mcpServers": {
    "logic-lab": {
      "type": "stdio",
      "command": "logic-lab-mcp"
    }
  }
}

Available Tools

303 algorithms across 11 domains are accessible via 6 MCP tools:

Tool

Description

search_algorithms(query, category, limit)

Free-text search across titles, concepts, and visual descriptions. Start here.

search_by_mood(mood, style, limit)

Find algorithms by aesthetic mood: ethereal, chaotic, geometric, organic, cosmic, minimal, and 6 more.

recommend_combinations(intent, count)

Returns layered multi-algorithm recipes for a given artistic intent.

get_algorithm_summary(path)

Returns manifest metadata and README excerpt for a path. Check relevance before fetching source.

get_algorithm(path, max_chars)

Returns source code for a specific algorithm file. Read-only, size-limited.

get_manifest()

Returns the full manifest JSON. Use when you need to enumerate all entries or categories.

Recommended workflow: search_algorithms → get_algorithm_summary → get_algorithm

See src/logic_lab/mcp/README.md for full parameter reference, security notes, and resource endpoints.

Agent Conversation Example

User: I want to create flowing smoke with invisible force fields.

Agent: Running search_algorithms("flowing smoke invisible force fields")...

  • steering_behaviors/flow_field.py — particles following a fluid vector field

  • physics/fluid_simulation.py — grid-based fluid dynamics

Checking details with get_algorithm_summary("steering_behaviors/flow_field.py")... complexity: medium, concepts: [flow field, Perlin noise, autonomous agents]

Fetching source with get_algorithm("steering_behaviors/flow_field.py") to use as reference for implementation.

Algorithm Domains

  • mathematical/ - Generative geometry, color harmony, noise functions, fractals

  • physics/ - Particle systems, forces, spring physics, fluid dynamics, collision

  • steering_behaviors/ - Autonomous agents, flocking, pathfinding, flow fields

  • genetic_algorithms/ - Evolution, selection, crossover, mutation

  • neuro_evolution/ - Neural networks evolved via genetic algorithms

  • fractals/ - Recursive structures, space-filling curves, Mandelbrot sets

  • cellular_automata/ - Rule-based systems, Game of Life, emergence

  • tiling_patterns/ - Symmetry, tessellations, ornamental patterns

  • research/ - Experimental systems combining multiple domains

  • simulation/ - Prototype implementations and archived experiments

  • shader/ - GLSL fragment shaders for TouchDesigner and UE5

Example: Autonomous Artwork Generation

py5-media-art — a project that uses the Logic Lab MCP server with Claude Code to autonomously generate py5 sketches. Claude searches Logic Lab for relevant algorithms, adapts them into new compositions, and optionally writes accompanying articles.

Related MCP server: genart-mcp

Examples of generative art created with Logic Lab algorithms:

Watch on YouTube

Development

To contribute new algorithms or fixes, see CONTRIBUTING.md for detailed guidelines on:

  • Development setup with uv

  • Algorithm addition workflow

  • py5 code patterns and templates

  • Testing requirements

  • Conventional Commits specification

  • Automated release process

Setup

Install dependencies:

uv sync

Running Tests

# Install dev dependencies
uv sync --group dev

# Run all tests
uv run pytest tests/

# Run with coverage
uv run pytest tests/ --cov=src/logic_lab

Code Quality

# Lint with ruff
uv run ruff check src/ tests/

# Format with black
uv run black src/ tests/

# Lint and fix
uv run ruff check --fix src/ tests/

Repository Structure

logic-lab/
├── src/logic_lab/                 # Package root
│   ├── __init__.py
│   ├── mcp/                       # MCP server for AI agent access
│   ├── physics/                   # Motion, forces, particles, simulations
│   ├── steering_behaviors/        # Autonomous agents, flow fields, flocking
│   ├── genetic_algorithms/        # Selection, mutation, evolutionary search
│   ├── neuro_evolution/           # Neural networks evolved via genetics
│   ├── fractals/                  # Recursion, trees, Koch curves, L-systems
│   ├── cellular_automata/         # Rule-based grids, lattice systems
│   ├── mathematical/              # Noise, curves, geometry, harmony
│   ├── tiling_patterns/           # Symmetry, tessellation, ornaments
│   ├── research/                  # Experimental and hybrid systems
│   ├── simulation/                # Prototypes and reference implementations
│   ├── shared/                    # Reusable utilities and helpers
│   └── shader/                    # GLSL shader experiments
├── tests/                         # Pytest test suite
├── CONTRIBUTING.md                # Contributor guidelines and conventions
├── CHANGELOG.md                   # Version history and release notes
├── pyproject.toml                 # Package configuration and dependencies
└── .github/workflows/
    ├── test.yml                   # CI: lint and test automation
    └── release.yml                # CD: automated releases with release-please

Reference

License

License: MIT

Author

Asami.K

If you find this helpful, consider supporting the work:

BuyMeACoffee

Available Tools

6 tools
get_algorithmA

Return the source text of a Logic Lab .py file or README.md.

This tool is read-only: it reads only .py files and README.md files within
the repository boundary. File creation, editing, deletion, and shell execution
are not available through this server.

Returns a dict with:
- path (str): normalized manifest-relative path
- content (str): file text, possibly truncated
- truncated (bool): true when the file exceeded max_chars
- notice (str | null): truncation message with the current limit and maximum,
  or null when content was not truncated

Raises AccessError when the path escapes the repository root, points to a
non-existent file, or refers to a disallowed file type (not .py or README.md).

Call get_algorithm_summary first to confirm relevance before fetching full
source. Call search_algorithms or get_manifest to discover valid paths.

Inputs: path (required), max_chars. Returns: object

get_algorithm_summaryA

Return a short summary of a Logic Lab algorithm without fetching full source.

For paths in the manifest, returns all metadata fields:
- path, title, category, concepts, visual_use, good_for, complexity, dependencies
- readme_excerpt: first ~6 non-empty lines of the nearest README.md (up to 1200
  chars) when a README.md exists in the same directory

For paths not in the manifest, returns a minimal summary derived from the file
path (title inferred from directory name, category from the first path segment)
plus readme_excerpt when available.

This tool never returns source code — call get_algorithm for that. Use this
tool to assess relevance before committing to a full source fetch. It is
cheaper in context than get_algorithm for files you may not end up using.

Inputs: path (required). Returns: object

get_manifestA

Return the full Logic Lab art algorithm manifest as a JSON object.

The manifest contains an 'entries' array. Each entry includes:
- path (str): manifest-relative path to the source file (e.g. 'physics/wave/wave.py')
- title (str): human-readable algorithm name
- category (str): domain (physics, steering_behaviors, genetic_algorithms,
  neuro_evolution, fractals, cellular_automata, mathematical, tiling_patterns,
  research, simulation, shader)
- concepts (list[str]): key algorithmic concepts demonstrated
- visual_use (str): one-line description of the visual output
- good_for (list[str]): suggested use-cases and aesthetic tags
- complexity (str): 'low', 'medium', or 'high'
- dependencies (list[str]): required Python packages beyond py5

This tool is read-only and returns cached data for the current session.
Prefer search_algorithms for filtered discovery. Use get_manifest when you
need the full entry list or want to enumerate all available categories.

Inputs: no named parameters. Returns: object

recommend_combinationsA

Suggest multi-layer algorithm combinations for a given artistic intent.

Returns a dict with:
- intent (str): the original intent string
- combinations (list): ranked list of layered recipes
- tip (str): guidance for following up on returned paths

Each combination includes:
- name (str): recipe name
- description (str): recipe description
- moods (list[str]): associated creative moods
- layers (list): each layer has role (str), query (str), and suggestions
  (list of manifest entries resolved by search_algorithms)

Layer roles describe compositional function (e.g. background, agents, texture,
overlay). Suggestions are live manifest entries — use get_algorithm_summary or
get_algorithm on any suggested path for full details.

Use this tool to plan layered generative artworks from a text description.
It combines curated recipes with dynamic algorithm lookup per layer.

Inputs: intent (required), count. Returns: object

search_algorithmsA

Search the Logic Lab manifest for algorithms by keyword, category, or visual intent.

Returns a list of manifest entries sorted by relevance score. Each entry includes
path, title, category, concepts, visual_use, good_for, complexity, and dependencies.
Returns an empty list when no entries match — this is not an error.

This tool returns manifest metadata only; it never reads source files.
Synonym expansion is applied automatically so queries like 'flow' also match
'fluid' and 'stream'. Combining query with category narrows results to a
specific domain.

Recommended workflow: call this tool for discovery, then get_algorithm_summary
for short context on candidates, then get_algorithm only for paths you intend
to use.

Inputs: query (required), limit, category. Returns: result

search_by_moodA

Search algorithms by creative mood or visual atmosphere.

Returns a dict with:
- mood (str): the normalized mood used for the query
- style (str | null): the style refinement if provided
- profile_summary (dict): the mood's associated categories and key concepts
- results (list): ranked manifest entries matching the mood

Each mood maps to a curated set of algorithm categories, concepts, and good_for
tags. The style parameter re-ranks results by matching its tokens against all
metadata fields. When the mood is unrecognized, returns an error dict containing
'error', 'available_moods', and a 'tip'.

Prefer search_algorithms for free-text queries without a clear aesthetic direction.
Use this tool when you have a specific visual mood in mind (e.g. 'cosmic',
'minimal', 'chaotic').

Available moods: ethereal, chaotic, geometric, organic, cosmic, minimal,
generative, retro, crystalline, topological, networked, geological.

Inputs: mood (required), limit, style. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.8/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool has a distinct, well-defined purpose: get_algorithm retrieves source code, get_algorithm_summary returns metadata without source, get_manifest returns the full manifest, search_algorithms searches by keyword, search_by_mood searches by mood, and recommend_combinations suggests combinations. No overlap in functionality.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern in snake_case (e.g., get_algorithm, search_algorithms, recommend_combinations). No mixed conventions or ambiguous names.

    Tool Count5/5

    With 6 tools, the server is well-scoped for a domain of algorithm discovery and retrieval. Neither too few nor too many; each tool earns its place.

    Completeness5/5

    The tool set covers the full lifecycle of algorithm exploration: discovery (search_algorithms, search_by_mood, get_manifest), summary (get_algorithm_summary), full source retrieval (get_algorithm), and even creative combination planning (recommend_combinations). No obvious gaps for a read-only lookup server.

    Maintenance

    ActivityStale
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers