Factorio AI Companion

Factorio AI Companion

Bidirectional chat bridge between Factorio and Claude Code via MCP protocol, enabling players to send /companion commands and receive AI responses.

Category
Visit Server

README

Factorio AI Companion

Bidirectional chat bridge between Factorio and Claude Code via MCP protocol.

Status: ✅ Phase 1 Complete - Chat Bridge Working!

Bidirectional chat working between Factorio and Claude Code via RCON.

Quick Start Guide

1. Install Dependencies

bun install

2. Install Factorio Mod

Windows:

xcopy /E /I factorio-mod "%APPDATA%\Factorio\mods\ai-companion"

Linux/Mac: See factorio-mod/README.md

3. Configure RCON in Factorio

Edit %APPDATA%\Factorio\config\config.ini and add these lines (if not already present):

local-rcon-socket=127.0.0.1:34198
local-rcon-password=factorio

Or use the hidden settings GUI:

  1. In Factorio main menu, press Ctrl+Alt and click Settings
  2. Go to "The rest" tab
  3. Set local-rcon-socket to 127.0.0.1:34198
  4. Set local-rcon-password to factorio

4. Start Factorio Multiplayer

Important: RCON only works in multiplayer mode (even if playing solo).

  1. Launch Factorio
  2. Multiplayer → Host New Game (or Load Game)
  3. Select your save and click Play
  4. RCON will be automatically enabled

5. Test RCON Connection (Optional)

bun run src/rcon/test-connection.ts

Expected output:

✅ RCON connected on attempt 1
✅ Connection successful!
✅ RCON is working!

6. Start MCP Server

bun run src/index.ts

Expected output:

🚀 Starting Factorio MCP Server...
✅ RCON connected on attempt 1
📡 RCON connected to Factorio
✅ MCP server running on stdio

💡 Server is ready! Claude Code can now use:
   - get_companion_messages
   - send_companion_message

7. Connect Claude Code

The .mcp.json file in this project root configures Claude Code to use this server.

Claude Code will automatically start the MCP server when needed.

8. Test It!

In Factorio chat:

/companion Hello Claude! Can you help me?

In Claude Code:

Use the get_companion_messages tool

Claude will see:

[
  {
    "player": "YourName",
    "message": "Hello Claude! Can you help me?",
    "tick": 12345
  }
]

Claude can respond:

Use send_companion_message with "Hello! I'm here to help!"

In Factorio, you'll see:

[AI Companion] Hello! I'm here to help!

Tools Available

get_companion_messages

Get unread messages from Factorio chat starting with /companion.

Returns: Array of {player, message, tick}

send_companion_message

Send a message to Factorio chat as AI Companion.

Input: { message: string }

Architecture

Factorio (Lua mod captures /companion chat)
    ↕ RCON (TCP port 27000)
Node.js MCP Server (Bun)
    ↕ MCP Protocol (stdio)
Claude Code (You!)

What's Built

  • ✅ RCON client with retry logic
  • ✅ Chat message parser
  • ✅ Factorio Lua mod with FLE patterns
  • ✅ MCP server with 2 tools
  • ✅ Claude Code integration via .mcp.json

Phase 2 (Future)

  • AI-controlled character
  • Game state introspection
  • Automated building/crafting
  • Multi-agent coordination

Troubleshooting

"Connection failed"

  • Make sure Factorio is running
  • Check "Start as server" is enabled
  • Verify RCON port is 27000
  • Verify RCON password is "factorio"

"No messages"

  • Type /companion <message> in Factorio chat (not just "companion")
  • Check mod is enabled in Factorio → Mods menu
  • Restart Factorio after installing mod

"Command not found"

  • Make sure Bun is installed: https://bun.sh
  • Run bun --version to verify

Development

# Run tests
bun test

# Test RCON connection
bun run src/rcon/test-connection.ts

# Start MCP server
bun run src/index.ts

Credits

Inspired by Factorio Learning Environment patterns and best practices.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured