LC

lancercomet/cities-skylines-2-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

48 stars 16 forks 质量 83 趋势 15Apache-2.0

城市:天际线2 MCP

概览

给Claude(或任何MCP客户端)在运行中的《城市:天际线II》游戏时:读取城市数据,驾驶摄像机并截图,建造道路和建筑,涂装区域,管理财务和政策,并控制模拟时间。 - (C#):在游戏进程内的 TcpListener 绑定为 127.0.0.1 的最小 HTTP 服务器运行。请求由监听线程排队,并由注册于 SystemUpdatePhase.UIUpdate 的 ECS 系统在模拟主线程上执行(暂停时可运行)。构建过程通过自定义 ToolBaseSystem,使用游戏的原生定义/验证/应用流水线;拆除则通过 Bulldozer 流水线进行——没有绕过游戏验证的实体变异。- (TypeScript):通过 stdio 传输将 MCP 工具调用转换为针对桥接修改的 HTTP 请求。 - Windows + Cities: Skylines II(Steam)- .NET SDK 8.0+(用于构建模组)- Node。

概述(AI 翻译)

英语 |简体中文

让Claude(或任何MCP客户端)完全掌控正在运行的《城市:天际线II》游戏:读取城市数据,驾驶摄像机并截图,建造道路和建筑物,涂装区域,管理财务和政策,并控制模拟时间。

建筑

  • 游戏内模组(C#):在游戏进程内绑定为127.0.0.1的TcpListener上运行一个最小HTTP服务器。请求由监听线程排队,并由注册在SystemUpdatePhase.UIUpdate的ECS系统在模拟主线程上执行(暂停时有效)。构建过程通过游戏原生的定义/验证/应用流水线进行自定义ToolBaseSystem;拆除则通过推土机流水线——没有绕过游戏验证的实体变异。
  • MCP 服务器(TypeScript):通过 stdio 传输将 MCP 工具调用转换为针对桥接修改的 HTTP 请求。

要求

  • Windows + Cities: Skylines II(Steam)
  • .NET SDK 8.0+(用于构建模组)
  • Node.js 18+(用于运行MCP服务器)

构建与安装

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

CS2MCP — An MCP Server for Cities: Skylines II

English | 简体中文

Give Claude (or any MCP client) full control over a running Cities: Skylines II game: read city data, drive the camera and take screenshots, build roads and buildings, paint zones, manage finances and policies, and control simulation time.

Architecture

Claude Code / Claude Desktop (any MCP client)
      │  MCP (stdio)
      ▼
cs2-mcp  (mcp-server/, Node.js process)
      │  HTTP, localhost-only 127.0.0.1:8642
      ▼
CS2MCP bridge mod  (CS2MCP.Bridge/, inside the game process)
      │  all ECS reads/writes run on the simulation main thread
      ▼
Cities: Skylines II
  • In-game mod (C#): runs a minimal HTTP server on a TcpListener bound to 127.0.0.1 inside the game process. Requests are queued by listener threads and executed on the simulation main thread by an ECS system registered at SystemUpdatePhase.UIUpdate (works while paused). Construction goes through a custom ToolBaseSystem using the game’s native definition/validation/apply pipeline; demolition goes through the bulldozer pipeline — no entity mutations that bypass game validation.
  • MCP server (TypeScript): translates MCP tool calls into HTTP requests against the bridge mod, over stdio transport.

Requirements

  • Windows + Cities: Skylines II (Steam)
  • .NET SDK 8.0+ (to build the mod)
  • Node.js 18+ (to run the MCP server)

Build & Install

# 1. Build the in-game mod (auto-deploys to the game's local Mods folder)
dotnet build CS2MCP.Bridge\CS2MCP.Bridge.csproj

# 2. Build the MCP server
cd mcp-server
npm install
npm run build

The mod deploys to %USERPROFILE%\AppData\LocalLow\Colossal Order\Cities Skylines II\Mods\CS2MCP\ and loads automatically on game start — no Paradox Mods publishing required. To disable it temporarily, rename the folder to .CS2MCP.

Game path configuration

Building the mod references assemblies from the game folder. Resolution order (first match wins):

  1. Command line: dotnet build -p:GamePath="X:\...\Cities Skylines II"
  2. CS2_PATH environment variable
  3. CSII_INSTALLATIONPATH environment variable (set by the official modding toolchain)
  4. Auto-probing of common Steam library locations (C:\Program Files (x86)\Steam, Steam / SteamLibrary on common drive letters)

If the game cannot be found the build fails with a clear error. Example:

setx CS2_PATH "D:\Steam\steamapps\common\Cities Skylines II"

Runtime environment variables (.env supported)

The MCP server loads mcp-server/.env via dotenv (see .env.example):

Variable Scope Default Description
CS2_BRIDGE_URL MCP server http://127.0.0.1:8642 Address of the bridge mod
CS2MCP_PORT game process 8642 Bridge listen port (change both together)
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "cs2": { "command": "node", "args": ["<repo-path>\\mcp-server\\dist\\index.js"] } } }