Skip to main content

A lightning-fast, hybrid-search Vector Database and Model Context Protocol (MCP) server for Factorio modding.

Project description

Factorio AI Tools Icon
PyPI - Version GitHub Release

Factorio AI Tools (MCP Server)

A lightning-fast, hybrid-search Vector Database and Model Context Protocol (MCP) server designed to give LLMs absolute expertise over Factorio modding and Clusterio plugin development.

Architecture

This project consists of 4 main components:

  1. Factorio Docs Ingestion (ingest_factorio.py): Scrapes the official Lua API documentation and Data Phase Prototypes across multiple versions (e.g. 1.1.110 and latest).
  2. Clusterio Codebase Ingestion (ingest_clusterio.py): Uses AST (Abstract Syntax Tree) parsing to semantically chunk the massive Node.js/TypeScript Clusterio plugin architecture.
  3. Factorio Wiki Ingestion (ingest_wiki.py): Scrapes the official Factorio Wiki via the MediaWiki API, exclusively extracting English wikitext for gameplay mechanics, ratios, and formulas.
  4. GitHub Mod Ingestion (ingest_github_mod.py): A generalized pipeline that clones, AST-parses (via tree-sitter-lua), and incrementally hashes any GitHub Mod codebase (e.g., Maraxsis) into a semantic mod_lancedb index.
  5. FastMCP Server (server.py): The bridge that connects the underlying LanceDB vector databases to an LLM via the standard Model Context Protocol.

Setup & Usage

There are two primary ways to install and use this MCP server locally with Claude Desktop (or any other MCP client):

Method 1: Using uvx (Recommended)

If you have uv installed, this is the cleanest way to run the server. It will automatically download the package from PyPI and fetch the necessary vector databases on the first run. Add the following to your Claude Desktop config (%APPDATA%\Claude\claude_desktop_config.json or ~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "factorio-ai-tools": {
      "command": "uvx",
      "args": ["factorio-ai-tools"]
    }
  }
}

Method 2: Docker (Pre-packaged Datasets)

If you have Docker Desktop installed, you can simply pull the pre-packaged container natively. The Docker container includes the databases inside the image, so no additional downloads are required at runtime.

{
  "mcpServers": {
    "factorio-ai-tools": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "ghcr.io/solarcloud7/factorio-ai-tools:latest"]
    }
    }
  }
}

Method 3: Global SSE Server (Save RAM/VRAM)

By default, standard stdio MCP execution spawns a completely separate Python process for every single client connection. Because this server uses PyTorch and sentence-transformers, every connection will load the embedding model again, consuming roughly ~500MB of RAM/VRAM per instance.

If you want to use the MCP server across multiple IDEs or workspaces simultaneously without duplicating memory, you can run a single global HTTP SSE server in the background:

uv run factorio-ai-tools --sse --port 8000

Then, configure your IDE or Claude client to connect to the SSE endpoint (e.g., http://localhost:8000/sse) instead of executing the CLI via stdio.

Selective Tool Loading (Optional)

By default, the server loads all available tools. If you only want to expose specific tools to your LLM, you can use the --enable-tools or --disable-tools arguments. For example, to only load the doc search and the blueprint decoder using uvx:

      "command": "uvx",
      "args": [
        "factorio-ai-tools",
        "--enable-tools", "search_factorio_docs,decode_factorio_blueprint"
      ]

Manual Developer Setup

If you wish to run the python scripts manually or ingest custom codebases:

  1. Create a python virtual environment: python -m venv venv and activate it.
  2. Run pip install -r requirements.txt.
  3. (Optional) Run the ingestion scripts (python -m factorio_ai_tools.ingest.ingest_factorio, etc.) to rebuild the LanceDB tables.
  4. (Optional) Ingest a specific GitHub Mod:
    python -m factorio_ai_tools.ingest.ingest_github_mod --repo-url https://github.com/notnotmelon/maraxsis
    

Maintenance (Database Hygiene)

LanceDB is append-only: every ingest run adds new immutable versions and small data fragments, and nothing is garbage-collected automatically. Re-running an ingest script grows the on-disk history (e.g. factorio_lancedb had 155 versions / 469 files before its first compaction). To keep the committed stores lean:

python maintenance/compact_lancedb.py          # compact + prune every data/*_lancedb store
python maintenance/compact_lancedb.py --check   # read-only; exits non-zero if a store is uncompacted

This runs LanceDB's Table.optimize() on each store — compacting fragments, pruning old versions, and folding new rows into existing indices. Do not run it while the server or an ingest script is writing.

Recommended workflow: let the version history accumulate on feature branches so a PR diff shows exactly what data changed, then run the compaction script before merging to main so the committed history stays collapsed.

To enforce that automatically, opt into the bundled pre-push guard (it blocks pushes to main while any store is uncompacted):

git config core.hooksPath maintenance/hooks
# or copy maintenance/hooks/pre-push into .git/hooks/

Tools Included

  • search_factorio_docs: Look up Lua Runtime API methods, concepts, events, and Data Phase prototypes. Supports version filtering (1.1.110 vs latest).

  • search_clusterio_code: Semantically search the Clusterio Node.js architecture.

  • search_factorio_wiki: Access game mechanics, ratios, and fluid mechanics straight from the Wiki.

  • search_mod_code: Semantically search through specific downloaded GitHub mods (e.g., maraxsis) to read their Lua codebase.

  • decode_factorio_blueprint: Convert Factorio blueprint strings (e.g. 0eNq...) into easily readable/editable JSON.

  • encode_factorio_blueprint: Compress generated JSON back into an importable Factorio blueprint string.

  • factorio_mod_portal_analyzer: Scrape and summarize the Factorio Mod Portal for any given mod to retrieve dependencies and release versions.

  • get_mcp_version_info: Self-diagnostics tool to verify the currently loaded database versions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

factorio_ai_tools-1.1.1.tar.gz (4.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

factorio_ai_tools-1.1.1-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file factorio_ai_tools-1.1.1.tar.gz.

File metadata

  • Download URL: factorio_ai_tools-1.1.1.tar.gz
  • Upload date:
  • Size: 4.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for factorio_ai_tools-1.1.1.tar.gz
Algorithm Hash digest
SHA256 9608e34ea0bd8d8054fd798c53902ba859c6000c73e2b8004c726cdcc774666c
MD5 731364caa4069a811e009326a5f50063
BLAKE2b-256 c12481e0f14b10229e5bfceac156d2544e99bb618636a000f69627d846498504

See more details on using hashes here.

Provenance

The following attestation bundles were made for factorio_ai_tools-1.1.1.tar.gz:

Publisher: pypi-publish.yml on solarcloud7/factorio-ai-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file factorio_ai_tools-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for factorio_ai_tools-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5926f57e2be26f356a7781e77370dfa07c94b25a9b2ae54900a8c4e59afe0716
MD5 e4c331e95cbfbede34cf6b4dc823a170
BLAKE2b-256 cf126bddc5949247ee37d26277012b2a5cf17ad0849254dd878c5714fa53bb20

See more details on using hashes here.

Provenance

The following attestation bundles were made for factorio_ai_tools-1.1.1-py3-none-any.whl:

Publisher: pypi-publish.yml on solarcloud7/factorio-ai-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page