# FactoMCP

> Basic MCP server to control a Factorio Player via RCON

- **Type:** MCP server
- **Install:** `agentstack add mcp-widami-factomcp`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [WidAmi](https://agentstack.voostack.com/s/widami)
- **Installs:** 0
- **Category:** [Integrations](https://agentstack.voostack.com/c/integrations)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [WidAmi](https://github.com/WidAmi)
- **Source:** https://github.com/WidAmi/FactoMCP

## Install

```sh
agentstack add mcp-widami-factomcp
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# FactoMCP

An MCP server that lets Claude play Factorio. Claude can walk around, mine resources, place buildings, manage research, and build out a factory — all through natural language.

[](LICENSE)

> **Fair warning:** It's slow, makes spatial reasoning mistakes, and burns through tokens fast. But it works, and it's genuinely fun to watch.

## How it works

The server connects to a running Factorio instance via RCON and exposes a set of MCP tools that execute Lua commands in the game. Claude uses these tools to perceive the game state and take actions as the player.

## Requirements

- Factorio (tested on 2.0)
- Python 3.10+
- Claude Code (or any MCP-compatible client)
- The server must run on the **same machine** as Factorio

## Setup

### 1. Configure RCON in Factorio

RCON only works in multiplayer mode. You need to either:

**Option A — start from the command line:**
```
factorio --start-server mysave.zip --rcon-port 25575 --rcon-password CHANGE_ME
```

**Option B — start a local multiplayer game and set RCON in `config.ini`:**
```ini
[rcon]
rcon-port=25575
rcon-password=CHANGE_ME
```

Then start Factorio normally and open a multiplayer (LAN) game.

**Option C — configure via the in-game GUI:**

Factorio supports a number of hidden configuration options that are not normally shown in the GUI. They can be accessed by holding **CTRL + ALT** when clicking the "Settings" button in the pause menu, which will cause a new button labeled "The rest" to appear. The RCON port and password settings are in there.

### 2. Install the server

```bash
git clone https://github.com/WidAmi/FactoMCP.git
cd FactoMCP
python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -r requirements.txt
```

### 3. Configure the MCP connection

The repo includes a `mcp.json.example` you can use as a starting point. Copy it to `.mcp.json` and edit it to match your setup:

```json
{
  "mcpServers": {
    "factomcp": {
      "type": "stdio",
      "command": "/path/to/FactoMCP/.venv/bin/python",
      "args": ["/path/to/FactoMCP/server.py"],
      "env": {
        "RCON_HOST": "127.0.0.1",
        "RCON_PORT": "25575",
        "RCON_PASSWORD": "CHANGE_ME"
      }
    }
  }
}
```

Or set the environment variables manually and run:
```bash
RCON_PASSWORD=CHANGE_ME python server.py
```

### 4. Connect Claude Code

From the FactoMCP directory, start Claude Code:
```bash
claude
```

Claude Code will automatically pick up `.mcp.json`. You can verify the server connected with `/mcp`.

### 5. Start playing

With Factorio running and Claude Code connected, just tell Claude what to do:

```
Take a look around and find the ore patches
Build a basic iron smelting setup near the iron ore
Set up automated coal mining to keep the furnaces running
```

## Environment variables

| Variable | Default | Description |
|----------|---------|-------------|
| `RCON_HOST` | `127.0.0.1` | Factorio RCON host |
| `RCON_PORT` | `25575` | Factorio RCON port |
| `RCON_PASSWORD` | `CHANGE_ME` | Factorio RCON password |
| `FACTORIO_SCRIPT_OUTPUT` | `~/Library/Application Support/factorio/script-output` | Path for screenshot output (Mac default) |

## Available tools

### Navigation & perception
| Tool | Description |
|------|-------------|
| `get_player_position` | Get the player's current coordinates |
| `get_player_inventory` | List everything in the player's inventory |
| `scan_area` | Summarize resources, entities, and structures within a radius |
| `detail_area` | Detailed tile-by-tile breakdown of a smaller area |
| `walk_to` | Walk the player to a position using legitimate movement |

### Mining & building
| Tool | Description |
|------|-------------|
| `mine_resource` | Mine a resource or pick up an entity at a position |
| `build_entity` | Place an entity from inventory |
| `build_line` | Place a line of identical entities (belts, poles, etc.) |
| `rotate_entity` | Change the direction of a placed entity |
| `load_entity` | Put items from inventory into an entity (fuel, ingredients) |
| `collect_from_entity` | Take items out of an entity into inventory |

### Crafting & research
| Tool | Description |
|------|-------------|
| `craft` | Queue a crafting recipe |
| `get_crafting_queue` | See what's currently being crafted |
| `get_recipes` | List unlocked recipes, with optional name filter |
| `get_research_status` | Check current research progress |
| `get_available_technologies` | List technologies that can be researched |
| `set_research` | Start researching a technology |
| `set_recipe` | Set the recipe for an assembling machine |

### Diagnostics
| Tool | Description |
|------|-------------|
| `get_entity_status` | Check an entity's status, fuel, inventory, and health |
| `diagnose_area` | Identify idle or broken entities in an area |
| `check_power_network` | Inspect the power network around a location |
| `check_fluid_connections` | Check fluid connections for pipes and fluid entities |
| `trace_connections` | Trace belt/inserter connections from an entity |
| `trace_fluid_network` | Trace the fluid network from a pipe or entity |

### Misc
| Tool | Description |
|------|-------------|
| `run_lua` | Execute arbitrary Lua in Factorio (use sparingly) |
| `stop` | Stop all player actions if something gets stuck |
| `take_screenshot` | Save a screenshot to Factorio's script-output directory |
| `get_stats` | Report call count and estimated token usage per tool for this session |
| `clear_stats` | Reset all usage statistics |

## A note on fairness

The tools in this server are designed to only do what a normal player could do — walking to locations, mining with the character's reach, placing entities from inventory, crafting recipes, and so on. The goal is to have Claude play the game, not cheat at it.

That said, it may not be perfect. Some actions might inadvertently bypass normal game constraints in ways that aren't immediately obvious. And `run_lua` in particular executes arbitrary code with no restrictions — it can do basically anything. Use it with that in mind.

## Tips

- **Start by scanning:** Ask Claude to `scan_area` with a large radius before doing anything. This gives it the lay of the land.
- **Coal first:** Claude needs coal to fuel burner drills and furnaces. Make sure it sets up a coal supply before building out iron smelting.
- **Watch the token usage:** Long autonomous runs burn context fast. Break big tasks into phases and check in periodically.
- **It makes mistakes:** Expect to correct entity placement, inserter directions, and belt routing. The spatial reasoning isn't perfect.

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [WidAmi](https://github.com/WidAmi)
- **Source:** [WidAmi/FactoMCP](https://github.com/WidAmi/FactoMCP)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-widami-factomcp
- Seller: https://agentstack.voostack.com/s/widami
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
