glitchless-mcp 0.13.0 → 0.14.1

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 CHANGED
@@ -28,7 +28,8 @@ every tool takes `game` (a name or id). The key acts as you, with your role in t
28
28
  or touches billing or people. `npx -y glitchless-mcp whoami` shows where you're signed in, `logout` deletes the saved
29
29
  key, and Settings → Keys & access in the dashboard lists and revokes keys. An agent can also sign in from inside a
30
30
  chat with the `glitchless_sign_in` tool: it shows the link and code, and the running server switches over once you
31
- approve.
31
+ approve. The saved key is only ever sent to the server it was saved for: point `GLITCHLESS_URL` at another one (a
32
+ meetup's own box) and the MCP server connects without it, so set `GLITCHLESS_API_KEY` if that server has a key.
32
33
 
33
34
  ## Serve it over HTTP yourself
34
35
 
@@ -46,7 +47,7 @@ clients send it as `Authorization: Bearer`.
46
47
 
47
48
  | Variable | What |
48
49
  | --- | --- |
49
- | `GLITCHLESS_URL` | Your Glitchless server. Default: the signed-in workspace's, else `http://localhost:7777` |
50
+ | `GLITCHLESS_URL` | Your Glitchless server. Default: the signed-in workspace's, else `http://localhost:7777`. A saved sign-in goes only to the server it was saved for |
50
51
  | `GLITCHLESS_API_KEY` | A key, if the server needs one: a workspace key (`gl_ws_…`) for every game, or a secret key (`gl_sk_…`) for one. Overrides a sign-in. Keep it out of git and out of the game |
51
52
  | `GLITCHLESS_GAME` | With a workspace key, the game to use when a call doesn't name one. Optional |
52
53
  | `GLITCHLESS_SERVICE` | The service to use when a call doesn't name one. Optional |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitchless-mcp",
3
- "version": "0.13.0",
3
+ "version": "0.14.1",
4
4
  "mcpName": "io.github.glitchless-gg/glitchless",
5
5
  "description": "Coding agents can build a game. They can't see anyone play it. Glitchless lets them. The MCP server for Glitchless, game observability for coding agents: Claude Code, Codex, Cursor and others read real players' stutters, crashes, custom metrics and ranked findings in Unity, Godot, Unreal, Three.js, Phaser and GameMaker games, build the game's own dashboard, and run playtest bots.",
6
6
  "keywords": [
package/src/context.js CHANGED
@@ -9,7 +9,7 @@ import path from 'node:path';
9
9
  import { McpServer } from '@modelcontextprotocol/server';
10
10
  import { z } from 'zod';
11
11
 
12
- export const VERSION = '0.13.0';
12
+ export const VERSION = '0.14.1';
13
13
 
14
14
  // Where `glitchless-mcp login` keeps its workspace key: { url, token, workspace: { id, name }, scopes }.
15
15
  export const CREDENTIALS_FILE = path.join(process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config'), 'glitchless', 'credentials.json');
@@ -28,15 +28,34 @@ export function connection({ base, apiKey = '', service = '', game = '', fetch =
28
28
  return { base: String(base).replace(/\/$/, ''), apiKey, service, game, fetch, client, games: null };
29
29
  }
30
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`).
33
- const saved = process.env.GLITCHLESS_API_KEY ? null : readCredentials();
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
- });
31
+ const originOf = (u) => {
32
+ try {
33
+ return new URL(u).origin;
34
+ } catch {
35
+ return null;
36
+ }
37
+ };
38
+
39
+ // On stdio, the one connection: GLITCHLESS_URL and GLITCHLESS_API_KEY win, else the saved sign-in. A saved key goes
40
+ // only to the server it was saved for, so pointing GLITCHLESS_URL at a meetup's own server never hands it a Glitchless
41
+ // Cloud key: the connection goes without one (an open self-hosted server needs none), and `savedFor`, the origin the
42
+ // sign-in is for, says why on a 401. Over HTTP each request runs with the connection its bearer token gives
43
+ // (createServer's `connection`).
44
+ export function stdioConnection(env = process.env) {
45
+ const saved = env.GLITCHLESS_API_KEY ? null : readCredentials();
46
+ const savedAt = saved?.token ? originOf(saved.url) : null;
47
+ const fits = Boolean(saved?.token) && (!env.GLITCHLESS_URL || (savedAt !== null && originOf(env.GLITCHLESS_URL) === savedAt));
48
+ return {
49
+ ...connection({
50
+ base: env.GLITCHLESS_URL || (fits ? saved.url : '') || 'http://localhost:7777',
51
+ apiKey: env.GLITCHLESS_API_KEY || (fits ? saved.token : ''),
52
+ service: env.GLITCHLESS_SERVICE || '',
53
+ game: env.GLITCHLESS_GAME || '',
54
+ }),
55
+ savedFor: saved?.token && !fits ? (savedAt ?? String(saved.url)) : null,
56
+ };
57
+ }
58
+ const local = stdioConnection();
40
59
  const connections = new AsyncLocalStorage();
41
60
  const conn = () => connections.getStore() ?? local;
42
61
 
@@ -47,7 +66,13 @@ export const isWorkspace = () => conn().apiKey.startsWith('gl_ws_');
47
66
 
48
67
  // After a sign-in from inside the agent (glitchless_sign_in): the running server switches to the new key.
49
68
  export function useCredentials({ url, token }) {
50
- Object.assign(local, { base: String(url).replace(/\/$/, ''), apiKey: token, games: null });
69
+ Object.assign(local, { base: String(url).replace(/\/$/, ''), apiKey: token, games: null, savedFor: null });
70
+ }
71
+
72
+ // What a 401 adds when the saved sign-in was kept from this server: where it's for, and how to give this one a key.
73
+ function signInHint(status) {
74
+ const { savedFor, base: at } = conn();
75
+ return status === 401 && savedFor ? ` The saved sign-in is for ${savedFor} and isn't sent to another server: set GLITCHLESS_API_KEY for ${at}.` : '';
51
76
  }
52
77
 
53
78
  // The games a workspace key reaches, cached briefly; the game each call names (by name or id), else the one the
@@ -104,7 +129,7 @@ export async function query(name, params = {}) {
104
129
  const qs = new URLSearchParams();
105
130
  for (const [k, v] of Object.entries(params)) if (v != null && v !== '') qs.set(k, String(v));
106
131
  const res = await conn().fetch(`${base()}/v1/query/${name}?${qs}`, { headers: await headers() });
107
- if (!res.ok) throw new Error(`Glitchless API ${name} → HTTP ${res.status}: ${(await res.text()).slice(0, 200)}`);
132
+ if (!res.ok) throw new Error(`Glitchless API ${name} → HTTP ${res.status}: ${(await res.text()).slice(0, 200)}${signInHint(res.status)}`);
108
133
  const data = await res.json();
109
134
  const call = calls.getStore();
110
135
  if (call && data?.meta) Object.assign(call, { meta: data.meta, from: params.from });
@@ -136,7 +161,7 @@ export async function write(method, p, body) {
136
161
  });
137
162
  const data = await res.json().catch(() => ({}));
138
163
  if (res.status === 403) throw new Error(`${data.error || 'forbidden'}. Saving a dashboard needs a key with the dashboard scope (a workspace key from glitchless_sign_in has it).`);
139
- if (!res.ok) throw new Error(`Glitchless API ${method} ${p} → HTTP ${res.status}: ${data.error || ''}`);
164
+ if (!res.ok) throw new Error(`Glitchless API ${method} ${p} → HTTP ${res.status}: ${data.error || ''}${signInHint(res.status)}`);
140
165
  return data;
141
166
  }
142
167
 
@@ -267,7 +292,15 @@ function instructions(remote) {
267
292
 
268
293
  // An issue in a list: with `resolved` or `came_back` when the game's owner resolved it (glitchless_resolve_error).
269
294
  export function slimIssue(i) {
270
- return { fingerprint: i.fingerprint, kind: i.kind, message: i.message, location: i.location, count: i.count, sessions: i.sessions, sessions_pct: i.sessions_pct, levels: i.levels, versions: i.versions, first_version: i.first_version, last_seen: new Date(i.last_seen).toISOString(), ...(i.resolved ? { resolved: i.resolved } : {}), ...(i.came_back ? { came_back: i.came_back } : {}) };
295
+ return { fingerprint: i.fingerprint, kind: i.kind, message: i.message, location: i.location, count: i.count, sessions: i.sessions, sessions_pct: i.sessions_pct, levels: i.levels, versions: i.versions, first_version: i.first_version, last_seen: new Date(i.last_seen).toISOString(), ...(i.no_players ? { no_players: i.no_players } : {}), ...(i.resolved ? { resolved: i.resolved } : {}), ...(i.came_back ? { came_back: i.came_back } : {}) };
296
+ }
297
+
298
+ // An issue no player hit (the errors query's no_players: its sessions by kind), in a line, or ''.
299
+ const TEST_KINDS = { synthetic: 'synthetic (bots, playtests, store test phones)', tester: 'tester', simulated: 'simulated', dev_builds: 'on dev builds' };
300
+ export function noPlayersLine(i) {
301
+ if (!i.no_players) return '';
302
+ const kinds = Object.entries(i.no_players).map(([k, n]) => `${n} ${TEST_KINDS[k] ?? k}`);
303
+ return `No player hit it${kinds.length ? `: its sessions were ${kinds.join(', ')}` : ', only test sessions'}. Check that it can happen on players' devices before changing code for it.`;
271
304
  }
272
305
 
273
306
  export function slimGroup(g) {
package/src/tools/core.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // The built-in reads: which games report, findings, headline numbers, frame time, errors, levels,
2
2
  // death hotspots and one session in detail.
3
3
  import { z } from 'zod';
4
- import { base, query, resolveService, range, reply, common, tool, slimIssue, slimGroup, filters, isWorkspace, workspaceGames, workspaceIntake, agent, SETUP_URL } from '../context.js';
4
+ import { base, query, resolveService, range, reply, common, tool, slimIssue, noPlayersLine, slimGroup, filters, isWorkspace, workspaceGames, workspaceIntake, agent, SETUP_URL } from '../context.js';
5
5
 
6
6
  tool('glitchless_list_games', 'List the games: with a workspace key, every game in the workspace (its id, name, client token and the services reporting to it); with a key for one game, its services, versions, environments and when they were last seen.', {}, async () => {
7
7
  if (isWorkspace()) {
@@ -78,7 +78,7 @@ tool(
78
78
 
79
79
  tool(
80
80
  'glitchless_get_error',
81
- "Error Tracking for a game. Without a fingerprint: the open error issues ranked by sessions affected, any that came back first (`came_back`: resolved by the game's owner, then fired again in a later version: which, since when, and the note), and then, apart, the ones resolved (`resolved`: when, the newest version it had been seen in, the note). With a fingerprint: the full issue — message, location, stack trace, affected levels/versions, occurrence counts and breadcrumbs (the game events right before it fired), and whether it is resolved or came back. For a minified web build whose source maps were uploaded (glitchless-sourcemaps), location and stack are the original ones, `frames` gives each frame with its line of code, and `minified` what the browser reported. glitchless_resolve_error resolves one.",
81
+ "Error Tracking for a game. Without a fingerprint: the open error issues ranked by sessions affected, any that came back first (`came_back`: resolved by the game's owner, then hit by players again in a later version: which, since when, and the note), and then, apart, the ones resolved (`resolved`: when, the newest version it had been seen in, the note). With a fingerprint: the full issue — message, location, stack trace, affected levels/versions, occurrence counts and breadcrumbs (the game events right before it fired), and whether it is resolved or came back. An issue no player hit has `no_players`, its sessions by kind (synthetic: bots, playtests and store test phones such as Google Play's pre-launch ones; tester; dev_builds): check that it can happen on players' devices before fixing it. For a minified web build whose source maps were uploaded (glitchless-sourcemaps), location and stack are the original ones, `frames` gives each frame with its line of code, and `minified` what the browser reported. glitchless_resolve_error resolves one.",
82
82
  { ...common, fingerprint: z.string().optional().describe('Issue fingerprint from the list or from glitchless_triage') },
83
83
  async ({ service, hours, fingerprint, ...f }) => {
84
84
  const svc = await resolveService(service);
@@ -87,13 +87,15 @@ tool(
87
87
  const open = issues.filter((i) => !i.resolved).map(slimIssue);
88
88
  const resolved = issues.filter((i) => i.resolved).map(slimIssue);
89
89
  const back = open.filter((i) => i.came_back).length;
90
- return reply(`${open.length} open error issue(s) in ${svc}${back ? `, ${back} of them back after being resolved` : ''}${resolved.length ? `; ${resolved.length} resolved (left out of glitchless_triage)` : ''}`, resolved.length ? { open, resolved } : open);
90
+ const tests = open.filter((i) => i.no_players).length;
91
+ return reply(`${open.length} open error issue(s) in ${svc}${back ? `, ${back} of them back after being resolved` : ''}${tests ? `, ${tests} hit by no player (only test phones, bots, testers or dev builds: no_players)` : ''}${resolved.length ? `; ${resolved.length} resolved (left out of glitchless_triage)` : ''}`, resolved.length ? { open, resolved } : open);
91
92
  }
92
93
  const issue = issues.find((i) => i.fingerprint === fingerprint || i.fingerprint?.startsWith(fingerprint));
93
94
  if (!issue) return reply(`No issue ${fingerprint} in ${svc} in this window. Known issues:`, issues.map(slimIssue));
94
95
  const { series, ...rest } = issue;
95
96
  const state = issue.came_back ? ` — resolved${issue.came_back.resolved.version ? ` in ${issue.came_back.resolved.version}` : ''}, and came back in ${issue.came_back.version}` : issue.resolved ? ` — resolved${issue.resolved.version ? ` (newest version then: ${issue.resolved.version})` : ''}${issue.resolved.note ? `: ${issue.resolved.note}` : ''}` : '';
96
- return reply(`Error issue ${issue.fingerprint} in ${svc}${state}`, rest);
97
+ const tests = noPlayersLine(issue);
98
+ return reply(`Error issue ${issue.fingerprint} in ${svc}${state}${tests ? `. ${tests}` : ''}`, rest);
97
99
  },
98
100
  );
99
101
 
@@ -116,24 +116,26 @@ act(
116
116
 
117
117
  act(
118
118
  'glitchless_resolve_error',
119
- "Resolve an error issue, as in Sentry: the game's owner has fixed it or accepts it (a GPU driver's error on test phones, one the newest build fixed). The Errors page hides it, glitchless_get_error lists it apart, and glitchless_triage, the overview and the weekly summary leave it out. It comes back by itself if it fires again in a version later than the newest it had been seen in (any_version: in any version, the old builds included), first in the list and new to the new_error alert. fingerprint is the issue's from glitchless_get_error or glitchless_triage (error-<fingerprint>), or the start of one. Resolving one again (one that came back) starts over from now. clear: true unresolves it. Without fingerprint, lists the game's resolved errors. Only the person's say-so resolves an error: ask before resolving one. Needs an Owner's or Admin's key, as alert settings do.",
119
+ "Resolve an error issue, as in Sentry: the game's owner has fixed it or accepts it (a GPU driver's error on test phones, one the newest build fixed). The Errors page hides it, glitchless_get_error lists it apart, and glitchless_triage, the overview and the weekly summary leave it out. It comes back by itself if players hit it again in a version later than the newest players had hit it in (any_version: in any version, the old builds included), first in the list and new to the new_error alert. Store test phones (Google Play runs each upload on its own before release), bots, testers and dev builds don't bring it back unless all_sessions is true. fingerprint is the issue's from glitchless_get_error or glitchless_triage (error-<fingerprint>), or the start of one. Resolving one again (one that came back) starts over from now. clear: true unresolves it. Without fingerprint, lists the game's resolved errors. Only the person's say-so resolves an error: ask before resolving one. Needs an Owner's or Admin's key, as alert settings do.",
120
120
  {
121
121
  fingerprint: z.string().optional().describe('The issue\'s fingerprint, e.g. "9803ec1a", or the start of one'),
122
122
  note: z.string().optional().describe('Why, in a few words (200 characters at most), e.g. "Google Play\'s test phones on SwiftShader"'),
123
123
  any_version: z.boolean().optional().describe('Come back if it fires again in any version, not only a later one'),
124
+ all_sessions: z.boolean().optional().describe("Come back when any session fires it (store test phones, bots, testers, dev builds), not only a player's"),
124
125
  clear: z.boolean().optional().describe('Unresolve it'),
125
126
  },
126
- async ({ fingerprint, note, any_version, clear, game }) => {
127
+ async ({ fingerprint, note, any_version, all_sessions, clear, game }) => {
127
128
  const pid = await projectFor(game);
128
129
  if (!fingerprint) {
129
130
  const { resolved } = await agent('GET', `/games/${pid}/resolved`);
130
131
  return reply(resolved.length ? `${resolved.length} resolved error(s), hidden on the Errors page and left out of triage until they come back:` : 'No resolved errors.', resolved);
131
132
  }
132
133
  const fp = fingerprint.replace(/^error-/, '');
133
- const { resolved } = await agent('POST', `/games/${pid}/resolved`, clear ? { fingerprint: fp, clear: true } : { fingerprint: fp, note, any_version });
134
+ const { resolved } = await agent('POST', `/games/${pid}/resolved`, clear ? { fingerprint: fp, clear: true } : { fingerprint: fp, note, any_version, all_sessions });
134
135
  if (clear) return reply(`${fp} is open again: the Errors page and glitchless_triage show it.`, resolved);
135
136
  const e = resolved.find((x) => x.fingerprint.startsWith(fp));
136
- return reply(`Resolved ${e.fingerprint}. It comes back if it fires again ${e.any ? 'in any version' : e.version ? `in a version after ${e.version}` : 'at all'}. Resolved errors:`, resolved);
137
+ const who = e.all_sessions ? 'any session fires it' : 'a player hits it';
138
+ return reply(`Resolved ${e.fingerprint}. It comes back if ${who} again ${e.any ? 'in any version' : e.version ? `in a version after ${e.version}` : 'at all'}. Resolved errors:`, resolved);
137
139
  },
138
140
  // Resolving again starts it over, and clear unresolves one.
139
141
  { title: 'Resolve error', annotations: { destructiveHint: true, idempotentHint: false } },