glitchless-mcp 0.8.0 → 0.10.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.
- package/README.md +23 -4
- package/package.json +3 -2
- package/src/context.js +125 -52
- package/src/hosted-tools.js +10 -0
- package/src/http.js +110 -0
- package/src/index.js +20 -16
- package/src/login.js +1 -1
- package/src/tools/analytics.js +41 -19
- package/src/tools/core.js +36 -14
- package/src/tools/dashboard.js +62 -36
- package/src/tools/deck.js +16 -11
- package/src/tools/multiplayer.js +153 -0
- package/src/tools/playtest.js +8 -6
- package/src/tools/workspace.js +15 -18
package/README.md
CHANGED
|
@@ -11,6 +11,10 @@ It's a stdio server. Run it with `npx`, no install needed:
|
|
|
11
11
|
npx -y glitchless-mcp
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
+
Apps that connect to a URL instead of starting a process (claude.ai, ChatGPT, Claude Code's HTTP servers) use
|
|
15
|
+
Glitchless Cloud's hosted copy at `https://api.glitchless.gg/mcp` and sign in with OAuth: see
|
|
16
|
+
[Glitchless by URL](../../docs/remote-mcp.md). It has the same tools, less the ones that act on your own computer.
|
|
17
|
+
|
|
14
18
|
## Sign in to a workspace (Glitchless Cloud)
|
|
15
19
|
|
|
16
20
|
```bash
|
|
@@ -22,10 +26,22 @@ It prints a link and a code; you approve the code in the Glitchless dashboard, a
|
|
|
22
26
|
workspace: `glitchless_list_games` lists them, `glitchless_create_game` makes one and returns its client token, and
|
|
23
27
|
every tool takes `game` (a name or id). The key acts as you, with your role in the workspace, and never deletes data
|
|
24
28
|
or touches billing or people. `npx -y glitchless-mcp whoami` shows where you're signed in, `logout` deletes the saved
|
|
25
|
-
key, and Settings →
|
|
29
|
+
key, and Settings → Keys & access in the dashboard lists and revokes keys. An agent can also sign in from inside a
|
|
26
30
|
chat with the `glitchless_sign_in` tool: it shows the link and code, and the running server switches over once you
|
|
27
31
|
approve.
|
|
28
32
|
|
|
33
|
+
## Serve it over HTTP yourself
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx -y glitchless-mcp serve [--port 3001] [--host 127.0.0.1]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The tools that work from a server (all but sign-in, playtests and the Steam Deck) at `http://127.0.0.1:3001/mcp`, over
|
|
40
|
+
Streamable HTTP, for clients of the 2026-07-28 protocol and older ones alike. It reads with the same settings as the
|
|
41
|
+
stdio server (below), for a self-hosted server or a signed-in workspace. It answers this computer only, and checks
|
|
42
|
+
`Host` and `Origin` so web pages can't reach it; to listen on another address, set `GLITCHLESS_MCP_TOKEN` and have
|
|
43
|
+
clients send it as `Authorization: Bearer`.
|
|
44
|
+
|
|
29
45
|
## Settings
|
|
30
46
|
|
|
31
47
|
| Variable | What |
|
|
@@ -81,9 +97,9 @@ above go in its environment.
|
|
|
81
97
|
| `glitchless_overview` | Headline numbers: sessions, players, crash-free sessions, frame time against the budget, rage quits |
|
|
82
98
|
| `glitchless_performance` | Frame time per level, with draw calls, geometry counts and game gauges |
|
|
83
99
|
| `glitchless_get_error` | One error issue, with its stack and the gameplay before it |
|
|
84
|
-
| `glitchless_player_funnel` | Per level: starts, completions, deaths and their causes, rage quits |
|
|
100
|
+
| `glitchless_player_funnel` | Per level: starts, completions, deaths and their causes, disconnects, rage quits; split by what describes the attempt (tier, party size, class), runs per level, and retention |
|
|
85
101
|
| `glitchless_death_hotspots` | Where players die on a level, clustered in world coordinates |
|
|
86
|
-
| `glitchless_events` | The game's own events (whatever it sends with `track`): counts, attribute breakdowns and funnels |
|
|
102
|
+
| `glitchless_events` | The game's own events (whatever it sends with `track`, and the streams it counts with `count`): counts, attribute breakdowns, rates, distributions and funnels, and the session properties it sets |
|
|
87
103
|
| `glitchless_dashboard` | The game's dashboard: its pages, and one board's panels with their numbers |
|
|
88
104
|
| `glitchless_set_dashboard` | Save the game's pages: boards of panels in its own words, and the built-in views it keeps. Needs a key with the dashboard scope |
|
|
89
105
|
| `glitchless_compare_versions` | Two or more versions side by side, in the game's own stats first, to confirm a fix with real players |
|
|
@@ -92,11 +108,14 @@ above go in its environment.
|
|
|
92
108
|
| `glitchless_store_reviews` | For a game connected to a store (Glitchless Cloud: Steam, Google Play, the App Store): what players wrote there, by store, build or version, sentiment, topic (stutter, lag, fps, freeze, crash), device and, on Steam, Steam Deck, each build with the frame-time p95 and crash-free sessions measured on it |
|
|
93
109
|
| `glitchless_store_vitals` | What Google Play (slow rendering, crash and ANR rates, the slowest devices and GPUs) or the App Store (hang rate, launch time, animation hitches, hang signatures) measured of each version, next to what Glitchless measured, and where the two disagree |
|
|
94
110
|
| `glitchless_revenue` | For a game connected to RevenueCat or to its own Stripe account (Glitchless Cloud; `source` picks one, else both): its real revenue by day and revenue per player measured. RevenueCat's (production purchases only): installs (new customers) and active users, MRR, active subscriptions and trials, and revenue by version where RevenueCat splits it. Stripe's: refunds, disputes, fees and net, new paying customers, revenue by product, and by version and platform for purchases the game tied to a session. All next to the sessions, players and new players Glitchless measured and what the game's own purchase events add up to |
|
|
111
|
+
| `glitchless_match` | A multiplayer game's matches (the worst by lag or disconnects on request), or one match from every side, 30 seconds at a time: each player's ping, frame time and outcome, the server's ticks, and whether the whole lobby lagged at once (the server) or one player did (their connection) |
|
|
112
|
+
| `glitchless_network` | Ping, lag (play over 150 ms), packet loss and disconnects by level, version, platform, kind of connection and region, with the worst matches and the network findings |
|
|
113
|
+
| `glitchless_servers` | A game's dedicated servers in server mode: servers running now and their players, tick time against its budget by players connected, map and version, crashes with the matches they ended, and memory that climbs. Every other tool reads them with service `<game>.server` |
|
|
95
114
|
| `glitchless_playtest` | Autoplay bots play the game and compare with a saved baseline ([glitchless-playtest](https://www.npmjs.com/package/glitchless-playtest); needs Playwright in the game project) |
|
|
96
115
|
| `glitchless_deck_send` | Build the game, send it to the paired Steam Deck, add it to the Deck's library and optionally start it ([glitchless-deck](https://www.npmjs.com/package/glitchless-deck); pair once with `npx glitchless-deck pair`) |
|
|
97
116
|
| `glitchless_deck_measure` | Measure a Unity, Godot or Unreal build on the Steam Deck and compare it with a saved run |
|
|
98
117
|
|
|
99
|
-
The reads take `hours`, `version`, `env` (e.g. `prod`)
|
|
118
|
+
The reads take `hours`, `version`, `env` (e.g. `prod`), `session_type` (`user` for players only, `tester` for people on TestFlight and other test builds, `synthetic` for bots, playtests and store test devices, `all`) and `props`, the session properties the game sets (`{ rank: "diamond" }`, or a list of values). Unless `env` or `session_type` is given, findings read the production sessions of players and say so; the other numbers count every session in the window.
|
|
100
119
|
|
|
101
120
|
To let the agent drive the running game as well (measure frame times, inspect the scene, load a
|
|
102
121
|
level), add the WebMCP server beside this one: `npx -y @jason.today/webmcp@latest --mcp`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glitchless-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"mcpName": "io.github.glitchless-gg/glitchless",
|
|
5
5
|
"description": "Game observability and analytics MCP server for Unity, Godot, Unreal, Three.js, Phaser and GameMaker games. Coding agents (Claude Code, Codex, Cursor and others) read your players' stutters, crashes, custom metrics and ranked findings, build the game's own dashboard, and run playtest bots.",
|
|
6
6
|
"keywords": [
|
|
@@ -64,12 +64,13 @@
|
|
|
64
64
|
"bundle": "esbuild src/index.js --bundle --platform=node --format=esm --target=node20 --external:playwright --outfile=../../plugin/glitchless/mcp/glitchless-mcp.mjs --banner:js=\"import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);\""
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@modelcontextprotocol/
|
|
67
|
+
"@modelcontextprotocol/server": "^2.4.0",
|
|
68
68
|
"zod": "^4.6.7",
|
|
69
69
|
"glitchless-playtest": "^0.2.0",
|
|
70
70
|
"glitchless-deck": "^0.1.0"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
+
"@modelcontextprotocol/client": "^2.4.0",
|
|
73
74
|
"esbuild": "^0.28.2"
|
|
74
75
|
}
|
|
75
76
|
}
|
package/src/context.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
// What every Glitchless MCP tool shares: the
|
|
2
|
-
//
|
|
1
|
+
// What every Glitchless MCP tool shares: the connection to the Glitchless API it reads and writes, the helpers that
|
|
2
|
+
// shape a tool's reply, and the list of tools. Each area's tools live in tools/<area>.js and define themselves on
|
|
3
|
+
// import; createServer() builds a server from them, once for stdio (index.js) or once per HTTP request (http.js).
|
|
3
4
|
|
|
4
5
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
5
6
|
import fs from 'node:fs';
|
|
6
7
|
import os from 'node:os';
|
|
7
8
|
import path from 'node:path';
|
|
8
|
-
import { McpServer } from '@modelcontextprotocol/
|
|
9
|
+
import { McpServer } from '@modelcontextprotocol/server';
|
|
9
10
|
import { z } from 'zod';
|
|
10
11
|
|
|
12
|
+
export const VERSION = '0.10.0';
|
|
13
|
+
|
|
11
14
|
// Where `glitchless-mcp login` keeps its workspace key: { url, token, workspace: { id, name }, scopes }.
|
|
12
15
|
export const CREDENTIALS_FILE = path.join(process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config'), 'glitchless', 'credentials.json');
|
|
13
16
|
export function readCredentials() {
|
|
@@ -18,42 +21,48 @@ export function readCredentials() {
|
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
//
|
|
22
|
-
// (gl_ws_…) every game in its workspace, and then every tool takes `game`.
|
|
24
|
+
// A connection: the Glitchless API an agent reaches and the key it reaches it with. A game key (gl_sk_…) reaches one
|
|
25
|
+
// game; a workspace key (gl_ws_…) every game in its workspace, and then every tool takes `game`. `game` is the one
|
|
26
|
+
// the agent last named; `fetch` is how requests go out (Glitchless Cloud answers its own MCP requests in-process).
|
|
27
|
+
export function connection({ base, apiKey = '', service = '', game = '', fetch = globalThis.fetch, client = '' }) {
|
|
28
|
+
return { base: String(base).replace(/\/$/, ''), apiKey, service, game, fetch, client, games: null };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// On stdio, the one connection: GLITCHLESS_API_KEY wins; without it, a saved sign-in. Over HTTP each request runs
|
|
32
|
+
// with the connection its bearer token gives (createServer's `connection`).
|
|
23
33
|
const saved = process.env.GLITCHLESS_API_KEY ? null : readCredentials();
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
const local = connection({
|
|
35
|
+
base: process.env.GLITCHLESS_URL || saved?.url || 'http://localhost:7777',
|
|
36
|
+
apiKey: process.env.GLITCHLESS_API_KEY || saved?.token || '',
|
|
37
|
+
service: process.env.GLITCHLESS_SERVICE || '',
|
|
38
|
+
game: process.env.GLITCHLESS_GAME || '',
|
|
39
|
+
});
|
|
40
|
+
const connections = new AsyncLocalStorage();
|
|
41
|
+
const conn = () => connections.getStore() ?? local;
|
|
42
|
+
|
|
43
|
+
export const base = () => conn().base;
|
|
44
|
+
export const apiKey = () => conn().apiKey;
|
|
45
|
+
export const defaultService = () => conn().service;
|
|
46
|
+
export const isWorkspace = () => conn().apiKey.startsWith('gl_ws_');
|
|
28
47
|
|
|
29
48
|
// After a sign-in from inside the agent (glitchless_sign_in): the running server switches to the new key.
|
|
30
49
|
export function useCredentials({ url, token }) {
|
|
31
|
-
|
|
32
|
-
API_KEY = token;
|
|
33
|
-
games = null;
|
|
50
|
+
Object.assign(local, { base: String(url).replace(/\/$/, ''), apiKey: token, games: null });
|
|
34
51
|
}
|
|
35
52
|
|
|
36
|
-
export const server = new McpServer(
|
|
37
|
-
{ name: 'glitchless', version: '0.8.0' },
|
|
38
|
-
{
|
|
39
|
-
instructions:
|
|
40
|
-
'Glitchless is observability for games made with Three.js, Phaser, Babylon.js, PlayCanvas, Unity, Godot, Unreal or GameMaker. On Glitchless Cloud, glitchless_sign_in connects you to the person\'s whole workspace (they approve a code in the browser): then glitchless_list_games lists every game, glitchless_create_game makes one and hands back its client token, every tool takes game (by name), and glitchless_share_board makes a read-only link to a board. Start with glitchless_triage to get ranked, evidence-backed findings for a game, then drill in with glitchless_performance, glitchless_get_error, glitchless_death_hotspots or glitchless_session. When players or playtesters send bug reports from inside the game (an F8 form or a button), glitchless_bug_reports lists them with what they wrote, the level and where they stood, and opens one with its screenshot. For metrics the game defines itself (what it sends with track(): plays, purchases, paywall views and so on) and funnels between them, use glitchless_events. For a game connected to a store (Steam, Google Play, the App Store), glitchless_store_reviews reads what players wrote there by build, with the hardware and Steam Deck playtime reviewers show, next to what Glitchless measured on that build, and glitchless_store_vitals what the store itself measured (slow rendering, crashes, ANRs, hangs) next to Glitchless, version by version. For a game connected to RevenueCat or to its own Stripe account, glitchless_revenue reads its real revenue by day, version and country (RevenueCat: production purchases only, by store too, installs and active users; Stripe: refunds, fees, net, new paying customers and revenue by product), next to the sessions, players and new players Glitchless measured and what the game\'s own purchase events add up to. Each game has its own dashboard, a list of pages (boards of panels, and built-in views such as Errors, Sessions and Live Tail): read it with glitchless_dashboard, and after instrumenting a game, design one that fits it with glitchless_set_dashboard. Before changing game code, run glitchless_playtest with save_as "baseline"; after the change, run glitchless_playtest again to compare, and treat a FAIL as unfinished work. After shipping a fix (bump the version passed to Glitchless.init), use glitchless_compare_versions to confirm it with real players. If the game is running in a browser with WebMCP connected, its live tools (glitchless_live_performance, glitchless_measure, glitchless_inspect_scene, and game tools such as zoomies_load_level) let you reproduce and measure issues directly. Unity, Godot, Unreal and GameMaker builds measure themselves when run with --glitchless-measure=SECONDS (-glitchless-measure in Unreal and GameMaker); in the Unreal editor, Unreal MCP with the Glitchless Toolset has a Measure tool.',
|
|
41
|
-
},
|
|
42
|
-
);
|
|
43
|
-
|
|
44
53
|
// The games a workspace key reaches, cached briefly; the game each call names (by name or id), else the one the
|
|
45
|
-
//
|
|
46
|
-
let games = null;
|
|
47
|
-
let currentGame = process.env.GLITCHLESS_GAME || '';
|
|
54
|
+
// connection last used (or GLITCHLESS_GAME), else the only game.
|
|
48
55
|
export async function workspaceGames(fresh = false) {
|
|
49
|
-
|
|
56
|
+
const c = conn();
|
|
57
|
+
if (!fresh && c.games && Date.now() - c.games.at < 30_000) return c.games.list;
|
|
50
58
|
const { games: list } = await agent('GET', '/games');
|
|
51
|
-
games = { at: Date.now(), list };
|
|
59
|
+
c.games = { at: Date.now(), list };
|
|
52
60
|
return list;
|
|
53
61
|
}
|
|
54
62
|
|
|
55
63
|
export async function projectFor(game) {
|
|
56
|
-
const
|
|
64
|
+
const c = conn();
|
|
65
|
+
const want = game || c.game;
|
|
57
66
|
let list = await workspaceGames();
|
|
58
67
|
const find = () => list.find((g) => g.id === want) ?? list.find((g) => g.name.toLowerCase() === String(want).toLowerCase());
|
|
59
68
|
let hit = want ? find() : list.length === 1 ? list[0] : null;
|
|
@@ -62,21 +71,21 @@ export async function projectFor(game) {
|
|
|
62
71
|
hit = find();
|
|
63
72
|
}
|
|
64
73
|
if (!hit) throw new Error(want ? `No game called "${want}" in this workspace. Games: ${list.map((g) => g.name).join(', ') || 'none yet'}.` : `Name the game this is about (game: "<name>"): ${list.map((g) => g.name).join(', ') || 'none yet; glitchless_create_game makes one'}.`);
|
|
65
|
-
|
|
74
|
+
c.game = hit.id;
|
|
66
75
|
return hit.id;
|
|
67
76
|
}
|
|
68
77
|
|
|
69
78
|
async function headers(extra = {}) {
|
|
70
|
-
const client =
|
|
71
|
-
return { 'x-glitchless-client': client, ...(
|
|
79
|
+
const client = conn().client || calls.getStore()?.server?.server.getClientVersion?.()?.name || 'mcp';
|
|
80
|
+
return { 'x-glitchless-client': client, ...(apiKey() ? { 'x-glitchless-api-key': apiKey() } : {}), ...(isWorkspace() ? { 'x-glitchless-project': await projectFor(calls.getStore()?.game) } : {}), ...extra };
|
|
72
81
|
}
|
|
73
82
|
|
|
74
83
|
// A workspace key's own routes (/v1/agent/…, Glitchless Cloud).
|
|
75
84
|
export async function agent(method, p, body) {
|
|
76
85
|
if (!isWorkspace()) throw new Error('This needs a workspace: sign in with glitchless_sign_in (or run `npx -y glitchless-mcp login`) on Glitchless Cloud.');
|
|
77
|
-
const res = await fetch(`${
|
|
86
|
+
const res = await conn().fetch(`${base()}/v1/agent${p}`, {
|
|
78
87
|
method,
|
|
79
|
-
headers: { 'x-glitchless-api-key':
|
|
88
|
+
headers: { 'x-glitchless-api-key': apiKey(), ...(body ? { 'content-type': 'application/json' } : {}) },
|
|
80
89
|
...(body ? { body: JSON.stringify(body) } : {}),
|
|
81
90
|
});
|
|
82
91
|
const data = await res.json().catch(() => ({}));
|
|
@@ -87,7 +96,7 @@ export async function agent(method, p, body) {
|
|
|
87
96
|
export async function query(name, params = {}) {
|
|
88
97
|
const qs = new URLSearchParams();
|
|
89
98
|
for (const [k, v] of Object.entries(params)) if (v != null && v !== '') qs.set(k, String(v));
|
|
90
|
-
const res = await fetch(`${
|
|
99
|
+
const res = await conn().fetch(`${base()}/v1/query/${name}?${qs}`, { headers: await headers() });
|
|
91
100
|
if (!res.ok) throw new Error(`Glitchless API ${name} → HTTP ${res.status}: ${(await res.text()).slice(0, 200)}`);
|
|
92
101
|
const data = await res.json();
|
|
93
102
|
const call = calls.getStore();
|
|
@@ -95,7 +104,8 @@ export async function query(name, params = {}) {
|
|
|
95
104
|
return data;
|
|
96
105
|
}
|
|
97
106
|
|
|
98
|
-
// The tool call being answered: the meta of its last query, for
|
|
107
|
+
// The tool call being answered: the game it names, the server answering it, and the meta of its last query, for
|
|
108
|
+
// windowNote().
|
|
99
109
|
const calls = new AsyncLocalStorage();
|
|
100
110
|
|
|
101
111
|
// How the window was answered, when an agent should know: by day past 31 days, what is estimated, what a
|
|
@@ -112,7 +122,7 @@ function windowNote() {
|
|
|
112
122
|
}
|
|
113
123
|
|
|
114
124
|
export async function write(method, p, body) {
|
|
115
|
-
const res = await fetch(`${
|
|
125
|
+
const res = await conn().fetch(`${base()}${p}`, {
|
|
116
126
|
method,
|
|
117
127
|
headers: await headers({ 'content-type': 'application/json' }),
|
|
118
128
|
...(body ? { body: JSON.stringify(body) } : {}),
|
|
@@ -125,7 +135,7 @@ export async function write(method, p, body) {
|
|
|
125
135
|
|
|
126
136
|
export async function resolveService(service) {
|
|
127
137
|
if (service) return service;
|
|
128
|
-
if (
|
|
138
|
+
if (defaultService()) return defaultService();
|
|
129
139
|
const { services } = await query('services');
|
|
130
140
|
if (!services?.length) throw new Error('No games are reporting to Glitchless yet. Add the SDK and play a level first.');
|
|
131
141
|
return services.sort((a, b) => b.last_seen - a.last_seen)[0].service;
|
|
@@ -151,7 +161,7 @@ export const common = {
|
|
|
151
161
|
.min(0.25)
|
|
152
162
|
.max(9600)
|
|
153
163
|
.optional()
|
|
154
|
-
.describe("Look-back window in hours (default 24)
|
|
164
|
+
.describe("Look-back window in hours (default 24), as far back as the workspace keeps data on Glitchless Cloud (the answer says when it starts later than asked). Past 744 (31 days) answers are by day."),
|
|
155
165
|
version: z.string().optional().describe('Only include sessions from this game version'),
|
|
156
166
|
steam_branch: z.string().optional().describe('Only include sessions that ran this Steam branch ("public", or a beta\'s name); games that use Steamworks send it'),
|
|
157
167
|
env: z.string().optional().describe('Only include sessions from this environment, e.g. "prod" (what the game passes to init; builds a developer runs usually send "dev")'),
|
|
@@ -159,30 +169,93 @@ export const common = {
|
|
|
159
169
|
.enum(['user', 'tester', 'synthetic', 'all'])
|
|
160
170
|
.optional()
|
|
161
171
|
.describe('"user": players only; "tester": people on TestFlight and other test builds only; "synthetic": bots, playtests and store test devices only; "all" or unset: every session. Findings (glitchless_triage, and the overview\'s) read the production sessions of players unless env or session_type is given'),
|
|
172
|
+
props: z
|
|
173
|
+
.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number(), z.boolean()]))]))
|
|
174
|
+
.optional()
|
|
175
|
+
.describe('Only sessions with these session properties (what the game set with setProperties): { rank: "diamond" }, or a list of values for any of them, { rank: ["diamond", "master"] }; "(none)" keeps the sessions without one. glitchless_events lists the properties and their values. Read from the sessions, so over 31 days or less'),
|
|
162
176
|
};
|
|
163
177
|
|
|
164
|
-
// The filters every read passes on to the Glitchless API.
|
|
165
|
-
export function filters({ version, steam_branch, env, session_type } = {}) {
|
|
166
|
-
|
|
178
|
+
// The filters every read passes on to the Glitchless API: a session property becomes prop.<key>=<value>[,<value>…].
|
|
179
|
+
export function filters({ version, steam_branch, env, session_type, props } = {}) {
|
|
180
|
+
const out = { version, steam_branch, env, type: session_type };
|
|
181
|
+
for (const [key, value] of Object.entries(props || {})) out[`prop.${key}`] = (Array.isArray(value) ? value : [value]).map(String).join(',');
|
|
182
|
+
return out;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// ── the tools ─────────────────────────────────────────────────────
|
|
186
|
+
// Every tool as its file defined it: { name, config, handler, scope, local }. Over HTTP a tool shows only to a
|
|
187
|
+
// connection whose scopes include its `scope` (read, dashboard or manage, as a workspace key's), and `local` tools
|
|
188
|
+
// (signing in, playtests, the Steam Deck) are left out: they act on the computer the server runs on.
|
|
189
|
+
const tools = [];
|
|
190
|
+
|
|
191
|
+
// The annotations a read gets: it changes nothing and reads only the person's own Glitchless data.
|
|
192
|
+
const READS = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
193
|
+
|
|
194
|
+
export function define(name, config, handler, { scope = 'read', local = false } = {}) {
|
|
195
|
+
tools.push({ name, config: { ...config, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false, ...config.annotations } }, handler, scope, local });
|
|
167
196
|
}
|
|
168
197
|
|
|
198
|
+
// A read-only tool.
|
|
199
|
+
export function tool(name, description, schema, handler) {
|
|
200
|
+
define(name, { description, inputSchema: schema, annotations: READS }, handler);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// The tools a server built with these options shows: { name, title, description, annotations, scope, local }.
|
|
204
|
+
export function toolList({ remote = false, scopes = null } = {}) {
|
|
205
|
+
return tools.filter((t) => !(remote && t.local) && (!scopes || scopes.includes(t.scope))).map((t) => ({ name: t.name, title: titleOf(t), description: t.config.description, annotations: t.config.annotations, scope: t.scope, local: t.local }));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// "glitchless_store_reviews" → "Store reviews", unless the tool names its own title.
|
|
209
|
+
const titleOf = (t) => t.config.title ?? `${t.name.replace(/^glitchless_/, '').replace(/_/g, ' ').replace(/^./, (c) => c.toUpperCase())}`;
|
|
210
|
+
|
|
169
211
|
// Every tool takes `game` (by name or id): with a workspace key it picks the game, with a game key it's ignored.
|
|
170
212
|
const gameField = z.string().optional().describe('The game, by name or id, when signed in to a workspace (glitchless_list_games lists them); later calls keep it. Ignored with a key for one game.');
|
|
171
|
-
const register = server.registerTool.bind(server);
|
|
172
|
-
server.registerTool = (name, config, handler) =>
|
|
173
|
-
register(name, { ...config, inputSchema: { ...(config.inputSchema || {}), game: gameField } }, (args, extra) => calls.run({ game: args?.game }, () => handler(args || {}, extra)));
|
|
174
213
|
|
|
175
|
-
// A
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
} catch (err) {
|
|
182
|
-
return fail(err);
|
|
183
|
-
}
|
|
184
|
-
}),
|
|
214
|
+
// A server with the tools. remote: the HTTP server's set (no local tools, and instructions to match); scopes: show
|
|
215
|
+
// only the tools these scopes allow; connection: what every call runs with (default: this process's own).
|
|
216
|
+
export function createServer({ remote = false, scopes = null, connection: c = null } = {}) {
|
|
217
|
+
const server = new McpServer(
|
|
218
|
+
{ name: 'glitchless', title: 'Glitchless', version: VERSION, websiteUrl: 'https://www.glitchless.gg', icons: [{ src: 'https://app.glitchless.gg/brand/glitchless-icon-512.png', mimeType: 'image/png', sizes: ['512x512'] }] },
|
|
219
|
+
{ instructions: instructions(remote) },
|
|
185
220
|
);
|
|
221
|
+
for (const t of tools) {
|
|
222
|
+
if ((remote && t.local) || (scopes && !scopes.includes(t.scope))) continue;
|
|
223
|
+
const { inputSchema = {}, ...config } = t.config;
|
|
224
|
+
server.registerTool(t.name, { ...config, title: titleOf(t), inputSchema: z.object({ game: gameField, ...inputSchema }) }, (args = {}, ctx) => {
|
|
225
|
+
const run = () =>
|
|
226
|
+
calls.run({ game: args.game, server }, async () => {
|
|
227
|
+
try {
|
|
228
|
+
return await t.handler(args, ctx);
|
|
229
|
+
} catch (err) {
|
|
230
|
+
return fail(err);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
return c ? connections.run(c, run) : run();
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
return server;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function instructions(remote) {
|
|
240
|
+
return [
|
|
241
|
+
'Glitchless is observability for games made with Three.js, Phaser, Babylon.js, PlayCanvas, Unity, Godot, Unreal or GameMaker.',
|
|
242
|
+
remote
|
|
243
|
+
? "You're connected to the person's Glitchless workspace: glitchless_list_games lists every game, glitchless_create_game makes one and hands back its client token, every tool takes game (by name), and glitchless_share_board makes a read-only link to a board."
|
|
244
|
+
: "On Glitchless Cloud, glitchless_sign_in connects you to the person's whole workspace (they approve a code in the browser): then glitchless_list_games lists every game, glitchless_create_game makes one and hands back its client token, every tool takes game (by name), and glitchless_share_board makes a read-only link to a board.",
|
|
245
|
+
'Start with glitchless_triage to get ranked, evidence-backed findings for a game, then drill in with glitchless_performance, glitchless_get_error, glitchless_death_hotspots or glitchless_session.',
|
|
246
|
+
'When players or playtesters send bug reports from inside the game (an F8 form or a button), glitchless_bug_reports lists them with what they wrote, the level and where they stood, and opens one with its screenshot.',
|
|
247
|
+
'For metrics the game defines itself (what it sends with track() and count(): plays, purchases, paywall views, kills and gold, and so on) and funnels between them, use glitchless_events; it also lists the session properties the game sets (rank, class, region), which every read tool takes as props.',
|
|
248
|
+
'For a multiplayer game, glitchless_network gives ping, packet loss and disconnects by level, region, platform, kind of connection and version; glitchless_match lists matches or opens one from every side, telling a whole lobby lagging (the server) from one player lagging (their connection); and glitchless_servers reads the game\'s dedicated servers (tick time against its budget by players connected, crashes that ended matches, memory that climbs).',
|
|
249
|
+
'For a game connected to a store (Steam, Google Play, the App Store), glitchless_store_reviews reads what players wrote there by build, with the hardware and Steam Deck playtime reviewers show, next to what Glitchless measured on that build, and glitchless_store_vitals what the store itself measured (slow rendering, crashes, ANRs, hangs) next to Glitchless, version by version.',
|
|
250
|
+
"For a game connected to RevenueCat or to its own Stripe account, glitchless_revenue reads its real revenue by day, version and country (RevenueCat: production purchases only, by store too, installs and active users; Stripe: refunds, fees, net, new paying customers and revenue by product), next to the sessions, players and new players Glitchless measured and what the game's own purchase events add up to.",
|
|
251
|
+
"Each game has its own dashboard, a list of pages (boards of panels, and built-in views such as Errors, Sessions and Live Tail): read it with glitchless_dashboard, and after instrumenting a game, design one that fits it with glitchless_set_dashboard.",
|
|
252
|
+
...(remote
|
|
253
|
+
? ['After shipping a fix (bump the version passed to Glitchless.init), use glitchless_compare_versions to confirm it with real players.']
|
|
254
|
+
: [
|
|
255
|
+
'Before changing game code, run glitchless_playtest with save_as "baseline"; after the change, run glitchless_playtest again to compare, and treat a FAIL as unfinished work. After shipping a fix (bump the version passed to Glitchless.init), use glitchless_compare_versions to confirm it with real players.',
|
|
256
|
+
'If the game is running in a browser with WebMCP connected, its live tools (glitchless_live_performance, glitchless_measure, glitchless_inspect_scene, and game tools such as zoomies_load_level) let you reproduce and measure issues directly. Unity, Godot, Unreal and GameMaker builds measure themselves when run with --glitchless-measure=SECONDS (-glitchless-measure in Unreal and GameMaker); in the Unreal editor, Unreal MCP with the Glitchless Toolset has a Measure tool.',
|
|
257
|
+
]),
|
|
258
|
+
].join(' ');
|
|
186
259
|
}
|
|
187
260
|
|
|
188
261
|
export function slimIssue(i) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// The tools that work from a server anywhere: they read and write through the Glitchless API. http.js serves these;
|
|
2
|
+
// index.js (stdio) adds the ones that act on the computer the agent runs on (playtests, the Steam Deck).
|
|
3
|
+
import './tools/core.js';
|
|
4
|
+
import './tools/analytics.js';
|
|
5
|
+
import './tools/dashboard.js';
|
|
6
|
+
import './tools/reports.js';
|
|
7
|
+
import './tools/store-reviews.js';
|
|
8
|
+
import './tools/revenue.js';
|
|
9
|
+
import './tools/multiplayer.js';
|
|
10
|
+
import './tools/workspace.js';
|
package/src/http.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Glitchless's MCP server over Streamable HTTP, for clients that connect to a URL instead of starting a process
|
|
2
|
+
// (claude.ai and ChatGPT connectors, agents on another machine). Every request gets a server of its own
|
|
3
|
+
// (createServer), so nothing lives between requests: it runs behind a load balancer or in a serverless function, and
|
|
4
|
+
// answers clients of the 2026-07-28 protocol and older ones that open with initialize alike. The tools that act on
|
|
5
|
+
// the computer the server runs on (playtests, the Steam Deck, the device sign-in) are left out.
|
|
6
|
+
//
|
|
7
|
+
// The host checks each request's credentials, then hands over the connection it runs with and its scopes:
|
|
8
|
+
//
|
|
9
|
+
// const mcp = createHttpHandler();
|
|
10
|
+
// http.createServer((req, res) => mcp.handle(req, res, { connection, scopes }));
|
|
11
|
+
//
|
|
12
|
+
// Glitchless Cloud signs people in with OAuth and runs each request with their workspace key; `glitchless-mcp serve`
|
|
13
|
+
// (serve() below) serves this machine's own key or self-hosted server.
|
|
14
|
+
import crypto from 'node:crypto';
|
|
15
|
+
import http from 'node:http';
|
|
16
|
+
import { createMcpHandler } from '@modelcontextprotocol/server';
|
|
17
|
+
import { createServer, base } from './context.js';
|
|
18
|
+
import './hosted-tools.js';
|
|
19
|
+
|
|
20
|
+
export const MAX_BODY = 4 * 1024 * 1024;
|
|
21
|
+
|
|
22
|
+
// → { fetch(Request, { authInfo }) → Response, handle(req, res, opts), close() }. opts: { connection (default: this
|
|
23
|
+
// process's own), scopes (default: every tool), token, clientId }.
|
|
24
|
+
export function createHttpHandler({ responseMode = 'auto', onerror } = {}) {
|
|
25
|
+
const mcp = createMcpHandler(({ authInfo }) => createServer({ remote: true, connection: authInfo?.extra?.connection ?? null, scopes: authInfo?.extra?.scopes ?? null }), { responseMode, onerror, maxRequestBodySize: MAX_BODY });
|
|
26
|
+
return {
|
|
27
|
+
fetch: mcp.fetch,
|
|
28
|
+
async handle(req, res, { connection = null, scopes = null, token = '', clientId = '' } = {}) {
|
|
29
|
+
const request = await toRequest(req, res);
|
|
30
|
+
if (!request) return;
|
|
31
|
+
await send(res, await mcp.fetch(request, { authInfo: { token, clientId, scopes: scopes ?? [], extra: { connection, scopes } } }));
|
|
32
|
+
},
|
|
33
|
+
close: mcp.close,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// A Node request as a web Request (null once it has answered 413 itself), aborted if the client goes away.
|
|
38
|
+
async function toRequest(req, res) {
|
|
39
|
+
const chunks = [];
|
|
40
|
+
let size = 0;
|
|
41
|
+
for await (const chunk of req) {
|
|
42
|
+
size += chunk.length;
|
|
43
|
+
if (size > MAX_BODY) {
|
|
44
|
+
res.writeHead(413, { 'content-type': 'application/json' }).end(JSON.stringify({ error: 'Request body too large.' }));
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
chunks.push(chunk);
|
|
48
|
+
}
|
|
49
|
+
const headers = new Headers();
|
|
50
|
+
for (const [k, v] of Object.entries(req.headers)) if (v != null) headers.set(k, Array.isArray(v) ? v.join(', ') : v);
|
|
51
|
+
const abort = new AbortController();
|
|
52
|
+
res.on('close', () => res.writableFinished || abort.abort());
|
|
53
|
+
const body = req.method === 'GET' || req.method === 'HEAD' || !size ? undefined : Buffer.concat(chunks);
|
|
54
|
+
return new Request(new URL(req.url, `http://${req.headers.host || 'localhost'}`), { method: req.method, headers, body, signal: abort.signal });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function send(res, response) {
|
|
58
|
+
const headers = {};
|
|
59
|
+
response.headers.forEach((v, k) => (headers[k] = v));
|
|
60
|
+
res.writeHead(response.status, headers);
|
|
61
|
+
if (response.body) for await (const chunk of response.body) res.write(chunk);
|
|
62
|
+
res.end();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ── glitchless-mcp serve ─────────────────────────────────────────
|
|
66
|
+
// The hosted tools at http://<host>:<port>/mcp, reading with this machine's key or self-hosted server (as the stdio
|
|
67
|
+
// server does: GLITCHLESS_URL, GLITCHLESS_API_KEY or a saved sign-in). On this computer only by default, where it
|
|
68
|
+
// checks Host and Origin against DNS rebinding; to listen beyond it, set GLITCHLESS_MCP_TOKEN and clients send it as
|
|
69
|
+
// Authorization: Bearer.
|
|
70
|
+
const LOOPBACK = new Set(['localhost', '127.0.0.1', '[::1]', '::1']);
|
|
71
|
+
const hostname = (value) => {
|
|
72
|
+
try {
|
|
73
|
+
return new URL(value.includes('://') ? value : `http://${value}`).hostname;
|
|
74
|
+
} catch {
|
|
75
|
+
return '';
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// → the listening http.Server; throws when told to listen beyond this computer without a token.
|
|
80
|
+
export async function serve(argv = []) {
|
|
81
|
+
const flag = (name) => {
|
|
82
|
+
const i = argv.indexOf(`--${name}`);
|
|
83
|
+
return i >= 0 ? argv[i + 1] : null;
|
|
84
|
+
};
|
|
85
|
+
const port = Number(flag('port') || process.env.PORT || 3001);
|
|
86
|
+
const host = flag('host') || '127.0.0.1';
|
|
87
|
+
const token = process.env.GLITCHLESS_MCP_TOKEN || '';
|
|
88
|
+
const local = LOOPBACK.has(host);
|
|
89
|
+
if (!local && !token) throw new Error(`Listening on ${host} lets other computers in: set GLITCHLESS_MCP_TOKEN, and clients send it as Authorization: Bearer.`);
|
|
90
|
+
const mcp = createHttpHandler();
|
|
91
|
+
const server = http.createServer(async (req, res) => {
|
|
92
|
+
const deny = (status, error, extra = {}) => res.writeHead(status, { 'content-type': 'application/json', ...extra }).end(JSON.stringify({ error }));
|
|
93
|
+
if (new URL(req.url, 'http://local').pathname !== '/mcp') return deny(404, 'Not found: the MCP endpoint is /mcp.');
|
|
94
|
+
if (local && (!LOOPBACK.has(hostname(req.headers.host || '')) || (req.headers.origin && !LOOPBACK.has(hostname(req.headers.origin))))) return deny(403, 'Only this computer may call this server.');
|
|
95
|
+
if (token) {
|
|
96
|
+
const given = crypto.createHash('sha256').update(String(req.headers.authorization || '').replace(/^Bearer\s+/i, '')).digest();
|
|
97
|
+
if (!crypto.timingSafeEqual(given, crypto.createHash('sha256').update(token).digest())) return deny(401, 'Send GLITCHLESS_MCP_TOKEN as Authorization: Bearer.', { 'www-authenticate': 'Bearer' });
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
await mcp.handle(req, res);
|
|
101
|
+
} catch (err) {
|
|
102
|
+
console.error(err);
|
|
103
|
+
if (!res.headersSent) deny(500, 'Something went wrong.');
|
|
104
|
+
else res.end();
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
await new Promise((resolve, reject) => server.once('error', reject).listen(port, host, resolve));
|
|
108
|
+
console.error(`Glitchless MCP on http://${host.includes(':') ? `[${host}]` : host}:${server.address().port}/mcp, reading ${base()}`);
|
|
109
|
+
return server;
|
|
110
|
+
}
|
package/src/index.js
CHANGED
|
@@ -10,25 +10,29 @@
|
|
|
10
10
|
//
|
|
11
11
|
// npx -y glitchless-mcp login (also: whoami, logout)
|
|
12
12
|
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
// Or serve it over Streamable HTTP, for clients that connect to a URL (http.js):
|
|
14
|
+
//
|
|
15
|
+
// npx -y glitchless-mcp serve [--port 3001] [--host 127.0.0.1]
|
|
16
|
+
//
|
|
17
|
+
// The connection and the list of tools are in context.js; each area's tools are in tools/<area>.js, and a new area
|
|
18
|
+
// is one more file imported in hosted-tools.js (or here, for a tool that acts on this computer).
|
|
17
19
|
|
|
18
20
|
if (['login', 'logout', 'whoami'].includes(process.argv[2])) {
|
|
19
21
|
const { cli } = await import('./login.js');
|
|
20
22
|
process.exit(await cli(process.argv.slice(2)));
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
await import('./
|
|
25
|
-
await
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
await import('
|
|
31
|
-
await import('./
|
|
32
|
-
await import('./tools
|
|
33
|
-
|
|
34
|
-
await
|
|
25
|
+
if (process.argv[2] === 'serve') {
|
|
26
|
+
const { serve } = await import('./http.js');
|
|
27
|
+
await serve(process.argv.slice(3)).catch((err) => {
|
|
28
|
+
console.error(err.message);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
const { serveStdio } = await import('@modelcontextprotocol/server/stdio');
|
|
33
|
+
const { createServer } = await import('./context.js');
|
|
34
|
+
await import('./hosted-tools.js');
|
|
35
|
+
await import('./tools/playtest.js');
|
|
36
|
+
await import('./tools/deck.js');
|
|
37
|
+
serveStdio(() => createServer());
|
|
38
|
+
}
|
package/src/login.js
CHANGED
|
@@ -66,7 +66,7 @@ export async function cli(argv) {
|
|
|
66
66
|
};
|
|
67
67
|
if (command === 'logout') {
|
|
68
68
|
fs.rmSync(CREDENTIALS_FILE, { force: true });
|
|
69
|
-
console.log('Signed out: the saved workspace key is deleted. Revoke it in Settings →
|
|
69
|
+
console.log('Signed out: the saved workspace key is deleted. Revoke it in Settings → Keys & access if it may have leaked.');
|
|
70
70
|
return 0;
|
|
71
71
|
}
|
|
72
72
|
if (command === 'whoami') {
|