breakpoint-mcp 1.4.0 → 1.4.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
@@ -30,7 +30,9 @@ npx breakpoint-mcp doctor
30
30
 
31
31
  `init` copies the addon into `addons/breakpoint_mcp/`, enables it in `project.godot`, and
32
32
  prints — or, with `--client claude-code|claude-desktop|cursor|windsurf|vscode`, writes —
33
- the client config. `doctor` checks the Godot binary, the addon, and the four bridges
33
+ the client config. By default it uses the addon bundled in this package; add
34
+ `--from-github [ref]` to fetch the addon from GitHub instead (e.g. `--from-github main`).
35
+ `doctor` checks the Godot binary, the addon, and the four bridges
34
36
  (add `--require-live` once the editor is open; `--json` for a machine-readable report).
35
37
 
36
38
  To install the `breakpoint-mcp` command globally instead of invoking it via `npx`:
@@ -0,0 +1,97 @@
1
+ /**
2
+ * `--from-github` escape hatch for `breakpoint-mcp init`: fetch the editor addon
3
+ * (addons/breakpoint_mcp/**) straight from the GitHub repo at a chosen ref, as an
4
+ * alternative to the copy bundled in the npm tarball. Used when the bundled addon
5
+ * is missing/corrupt, or to install a different ref (e.g. `main`, or an older tag)
6
+ * than the one that shipped with the installed package.
7
+ *
8
+ * Dependency-free: one GitHub git/trees API call lists the addon's blobs at the ref,
9
+ * then each file is downloaded from raw.githubusercontent.com (a CDN that does not
10
+ * count against the REST rate limit). The fetch-shaped dependency is injectable, so
11
+ * the whole path is unit-testable offline.
12
+ */
13
+ import fs from "node:fs";
14
+ import path from "node:path";
15
+ export const DEFAULT_REPO = "jlivingston-Cipher/godot-breakpoint-mcp";
16
+ const ADDON_PREFIX = "addons/breakpoint_mcp/";
17
+ const USER_AGENT = "breakpoint-mcp-cli";
18
+ function defaultFetch() {
19
+ const f = globalThis.fetch;
20
+ if (typeof f !== "function") {
21
+ throw new Error("global fetch is unavailable — Node 18+ is required for --from-github.");
22
+ }
23
+ return f;
24
+ }
25
+ /** Validate and split an `owner/repo` slug; throws on anything else. */
26
+ export function parseRepo(repo) {
27
+ const m = /^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)$/.exec(repo.trim());
28
+ if (!m)
29
+ throw new Error(`invalid --repo '${repo}' (expected owner/repo).`);
30
+ return { owner: m[1], name: m[2] };
31
+ }
32
+ function authHeaders() {
33
+ const token = process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN;
34
+ const h = { "User-Agent": USER_AGENT };
35
+ if (token)
36
+ h.Authorization = `Bearer ${token}`;
37
+ return h;
38
+ }
39
+ /**
40
+ * Fetch addons/breakpoint_mcp/** from `repo` at `ref` into `dest` (created if
41
+ * needed). Returns the written relative paths. Throws a clear Error on a bad
42
+ * repo/ref, a missing addon, rate-limiting, or a network failure.
43
+ */
44
+ export async function fetchAddonFromGitHub(opts, fetchFn) {
45
+ const doFetch = fetchFn ?? defaultFetch();
46
+ const { owner, name } = parseRepo(opts.repo);
47
+ const ref = opts.ref;
48
+ const treeUrl = `https://api.github.com/repos/${owner}/${name}/git/trees/${ref}?recursive=1`;
49
+ let treeRes;
50
+ try {
51
+ treeRes = await doFetch(treeUrl, {
52
+ headers: { ...authHeaders(), Accept: "application/vnd.github+json" },
53
+ });
54
+ }
55
+ catch (err) {
56
+ throw new Error(`could not reach GitHub: ${err instanceof Error ? err.message : String(err)}`);
57
+ }
58
+ if (treeRes.status === 404) {
59
+ throw new Error(`GitHub returned 404 for ${owner}/${name}@${ref} — check the repo and ref.`);
60
+ }
61
+ if (treeRes.status === 403) {
62
+ throw new Error("GitHub returned 403 (rate-limited or forbidden). Set GITHUB_TOKEN to raise the limit, or retry later.");
63
+ }
64
+ if (!treeRes.ok) {
65
+ throw new Error(`GitHub git/trees request failed (HTTP ${treeRes.status}).`);
66
+ }
67
+ const body = (await treeRes.json());
68
+ if (body.truncated) {
69
+ throw new Error(`the repository tree at ${ref} was too large to list in one request; --from-github can't be used for this ref.`);
70
+ }
71
+ const entries = Array.isArray(body.tree) ? body.tree : [];
72
+ const files = entries.filter((e) => e.type === "blob" && e.path.startsWith(ADDON_PREFIX));
73
+ if (files.length === 0) {
74
+ throw new Error(`no ${ADDON_PREFIX} found in ${owner}/${name}@${ref}.`);
75
+ }
76
+ const written = [];
77
+ for (const f of files) {
78
+ const rawUrl = `https://raw.githubusercontent.com/${owner}/${name}/${ref}/${f.path}`;
79
+ let res;
80
+ try {
81
+ res = await doFetch(rawUrl, { headers: { "User-Agent": USER_AGENT } });
82
+ }
83
+ catch (err) {
84
+ throw new Error(`could not download ${f.path}: ${err instanceof Error ? err.message : String(err)}`);
85
+ }
86
+ if (!res.ok) {
87
+ throw new Error(`could not download ${f.path} (HTTP ${res.status}).`);
88
+ }
89
+ const rel = f.path.slice(ADDON_PREFIX.length);
90
+ const outPath = path.join(opts.dest, rel);
91
+ fs.mkdirSync(path.dirname(outPath), { recursive: true });
92
+ fs.writeFileSync(outPath, Buffer.from(await res.arrayBuffer()));
93
+ written.push(rel);
94
+ }
95
+ return written;
96
+ }
97
+ //# sourceMappingURL=github.js.map
package/dist/cli/init.js CHANGED
@@ -9,10 +9,12 @@
9
9
  * it into that client's config file (see clients.ts for the id list + paths).
