factorio-mcp

module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2026 License: MIT

README

factorio-mcp

CI Quality Gate Status codecov Go 1.26 MIT License

A Claude Code plugin that lets Claude play Factorio 2.0 (base game, no Space Age) and work toward launching a rocket — under the real game economy.

Inspired by "Factorio plays itself" Lua-scripting demos like this one, but instead of a fixed scripted strategy the brain is an LLM: Claude perceives live game state, reasons about it, acts, and recovers from the unexpected.

How it works

Claude Code ──stdio──> Go MCP server ──RCON/TCP──> Factorio + companion mod
  • Go MCP server (cmd/factorio-mcp) exposes typed factorio_* tools and talks to the game over RCON, one /silent-command per call.
  • Companion mod (mod/factorio_mcp) registers a factorio_mcp remote interface with a clean named API (plus a guarded eval escape hatch) and returns state as JSON.
  • Skills (skills/) encode the strategy: orientation, early bootstrap, smelting, red/green/blue science, research progression, mall builds, rocket.

The economy is legit: placing a building consumes a crafted item; crafting and research take real time and ingredients. Only navigation is a concession (factorio_teleport, since real-time pathfinding is out of scope).

Tools

Introspection: get_player_state, get_inventory, scan_entities, scan_resources, get_research_state, get_tech_tree, get_production_stats, get_recipe_info.

Actions: place_entity, remove_entity, set_recipe, insert_items, remove_items, craft, set_research, queue_research, teleport, mine_resource. Optional cheat/debug: eval (off by default).

All are exposed as MCP tools prefixed factorio_.

Install

Homebrew
brew install danielriddell21/tap/factorio-mcp

Quickstart

See docs/QUICKSTART.md — install the mod, enable RCON, host a game, then:

just build
export FACTORIO_RCON_PASSWORD=changeme
./bin/factorio-mcp

Configuration

Env var Default Meaning
FACTORIO_RCON_HOST 127.0.0.1 RCON host
FACTORIO_RCON_PORT 27015 RCON port
FACTORIO_RCON_PASSWORD (required) RCON password
FACTORIO_MCP_ALLOW_EVAL (unset) set to enable the eval cheat tool

Development

just test     # unit + integration tests (no game required)
just fuzz     # fuzz the Lua escaping
just vet      # go vet
just fmt      # gofmt -s -w
just mod-zip  # package the mod
just ci       # fmt-check + vet + test

Requires Go 1.26+. The Factorio side can't run in CI; verify it with the quickstart smoke test.

Directories

Path Synopsis
cmd
factorio-mcp command
Command factorio-mcp is an MCP server that lets Claude play Factorio by reading game state and issuing high-level actions over RCON, routed through the factorio_mcp companion mod.
Command factorio-mcp is an MCP server that lets Claude play Factorio by reading game state and issuing high-level actions over RCON, routed through the factorio_mcp companion mod.
internal
config
Package config resolves runtime configuration for the Factorio MCP server from environment variables, with optional flag overrides handled by callers.
Package config resolves runtime configuration for the Factorio MCP server from environment variables, with optional flag overrides handled by callers.
factorio
Package factorio turns typed calls into one-line RCON commands routed through the factorio_mcp companion mod, and decodes the mod's JSON envelope back into Go values.
Package factorio turns typed calls into one-line RCON commands routed through the factorio_mcp companion mod, and decodes the mod's JSON envelope back into Go values.
rcon
Package rcon provides a Factorio-aware wrapper around a Source RCON connection.
Package rcon provides a Factorio-aware wrapper around a Source RCON connection.
tools
Package tools registers the MCP tool surface that Claude uses to perceive and act on a running Factorio game.
Package tools registers the MCP tool surface that Claude uses to perceive and act on a running Factorio game.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL