jerome3o/factorio-mcp
3.3
If you are the rightful owner of factorio-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A Model Context Protocol (MCP) server for managing Factorio servers using Claude.
Factorio MCP Server 🏭
A Model Context Protocol (MCP) server for managing Factorio servers using Claude. This repository contains two main components:
- An HTTP backend that securely wraps RCON commands (backend/server.py)
- An MCP server that provides a high-level interface for Claude (factorio_mcp.py)
Architecture
flowchart LR
Claude --> MCP_API --> HTTP_Backend --> Factorio_Server
Backend Server
The backend server provides a secure HTTP interface to Factorio's RCON, requiring API key authentication. This isolates the RCON password and provides a clean HTTP interface for the MCP server.
Setup
- Install requirements:
pip install fastapi uvicorn python-dotenv mcrcon
- Create a .env file:
RCON_HOST=localhost # Your Factorio server hostname
RCON_PORT=27015 # Your Factorio RCON port
RCON_PASSWORD=xxx # Your Factorio RCON password
API_KEY=xxx # Generate a secure API key (only supports one api key, for your MCP server to use)
- Run the server:
uvicorn backend.server:app --host 0.0.0.0 --port 8000
API Endpoints
GET /
- Health checkPOST /execute_command
- Execute RCON command- Requires
X-API-Key
header - Body:
{"command": "your command"}
- Requires
MCP Server
The MCP server provides a high-level interface for Claude to interact with Factorio, built using FastMCP.
Features
- Execute arbitrary Lua commands with explanations
- Player management (teleport, give items)
- Server monitoring
- Screenshot capabilities
Setup
- Install fastmcp:
pip install fastmcp
- Install the MCP server:
fastmcp install factorio_mcp.py -e API_KEY=your_backend_api_key
Available Tools
execute_command(command: str)
- Execute raw RCON commandsrun_lua(code: str, explanation: str)
- Run Lua code with announcementsget_player_count()
- Check online playerssend_message(message: str)
- Broadcast to all playersgive_items(player: str, item: str, count: int)
- Give items to playersteleport_player(player: str, x: float, y: float)
- Teleport playersget_player_info(player: str)
- Get player detailstake_screenshot(player?: str, resolution?: Dict)
- Take screenshots