10
10
  */
11
11
  import fs from "node:fs";
12
+ import os from "node:os";
12
13
  import path from "node:path";
13
14
  import { fileURLToPath } from "node:url";
14
15
  import { parseArgs } from "./args.js";
15
16
  import { CLIENT_IDS, clientInfo, mergeClientConfig, serverEntry, snippet } from "./clients.js";
17
+ import { DEFAULT_REPO, fetchAddonFromGitHub } from "./github.js";
16
18
  const PLUGIN_REL = "addons/breakpoint_mcp";
17
19
  const PLUGIN_CFG_RES = "res://addons/breakpoint_mcp/plugin.cfg";
18
20
  const SERVER_NAME = "godot";
@@ -39,6 +41,23 @@ export function resolveBundledAddon() {
39
41
  }
40
42
  return null;
41
43
  }
44
+ /** This package's own version, read from its package.json (null if unreadable). */
45
+ function packageVersion() {
46
+ try {
47
+ const pkgRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", ".."); // dist/cli -> pkg
48
+ const v = JSON.parse(fs.readFileSync(path.join(pkgRoot, "package.json"), "utf8"))
49
+ .version;
50
+ return typeof v === "string" ? v : null;
51
+ }
52
+ catch {
53
+ return null;
54
+ }
55
+ }
56
+ /** Default ref for --from-github: this package's version tag (vX.Y.Z), else main. */
57
+ function defaultGitHubRef() {
58
+ const v = packageVersion();
59
+ return v ? `v${v}` : "main";
60
+ }
42
61
  /**
43
62
  * Add `res://addons/breakpoint_mcp/plugin.cfg` to project.godot's
44
63
  * `[editor_plugins] enabled=PackedStringArray(...)`, creating the section or the
@@ -102,7 +121,7 @@ function claudeCodeCommand(projectPath) {
102
121
  return `claude mcp add godot --env GODOT_PROJECT=${projectPath} -- npx -y breakpoint-mcp`;
103
122
  }
104
123
  /** Entry point for `breakpoint-mcp init`. Returns the process exit code. */
