willibrandon/openttd-mcp
3.2
If you are the rightful owner of openttd-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.
The OpenTTD MCP Server is a Model Context Protocol server designed to enable AI assistants to interact with OpenTTD via the Admin Port.
Tools
27
Resources
0
Prompts
0
OpenTTD MCP Server
Model Context Protocol server for OpenTTD, enabling AI assistants to play OpenTTD via the Admin Port.
Features
- Complete Admin Port Implementation: Full binary protocol support for OpenTTD communication
- 25+ MCP Tools: Comprehensive game control including construction, vehicles, and economics
- Intelligent Analysis: Route finding, profit calculation, and network optimization
- Real-time State Tracking: Synchronized game state with companies, towns, industries, and vehicles
- Financial Management: Budget control, loan management, and financial forecasting
- Automated Operations: Vehicle orders, infrastructure building, and market analysis
Quick Start
Prerequisites
- Go 1.21 or higher
- Docker and Docker Compose
- OpenTTD server with Admin Port enabled
Installation
# Clone the repository
git clone https://github.com/willibrandon/openttd-mcp
cd openttd-mcp
# Install dependencies
go mod download
# Build the MCP server
go build -o bin/openttd-mcp main.go
Running the Server
# Start OpenTTD server with Docker
docker-compose up openttd -d
# Run MCP server
./bin/openttd-mcp
# Or with environment variables
OPENTTD_HOST=localhost OPENTTD_PORT=3977 OPENTTD_ADMIN_PASSWORD=admin123 ./bin/openttd-mcp
Docker Compose (All-in-One)
# Start both OpenTTD and MCP server
docker-compose up
# View logs
docker-compose logs -f
# Stop services
docker-compose down
Configuration
Environment Variables
Variable | Description | Default |
---|---|---|
OPENTTD_HOST | OpenTTD server hostname | localhost |
OPENTTD_PORT | Admin port number | 3977 |
OPENTTD_ADMIN_PASSWORD | Admin password | admin123 |
OPENTTD_RCON_PASSWORD | RCON password | rcon123 |
MCP_LOG_LEVEL | Logging level (debug/info/warn/error) | info |
MCP_AUTO_CONNECT | Auto-connect on startup | false |
Claude Desktop Integration
Add to your Claude Desktop configuration:
{
"mcpServers": {
"openttd": {
"command": "/path/to/openttd-mcp",
"env": {
"OPENTTD_HOST": "localhost",
"OPENTTD_PORT": "3977",
"OPENTTD_ADMIN_PASSWORD": "admin123"
}
}
}
}
Available Tools
Connection Management
connect_to_server
- Connect to OpenTTD serverdisconnect
- Disconnect from serverserver_status
- Get connection status
Information Tools
get_server_info
- Server details and map informationlist_companies
- All companies with statisticslist_towns
- Towns with population datalist_industries
- Industries and productionlist_vehicles
- Vehicle fleet informationget_map_info
- Map size and landscapeexecute_command
- Run console commands
Construction Tools
build_depot
- Build vehicle depotsbuild_station
- Build stationsbuild_road
- Build road segmentsbuild_vehicle
- Purchase vehicles
Vehicle Management
manage_orders
- Set vehicle ordersstart_stop_vehicle
- Control vehicle operationsell_vehicle
- Sell vehicles
Economic Tools
get_finances
- Company financial datacompany_analysis
- Performance analysisset_company_budget
- Budget managementmanage_loan
- Loan operationsfinancial_forecast
- Revenue projections
Advanced Analysis
find_profitable_routes
- Identify high-profit routesanalyze_industry_chains
- Industry connectionscalculate_route_profit
- Route profitabilitynetwork_optimizer
- Network efficiencymarket_analysis
- Competitive analysis
Testing
# Run all tests
go test ./...
# Run integration tests (requires OpenTTD server)
go test -v ./test/integration/...
# Run benchmarks
go test -bench=. ./test/integration/...
# Generate coverage report
go test -cover ./...
License
MIT
Contributing
Contributions are welcome! Please ensure:
- All tests pass (
go test ./...
) - Code follows Go conventions (
go fmt ./...
) - New features include tests
- Documentation is updated