Factorio AI Companion
Bidirectional chat bridge between Factorio and Claude Code via MCP protocol, enabling players to send /companion commands and receive AI responses.
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:
- In Factorio main menu, press Ctrl+Alt and click Settings
- Go to "The rest" tab
- Set
local-rcon-socketto127.0.0.1:34198 - Set
local-rcon-passwordtofactorio
4. Start Factorio Multiplayer
Important: RCON only works in multiplayer mode (even if playing solo).
- Launch Factorio
- Multiplayer → Host New Game (or Load Game)
- Select your save and click Play
- 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 --versionto 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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。