105
- export async function runInit(argv) {
124
+ export async function runInit(argv, deps = {}) {
106
125
  const { flags } = parseArgs(argv, ["force", "dry-run"]);
107
126
  const projectPath = typeof flags.project === "string"
108
127
  ? path.resolve(flags.project)
@@ -111,30 +130,69 @@ export async function runInit(argv) {
111
130
  const force = flags.force === true;
112
131
  const client = typeof flags.client === "string" ? flags.client : "none";
113
132
  const godotBin = process.env.GODOT_BIN ?? "godot";
133
+ // --from-github [ref]: source the addon from GitHub instead of the bundled copy.
134
+ const fromGitHub = "from-github" in flags;
135
+ const fgVal = flags["from-github"];
136
+ const ref = typeof fgVal === "string" && fgVal.length > 0 ? fgVal : defaultGitHubRef();
137
+ const repo = typeof flags.repo === "string" && flags.repo.length > 0 ? flags.repo : DEFAULT_REPO;
114
138
  const projGodot = path.join(projectPath, "project.godot");
115
139
  if (!fs.existsSync(projGodot)) {
116
140
  process.stderr.write(`init: no project.godot at ${projectPath}\n` +
117
141
  " Pass --project <dir> pointing at your Godot project (the folder with project.godot).\n");
118
142
  return 1;
119
143
  }
120
- const addonSource = resolveBundledAddon();
121
- if (!addonSource) {
122
- process.stderr.write("init: could not locate the bundled editor addon inside the package.\n");
123
- return 1;
124
- }
125
144
  const out = [];
126
145
  const say = (s = "") => {
127
146
  out.push(s);
128
147
  };
129
148
  say(`Project: ${projectPath}${dryRun ? " (dry run — no changes written)" : ""}`);
149
+ // Resolve the addon source: the bundled copy, or (--from-github) a temp dir
150
+ // fetched from GitHub. The temp dir is removed once the addon is installed.
151
+ let addonSource = null;
152
+ let tmpFetchDir = null;
153
+ if (fromGitHub) {
154
+ if (dryRun) {
155
+ say(` addon source: would fetch ${repo}@${ref} from GitHub`);
156
+ }
157
+ else {
158
+ say(` addon source: fetching ${repo}@${ref} from GitHub…`);
159
+ tmpFetchDir = fs.mkdtempSync(path.join(os.tmpdir(), "bpmcp-gh-"));
160
+ try {
161
+ const written = await fetchAddonFromGitHub({ repo, ref, dest: tmpFetchDir }, deps.fetchFn);
162
+ say(` addon source: fetched ${written.length} file(s) from ${repo}@${ref}`);
163
+ addonSource = tmpFetchDir;
164
+ }
165
+ catch (err) {
166
+ fs.rmSync(tmpFetchDir, { recursive: true, force: true });
167
+ process.stderr.write(`init: --from-github failed: ${err instanceof Error ? err.message : String(err)}\n` +
168
+ " Omit --from-github to install the addon bundled with this package.\n");
169
+ return 1;
170
+ }
171
+ }
172
+ }
173
+ else {
174
+ addonSource = resolveBundledAddon();
175
+ if (!addonSource) {
176
+ process.stderr.write("init: could not locate the bundled editor addon inside the package.\n" +
177
+ " Reinstall breakpoint-mcp, or pass --from-github to fetch the addon from GitHub.\n");
178
+ return 1;
179
+ }
180
+ }
130
181
  // 1. Install the addon.
131
182
  const destHasAddon = fs.existsSync(path.join(projectPath, PLUGIN_REL, "plugin.cfg"));
132
183
  if (dryRun) {
133
184
  const verb = destHasAddon ? (force ? "overwrite" : "skip (already present; --force to overwrite)") : "install";
134
- say(` addon: would ${verb} → ${PLUGIN_REL}/`);
185
+ const srcNote = fromGitHub ? ` (from ${repo}@${ref})` : "";
186
+ say(` addon: would ${verb} → ${PLUGIN_REL}/${srcNote}`);
135
187
  }
136
188
  else {
189
+ if (!addonSource) {
190
+ process.stderr.write("init: internal error — no addon source resolved.\n");
191
+ return 1;
192
+ }
137
193
  const r = installAddon(addonSource, projectPath, { force });
194
+ if (tmpFetchDir)
195
+ fs.rmSync(tmpFetchDir, { recursive: true, force: true });
138
196
  say(` addon: ${r.action} → ${PLUGIN_REL}/`);
139
197
  }
140
198
  // 2. Enable it in project.godot.
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ async function main() {
43
43
  // so long jobs (export/import/headless script) support poll/await/cancel.
44
44
  // D3: also advertise resources.subscribe so clients can subscribe to
45
45
  // godot://… resources and receive notifications/resources/updated.
46
- const server = new McpServer({ name: "breakpoint-mcp", version: "1.4.0" }, { capabilities: { ...TASK_CAPABILITIES, ...RESOURCE_CAPABILITIES }, taskStore });
46
+ const server = new McpServer({ name: "breakpoint-mcp", version: "1.4.1" }, { capabilities: { ...TASK_CAPABILITIES, ...RESOURCE_CAPABILITIES }, taskStore });
47
47
  // B1: enforce frozen output schemas on every structured tool. Must run before
48
48
  // the register*Tools calls below — it wraps server.registerTool.
49
49
  applyOutputSchemas(server);
@@ -118,6 +118,8 @@ function printUsage() {
118
118
  " --client <id> Write the MCP config for a client: claude-code | claude-desktop | cursor | windsurf | vscode.",
119
119
  " --force Overwrite an addon that is already installed.",
120
120
  " --dry-run Print what would change without writing anything.",
121
+ " --from-github [ref] Fetch the editor addon from GitHub at [ref] (default: this package's version tag) instead of the bundled copy.",
122
+ " --repo <owner/repo> With --from-github, the source repo (default: jlivingston-Cipher/godot-breakpoint-mcp).",
121
123
  "",
122
124
  "doctor options:",
123
125
  " --project <dir> Project to check (default: $GODOT_PROJECT or the current directory).",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "breakpoint-mcp",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "MCP server exposing Godot to AI coding assistants over the Model Context Protocol — developed and tested with Claude — across four planes (CLI, live editor, LSP+DAP, runtime) with elicitation-gated destructive tools, long jobs on the formal MCP task model, captured console output, and MCP resources.",
5
5
  "type": "module",
6
6
  "license": "MIT",