@csmodding/gameface-devtools-mcp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +190 -0
  3. package/dist/server.mjs +31721 -0
  4. package/package.json +51 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Morgan Touverey Quilling
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,190 @@
1
+ # gameface-devtools-mcp
2
+
3
+ An MCP server that drives a running **Coherent Gameface** UI, for any MCP client.
4
+
5
+ [Coherent Gameface](https://coherent-labs.com/products/coherent-gameface/) (Cohtml) is the
6
+ HTML/CSS/JS UI engine many games embed.
7
+ This server connects to its **Chrome DevTools Protocol (CDP)** debug endpoint directly and exposes
8
+ MCP tools to evaluate JavaScript, take screenshots, inspect and drive the DOM, capture the console,
9
+ and set JS breakpoints.
10
+
11
+ > **Generic, but developed against Cities: Skylines II.** The server makes no assumptions about a
12
+ > specific application; it works against any Gameface CDP endpoint. It is developed and verified
13
+ > against Cities: Skylines II's Gameface UI, which is the reference target and the source of the
14
+ > CDP quirks noted below.
15
+
16
+ > **Why direct CDP instead of Puppeteer/Playwright (or chrome-devtools-mcp)?** Gameface does not
17
+ > implement the browser-level handshake those tools rely on (`Browser.getVersion` is missing and
18
+ > `Target.attachedToTarget` is never emitted), so they connect but find zero drivable pages.
19
+ > A direct CDP client only sends the commands Gameface supports, and works end-to-end.
20
+
21
+ ## Requirements
22
+
23
+ - **A Gameface application running** with its CDP debug endpoint reachable (default
24
+ `http://localhost:9444`). Verify with:
25
+ ```sh
26
+ curl http://localhost:9444/json/list
27
+ ```
28
+ You should get back a JSON array containing a `"type": "page"` target. Set the host/port to match
29
+ your application if it differs (see Configuration).
30
+ - **Node.js 22.4+**. The package is a self-contained bundle; `npx` installs nothing else.
31
+
32
+ ## Install
33
+
34
+ The server speaks MCP over stdio. Register it in your client under the name `gameface`, launched
35
+ as `npx -y @csmodding/gameface-devtools-mcp@latest` (`@latest` keeps it fresh on each launch).
36
+
37
+ Most clients accept the canonical `mcpServers` JSON shape:
38
+
39
+ ```json
40
+ {
41
+ "mcpServers": {
42
+ "gameface": {
43
+ "command": "npx",
44
+ "args": ["-y", "@csmodding/gameface-devtools-mcp@latest"],
45
+ "env": {
46
+ "GAMEFACE_HOST": "localhost",
47
+ "GAMEFACE_PORT": "9444"
48
+ }
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+ The `env` block is optional; defaults are shown (see Configuration for all variables).
55
+
56
+ ### Claude Code
57
+
58
+ ```sh
59
+ claude mcp add gameface -- npx -y @csmodding/gameface-devtools-mcp@latest
60
+ ```
61
+
62
+ Add `--scope project` to share it with your team via a committed `.mcp.json`. To pass env vars,
63
+ note that another option must sit between `--env` and the server name:
64
+
65
+ ```sh
66
+ claude mcp add --env GAMEFACE_PORT=9444 --transport stdio gameface -- npx -y @csmodding/gameface-devtools-mcp@latest
67
+ ```
68
+
69
+ Claude Code and Codex CLI users can also install the
70
+ [coherent-gameface plugin](https://github.com/CitiesSkylinesModding/coherent-gameface-agent-plugin)
71
+ instead, which bundles this server (no npm involved) plus skills that teach the agent the Gameface
72
+ workflows.
73
+
74
+ ### Cursor
75
+
76
+ Add the canonical JSON above to `.cursor/mcp.json` in your project, or `~/.cursor/mcp.json`
77
+ globally.
78
+
79
+ ### Codex CLI
80
+
81
+ ```sh
82
+ codex mcp add gameface -- npx -y @csmodding/gameface-devtools-mcp@latest
83
+ ```
84
+
85
+ Or in `~/.codex/config.toml`:
86
+
87
+ ```toml
88
+ [mcp_servers.gameface]
89
+ command = "npx"
90
+ args = ["-y", "@csmodding/gameface-devtools-mcp@latest"]
91
+ ```
92
+
93
+ Codex CLI users can also install the
94
+ [coherent-gameface plugin](https://github.com/CitiesSkylinesModding/coherent-gameface-agent-plugin)
95
+ instead (see the note under Claude Code above).
96
+
97
+ ### Gemini CLI
98
+
99
+ ```sh
100
+ gemini mcp add gameface npx -- -y @csmodding/gameface-devtools-mcp@latest
101
+ ```
102
+
103
+ (The `--` goes after `npx`: it separates dash-prefixed server args from Gemini's own flags.)
104
+ Or add the canonical JSON above to `.gemini/settings.json` (project) or `~/.gemini/settings.json`.
105
+
106
+ ### VS Code / GitHub Copilot
107
+
108
+ ```sh
109
+ code --add-mcp "{\"name\":\"gameface\",\"command\":\"npx\",\"args\":[\"-y\",\"@csmodding/gameface-devtools-mcp@latest\"]}"
110
+ ```
111
+
112
+ Or in `.vscode/mcp.json` (note the `servers` key, not `mcpServers`):
113
+
114
+ ```json
115
+ {
116
+ "servers": {
117
+ "gameface": {
118
+ "type": "stdio",
119
+ "command": "npx",
120
+ "args": ["-y", "@csmodding/gameface-devtools-mcp@latest"]
121
+ }
122
+ }
123
+ }
124
+ ```
125
+
126
+ ## Tools
127
+
128
+ | Tool | What it does | Under the hood |
129
+ | ----------------- | ------------------------------------------------------------------------------- | ----------------------------------- |
130
+ | `game_status` | Reachability + page target + engine info. Run first when things fail. | `/json/list` + `/json/version` |
131
+ | `game_eval` | Evaluate a JS expression in the Gameface UI, returns the value as JSON. | `Runtime.evaluate` (returnByValue) |
132
+ | `game_screenshot` | Screenshot the viewport (or a selector's box) as an inline image. | `Page.captureScreenshot` (+ `clip`) |
133
+ | `game_dom` | DOM details (tag, classes, attributes, rect, outerHTML) for a CSS selector. | `Runtime.evaluate` |
134
+ | `game_wait` | Wait until a selector matches (optionally visible) or a JS predicate is truthy. | polled `Runtime.evaluate` |
135
+ | `game_click` | Click an element by dispatching real bubbling DOM events. | `Runtime.evaluate` (see note) |
136
+ | `game_fill` | Set an input/textarea/contenteditable value. | `Runtime.evaluate` (see note) |
137
+ | `game_type` | Type text key by key (real KeyboardEvents + value sync). | `Runtime.evaluate` (see note) |
138
+ | `game_hover` | Hover an element (over/enter/move sequence) to trigger tooltips/hover state. | `Runtime.evaluate` (see note) |
139
+ | `game_console` | Recent `console.*`, log entries, and uncaught exceptions from the Gameface UI. | `Log` + `Runtime.consoleAPICalled` |
140
+
141
+ > **Input is done via DOM events, not CDP `Input`.** Gameface accepts `Input.dispatchMouseEvent` /
142
+ > `dispatchKeyEvent` but never delivers them to the UI. So `game_click`, `game_fill`, `game_type`,
143
+ > and `game_hover` dispatch real DOM events in the page.
144
+
145
+ ### JS debugger tools
146
+
147
+ The Gameface UI's V8 `Debugger` domain is fully supported, so these drive a real source-level
148
+ debugger.
149
+
150
+ | Tool | What it does |
151
+ | ------------------------------ | ------------------------------------------------------------------------------------------------------------- |
152
+ | `game_debug_status` | Debugger state: paused?/where, pause-on-exceptions, breakpoints, script count. Also sets pause-on-exceptions. |
153
+ | `game_debug_scripts` | List parsed UI scripts (scriptId + url), filterable by url substring. |
154
+ | `game_debug_source` | Get a script's source (by scriptId) with line numbers, optionally a line range. |
155
+ | `game_debug_set_breakpoint` | Break at url-substring + line (1-based), with an optional JS condition. |
156
+ | `game_debug_remove_breakpoint` | Remove a breakpoint by id, or `all`. |
157
+ | `game_debug_pause_state` | When paused: the call stack, optionally with each frame's local/closure variables. |
158
+ | `game_debug_evaluate` | Evaluate in the paused frame's scope (read locals), or globally when running. |
159
+ | `game_debug_step` | `resume` / `over` / `into` / `out` / `pause`. |
160
+
161
+ > **Hitting a breakpoint or pausing FREEZES the UI thread until you resume** (`game_debug_step`
162
+ > with `resume`). Prefer conditional breakpoints to limit freezes, and while paused inspect with
163
+ > `game_debug_evaluate` rather than `game_eval`. Safety net: if the server's connection drops while
164
+ > paused, the engine auto-resumes.
165
+
166
+ ## Configuration
167
+
168
+ All are optional, read by the server from the environment:
169
+
170
+ | Variable | Default | Purpose |
171
+ | ----------------------------- | ----------- | ---------------------------------------- |
172
+ | `GAMEFACE_HOST` | `localhost` | Host of the Gameface CDP endpoint. |
173
+ | `GAMEFACE_PORT` | `9444` | Port of the Gameface CDP endpoint. |
174
+ | `GAMEFACE_CONNECT_TIMEOUT_MS` | `5000` | HTTP discovery / WebSocket open timeout. |
175
+ | `GAMEFACE_CALL_TIMEOUT_MS` | `15000` | Per-command reply timeout. |
176
+
177
+ ## Troubleshooting
178
+
179
+ - **Tools error with "Cannot reach ..."**: the Gameface application is not running or the debug
180
+ port is not reachable. Check `curl http://localhost:9444/json/list`. Use `game_status` for a
181
+ structured diagnosis.
182
+ - **The server fails to launch**: check your client's MCP logs for the server's stderr. Common
183
+ causes: `npx` not on `PATH`, or Node older than 22.4 (the bundle needs the global `WebSocket`).
184
+
185
+ ## Development
186
+
187
+ The server is developed in the
188
+ [coherent-gameface-agent-plugin](https://github.com/CitiesSkylinesModding/coherent-gameface-agent-plugin)
189
+ repository, where this package lives as the `mcp/` workspace. See the repository README for the
190
+ development setup, and its `AGENTS.md` for the verified Gameface CDP behavior matrix.