suppa-mcp-2 1.28.0 → 1.29.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/dist/bin.js CHANGED
@@ -2,12 +2,13 @@
2
2
  /**
3
3
  * stdio entrypoint for the Suppa MCP server (npm `suppa-mcp-2`).
4
4
  *
5
- * Builds the server (all 87 tools) and connects it to stdio, exactly like the
6
- * Python package's console script. Faithful 1:1 port.
5
+ * The server is loaded through a DYNAMIC import, which looks like a detail and
6
+ * is the whole point: a static `import` is resolved before the first statement
7
+ * of this module runs, so an incomplete install killed the process before any
8
+ * handler below existed. See ./startupRepair.ts for the incident.
7
9
  */
8
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
9
- import { buildServer } from "./server.js";
10
- import { refreshLatestVersionInBackground } from "./version.js";
10
+ import { fileURLToPath } from "node:url";
11
+ import { applyRepair, planRepair, readStamp, stampPath } from "./startupRepair.js";
11
12
  // Safety net: a long-running MCP stdio server must never be killed by a stray
12
13
  // async rejection or a synchronous throw in some callback (a background token
13
14
  // refresh, an aborted login-loopback request, a write to a closed socket…).
@@ -23,8 +24,12 @@ process.on("uncaughtException", (err) => {
23
24
  process.stderr.write(`[suppa-mcp] uncaught exception (ignored): ${err instanceof Error ? err.stack || err.message : String(err)}\n`);
24
25
  });
25
26
  // Startup is the one place a failure SHOULD stop the process — if the server
26
- // can't build or connect, there's nothing to serve.
27
+ // can't build or connect, there's nothing to serve. What it must not do is stop
28
+ // without saying why.
27
29
  try {
30
+ const { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
31
+ const { buildServer } = await import("./server.js");
32
+ const { refreshLatestVersionInBackground } = await import("./version.js");
28
33
  const server = buildServer();
29
34
  await server.connect(new StdioServerTransport());
30
35
  // Only once the server is actually serving, and detached: refresh the cached
@@ -34,6 +39,16 @@ try {
34
39
  refreshLatestVersionInBackground();
35
40
  }
36
41
  catch (e) {
37
- process.stderr.write(`[suppa-mcp] fatal startup error: ${e instanceof Error ? e.stack || e.message : String(e)}\n`);
42
+ const stamp = stampPath();
43
+ const plan = planRepair({
44
+ error: e,
45
+ // A path, never import.meta.url: a file:// URL is percent-encoded and names
46
+ // no directory, and the repair planner refuses one outright.
47
+ selfPath: fileURLToPath(import.meta.url),
48
+ lastRepairAt: readStamp(stamp),
49
+ now: Date.now(),
50
+ disabled: Boolean(process.env.SUPPA_MCP_NO_CACHE_REPAIR),
51
+ });
52
+ process.stderr.write(`[suppa-mcp] ${applyRepair(plan, stamp)}\n`);
38
53
  process.exit(1);
39
54
  }
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Prove, at install time, that what just landed actually works.
3
+ *
4
+ * Two outages reached users because nothing verified the install itself:
5
+ *
6
+ * - 1.15.0 added a second bin and `npx -y suppa-mcp-2@latest` stopped being
7
+ * able to pick one. Twelve releases shipped over it. Every test drove
8
+ * dist/bin.js directly — the one path a host never takes.
9
+ * - An interrupted npx download left the package without ajv. The server died
10
+ * during module resolution, so the host reported CONNECT_TIMEOUT and
11
+ * Server disconnected, as though the server had crashed rather than never
12
+ * having run.
13
+ *
14
+ * Both are invisible to a unit test and obvious to a smoke test: start the
15
+ * thing as a host starts it, and ask it to speak MCP. That is all this does.
16
+ *
17
+ * IT NEVER FAILS AN INSTALL. A package that refuses to install is a worse
18
+ * outcome than one that installs and complains, and this runs in sandboxes,
19
+ * offline boxes and CI images where spawning a child may be restricted. Every
20
+ * path here ends in a report, never a throw.
21
+ */
22
+ import { spawn } from "node:child_process";
23
+ import { existsSync } from "node:fs";
24
+ import { join } from "node:path";
25
+ /** Every bin the manifest declares, and whether its file is actually there. */
26
+ export function checkBins(pkg, root, exists = existsSync) {
27
+ return Object.entries(pkg.bin ?? {}).map(([name, target]) => ({
28
+ name,
29
+ target,
30
+ present: exists(join(root, target)),
31
+ }));
32
+ }
33
+ /** Read the package a module-resolution failure was about, out of stderr. */
34
+ export function missingModuleFrom(stderr) {
35
+ const m = /Cannot find (?:package|module) ['"]([^'"]+)['"]/.exec(stderr);
36
+ if (m)
37
+ return m[1];
38
+ // startupRepair's own wording, when the server got far enough to explain
39
+ // itself rather than dying on a bare Node stack.
40
+ const own = /could not resolve ([^.\s]+)/.exec(stderr);
41
+ return own ? own[1] : undefined;
42
+ }
43
+ /**
44
+ * Start the server exactly as an MCP host does and hold a real conversation:
45
+ * initialize, then tools/list. Answers the three questions that matter — does
46
+ * it start, does it speak the protocol, and are the tools there.
47
+ */
48
+ export function smokeTest(binPath, timeoutMs = 25_000) {
49
+ return new Promise((resolve) => {
50
+ let child;
51
+ try {
52
+ child = spawn(process.execPath, [binPath], {
53
+ stdio: ["pipe", "pipe", "pipe"],
54
+ env: {
55
+ ...process.env,
56
+ // Nothing here may touch the network during an install.
57
+ SUPPA_MCP_NO_UPDATE_CHECK: "1",
58
+ // Critical: the child must NOT try to repair a broken npx cache while
59
+ // npm is still writing into that very directory. A self-check that
60
+ // deletes the package mid-install would be far worse than the fault
61
+ // it is checking for.
62
+ SUPPA_MCP_NO_CACHE_REPAIR: "1",
63
+ },
64
+ });
65
+ }
66
+ catch (e) {
67
+ resolve({ ok: false, error: e instanceof Error ? e.message : String(e) });
68
+ return;
69
+ }
70
+ let out = "";
71
+ let err = "";
72
+ let settled = false;
73
+ const finish = (r) => {
74
+ if (settled)
75
+ return;
76
+ settled = true;
77
+ clearTimeout(timer);
78
+ try {
79
+ child.kill();
80
+ }
81
+ catch {
82
+ /* already gone */
83
+ }
84
+ resolve(r);
85
+ };
86
+ const timer = setTimeout(() => finish({ ok: false, error: `no answer within ${Math.round(timeoutMs / 1000)}s` }), timeoutMs);
87
+ let version;
88
+ child.stdout?.on("data", (d) => {
89
+ out += String(d);
90
+ let nl;
91
+ while ((nl = out.indexOf("\n")) !== -1) {
92
+ const line = out.slice(0, nl).trim();
93
+ out = out.slice(nl + 1);
94
+ if (!line)
95
+ continue;
96
+ let msg;
97
+ try {
98
+ msg = JSON.parse(line);
99
+ }
100
+ catch {
101
+ continue;
102
+ }
103
+ if (msg.id === 1) {
104
+ const info = msg.result?.serverInfo;
105
+ version = info?.version;
106
+ child.stdin?.write(JSON.stringify({ jsonrpc: "2.0", method: "notifications/initialized" }) + "\n");
107
+ child.stdin?.write(JSON.stringify({ jsonrpc: "2.0", id: 2, method: "tools/list", params: {} }) + "\n");
108
+ }
109
+ else if (msg.id === 2) {
110
+ const tools = msg.result?.tools ?? [];
111
+ finish({ ok: true, version, tools: tools.length });
112
+ }
113
+ }
114
+ });
115
+ child.stderr?.on("data", (d) => (err += String(d)));
116
+ child.on("error", (e) => finish({ ok: false, error: e.message }));
117
+ child.on("exit", (code) => finish({
118
+ ok: false,
119
+ missingModule: missingModuleFrom(err),
120
+ error: `exited with code ${code} before answering` + (err.trim() ? `: ${err.trim().slice(0, 300)}` : ""),
121
+ }));
122
+ child.stdin?.write(JSON.stringify({
123
+ jsonrpc: "2.0",
124
+ id: 1,
125
+ method: "initialize",
126
+ params: {
127
+ protocolVersion: "2024-11-05",
128
+ capabilities: {},
129
+ clientInfo: { name: "suppa-mcp-selfcheck", version: "1" },
130
+ },
131
+ }) + "\n");
132
+ });
133
+ }
134
+ /**
135
+ * What the operator reads. Pure, so the wording is pinned by tests rather than
136
+ * discovered in the middle of somebody's install.
137
+ */
138
+ export function report(o) {
139
+ const missingBins = o.bins.filter((b) => !b.present);
140
+ const lines = [];
141
+ if (missingBins.length) {
142
+ lines.push(`suppa-mcp-2: INSTALL IS INCOMPLETE — ${missingBins
143
+ .map((b) => b.target)
144
+ .join(", ")} missing. The download was truncated.`);
145
+ }
146
+ if (o.smoke.ok) {
147
+ if (o.smoke.version && o.smoke.version !== o.expectedVersion) {
148
+ lines.push(`suppa-mcp-2: self-check ran ${o.smoke.version} but this package is ` +
149
+ `${o.expectedVersion} — an older copy is shadowing it on the module path.`);
150
+ return { ok: false, lines };
151
+ }
152
+ if (!missingBins.length) {
153
+ lines.push(`suppa-mcp-2: self-check ok — v${o.smoke.version}, ${o.smoke.tools} tools.`);
154
+ return { ok: true, lines };
155
+ }
156
+ return { ok: false, lines };
157
+ }
158
+ lines.push("suppa-mcp-2: THE SERVER DID NOT START — " +
159
+ (o.smoke.missingModule
160
+ ? `could not resolve ${o.smoke.missingModule}. This is a truncated download.`
161
+ : (o.smoke.error ?? "unknown reason")));
162
+ lines.push(" A host would show this as CONNECT_TIMEOUT or 'Server disconnected', which looks " +
163
+ "like a crash but means the server never ran.");
164
+ lines.push(" Fix: npm cache clean --force && npm install suppa-mcp-2 --force " +
165
+ "(for npx, delete the _npx/<hash> directory the error names and rerun).");
166
+ return { ok: false, lines };
167
+ }
168
+ /** Run everything against an installed package root. Never throws. */
169
+ export async function runSelfCheck(root, pkg) {
170
+ const bins = checkBins(pkg, root);
171
+ const entry = join(root, "dist", "bin.js");
172
+ if (!existsSync(entry)) {
173
+ // A source checkout before its first build. Not a fault, and not ours to
174
+ // report on.
175
+ return { ok: true, lines: [] };
176
+ }
177
+ const smoke = await smokeTest(entry);
178
+ return report({ bins, smoke, expectedVersion: String(pkg.version ?? "") });
179
+ }
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * The self-check as a command, so postinstall can run it in a child process and
4
+ * a user can run it by hand: `node dist/selfcheckCli.js`.
5
+ *
6
+ * A separate file from selfcheck.ts on purpose — importing a module must never
7
+ * start a server as a side effect.
8
+ *
9
+ * Exit code is 0 on success and 1 on a finding, but the postinstall that calls
10
+ * it ignores that: the code is here for anyone scripting around it.
11
+ */
12
+ import { readFileSync } from "node:fs";
13
+ import { dirname, join, resolve } from "node:path";
14
+ import { fileURLToPath } from "node:url";
15
+ import { runSelfCheck } from "./selfcheck.js";
16
+ const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
17
+ let pkg = {};
18
+ try {
19
+ pkg = JSON.parse(readFileSync(join(ROOT, "package.json"), "utf-8"));
20
+ }
21
+ catch {
22
+ process.stderr.write("suppa-mcp-2: self-check could not read package.json; skipped.\n");
23
+ process.exit(0);
24
+ }
25
+ const { ok, lines } = await runSelfCheck(ROOT, pkg);
26
+ for (const line of lines)
27
+ process.stderr.write(line + "\n");
28
+ process.exit(ok ? 0 : 1);
@@ -0,0 +1,175 @@
1
+ /**
2
+ * A truncated install, made to say so — and to fix itself.
3
+ *
4
+ * A host reported CONNECT_TIMEOUT and CONNECTION_CLOSED on a server that was
5
+ * never reached: npx had left an INCOMPLETE package in its cache, and Node
6
+ * failed to resolve a transitive dependency (ajv, via the MCP SDK).
7
+ *
8
+ * ERR_MODULE_NOT_FOUND: Cannot find package
9
+ * '.../_npx/e5adf329fab52150/node_modules/ajv/dist/ajv.js'
10
+ *
11
+ * bin.ts already had three guards — unhandledRejection, uncaughtException and a
12
+ * try/catch around startup — and NONE of them could fire. Module resolution
13
+ * happens before the first statement of an ES module runs, so the process died
14
+ * before a single handler was installed. The operator got a bare Node stack on
15
+ * a stream most hosts do not surface, and a closed pipe. Hence bin.ts now loads
16
+ * the server through a dynamic import, and that catch lands here.
17
+ *
18
+ * WHY THIS DOES NOT SIMPLY CLEAN THE CACHE. Clearing on every start would cost
19
+ * a full re-download each launch (~11 s against ~0.4 s warm), make an offline
20
+ * start impossible, and `npm cache clean` would take every OTHER package's
21
+ * cache with it. Worse, _npx/<hash> is the directory this process is running
22
+ * FROM. So the rule is: act only on a failure that has already happened, only
23
+ * on our own cache directory, and never on anything else.
24
+ */
25
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
26
+ import { dirname, join } from "node:path";
27
+ import { tmpdir } from "node:os";
28
+ /** Written as a constant so no regex in this file needs a backslash escape. */
29
+ const BACKSLASH = String.fromCharCode(92);
30
+ /** How long after a repair we refuse to repair again. */
31
+ export const REPAIR_COOLDOWN_MS = 60_000;
32
+ /** Where the last repair is stamped, so an auto-restarting host cannot loop. */
33
+ export function stampPath() {
34
+ return join(tmpdir(), "suppa-mcp-last-cache-repair");
35
+ }
36
+ /**
37
+ * The package or file a module-resolution failure was about, or null when the
38
+ * error is something else — in which case nothing in this file applies.
39
+ */
40
+ export function missingModule(err) {
41
+ const e = err;
42
+ if (!e)
43
+ return null;
44
+ if (e.code !== "ERR_MODULE_NOT_FOUND" && e.code !== "MODULE_NOT_FOUND")
45
+ return null;
46
+ const quoted = /Cannot find (?:package|module) ['"]([^'"]+)['"]/.exec(String(e.message ?? ""));
47
+ return quoted ? quoted[1] : "(unnamed module)";
48
+ }
49
+ /**
50
+ * The `_npx/<hash>` directory a path sits in, or null.
51
+ *
52
+ * This is the safety boundary of the whole file: it answers with a directory
53
+ * ONLY for a path running through an `_npx` segment followed by a hex hash. A
54
+ * global install, a repo checkout, a plain node_modules, and a hand-made folder
55
+ * called `_npx/mystuff` all answer null — and null means nothing is deleted.
56
+ */
57
+ export function npxCacheDir(fromPath) {
58
+ if (!fromPath)
59
+ return null;
60
+ // A file:// URL is not a path, and its percent-encoding (ANDRII%7E1.HER) does
61
+ // not name a real directory. Passing one here once produced a confident
62
+ // "Removed the broken cache directory file:///C:/..." for a removal that
63
+ // never happened, so this refuses rather than guesses: callers convert with
64
+ // fileURLToPath first.
65
+ if (/^[a-z][a-z0-9+.-]*:\/\//i.test(fromPath))
66
+ return null;
67
+ const parts = fromPath.split(BACKSLASH).join("/").split("/");
68
+ const i = parts.indexOf("_npx");
69
+ if (i < 0)
70
+ return null;
71
+ const hash = parts[i + 1];
72
+ if (!hash || !/^[0-9a-f]{8,}$/i.test(hash))
73
+ return null;
74
+ // Slice the ORIGINAL string: splitting and joining on single characters
75
+ // preserves length, so this index maps back exactly and the caller's own
76
+ // separators survive untouched.
77
+ return fromPath.slice(0, parts.slice(0, i + 2).join("/").length);
78
+ }
79
+ /**
80
+ * Decide what to do about a startup failure. Pure — it reads nothing and
81
+ * removes nothing, so every branch is testable without a filesystem.
82
+ */
83
+ export function planRepair(o) {
84
+ const missing = missingModule(o.error);
85
+ if (!missing) {
86
+ const e = o.error;
87
+ return {
88
+ dir: null,
89
+ message: `fatal startup error: ${e instanceof Error ? e.stack || e.message : String(e)}`,
90
+ };
91
+ }
92
+ // The error names the file it could not resolve, which locates the broken
93
+ // install better than our own path does. Fall back to where we are running.
94
+ const dir = npxCacheDir(missing) ?? npxCacheDir(o.selfPath);
95
+ const head = `the installed package is INCOMPLETE — could not resolve ${missing}. ` +
96
+ "This is a truncated download, not a server fault.";
97
+ if (!dir) {
98
+ return {
99
+ dir: null,
100
+ message: head +
101
+ " Not running from an npx cache, so nothing was removed. Reinstall the package " +
102
+ "(npm install suppa-mcp-2 --force) and start it again.",
103
+ };
104
+ }
105
+ if (o.disabled) {
106
+ return {
107
+ dir: null,
108
+ message: head + ` Automatic repair is off (SUPPA_MCP_NO_CACHE_REPAIR). Remove ${dir} by hand.`,
109
+ };
110
+ }
111
+ if (o.lastRepairAt !== null && o.now - o.lastRepairAt < REPAIR_COOLDOWN_MS) {
112
+ // A host that restarts a failing server would otherwise re-download the
113
+ // whole package every few seconds, forever.
114
+ return {
115
+ dir: null,
116
+ message: head +
117
+ ` A repair was made moments ago and did not help, so ${dir} was left alone. ` +
118
+ "Something other than the cache is wrong — check disk space and permissions.",
119
+ };
120
+ }
121
+ return {
122
+ dir,
123
+ message: head +
124
+ ` Removed the broken cache directory ${dir}. Restart the server: the next launch ` +
125
+ "downloads it again cleanly.",
126
+ };
127
+ }
128
+ /** The moment of the last repair, or null when there is none we can trust. */
129
+ export function readStamp(path) {
130
+ try {
131
+ const n = Number(readFileSync(path, "utf-8").trim());
132
+ return Number.isFinite(n) ? n : null;
133
+ }
134
+ catch {
135
+ return null;
136
+ }
137
+ }
138
+ /**
139
+ * Carry out a plan. A failed removal is neither fatal nor hidden: on Windows a
140
+ * file belonging to the running process can be locked, and the operator still
141
+ * needs the path so they can remove it themselves.
142
+ */
143
+ export function applyRepair(plan, stamp = stampPath(),
144
+ // Injectable so the "removal did not take" branch is reachable from a test.
145
+ // On Windows that branch is a locked file, which cannot be staged reliably.
146
+ io = { rm: rmSync, exists: existsSync }) {
147
+ if (!plan.dir)
148
+ return plan.message;
149
+ if (!io.exists(plan.dir)) {
150
+ // rmSync({force: true}) treats a missing path as success, so without this
151
+ // the server would report a removal it did not perform — which is how a
152
+ // file:// URL slipped through review once.
153
+ return (`the installed package is INCOMPLETE and ${plan.dir} is not a directory on ` +
154
+ "this machine, so nothing was removed. Reinstall the package and start again.");
155
+ }
156
+ try {
157
+ io.rm(plan.dir, { recursive: true, force: true });
158
+ }
159
+ catch (e) {
160
+ return (`the installed package is INCOMPLETE. Could not remove ${plan.dir} ` +
161
+ `(${e instanceof Error ? e.message : String(e)}). Remove it by hand and start again.`);
162
+ }
163
+ if (io.exists(plan.dir)) {
164
+ return (`the installed package is INCOMPLETE and ${plan.dir} could not be fully removed ` +
165
+ "(files still in use). Remove it by hand and start the server again.");
166
+ }
167
+ try {
168
+ mkdirSync(dirname(stamp), { recursive: true });
169
+ writeFileSync(stamp, String(Date.now()), "utf-8");
170
+ }
171
+ catch {
172
+ // A missing stamp costs only the loop guard; the repair itself is done.
173
+ }
174
+ return plan.message;
175
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suppa-mcp-2",
3
- "version": "1.28.0",
3
+ "version": "1.29.0",
4
4
  "description": "MCP server for the Suppa platform (modern.suppa.me) — Tasks, Docs/Pages, Entities & Schema, Forms, Automations, and file attachments, with multi-tenant Google auth. Node port of PyPI suppa-mcp.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,12 +20,17 @@
20
20
  * @suppa/sdk dependency and no *.entity.ts. A package install is not
21
21
  * permission to configure an unrelated project.
22
22
  *
23
+ * EVERYTHING HERE WRITES TO STDERR. Under `npx -y suppa-mcp-2`, npm installs
24
+ * and then execs the server on the SAME stdio the MCP host is connected to,
25
+ * so a line of install chatter on stdout lands in the middle of the JSON-RPC
26
+ * stream. Diagnostics belong on stderr; stdout belongs to the protocol.
27
+ *
23
28
  * It also never fails an install: whatever happens, this exits 0. A package
24
29
  * that cannot be added because its postinstall threw is worse than a repo
25
30
  * without hooks.
26
31
  */
27
32
 
28
- import { execFileSync } from "node:child_process";
33
+ import { execFileSync, spawnSync } from "node:child_process";
29
34
  import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
30
35
  import { dirname, join, resolve } from "node:path";
31
36
  import { fileURLToPath } from "node:url";
@@ -36,7 +41,7 @@ const PACKAGE_ROOT = resolve(HERE, "..", "..", "..");
36
41
 
37
42
  /** Say why nothing happened, but only where a reader would wonder. */
38
43
  function skip(reason, loud = false) {
39
- if (loud) process.stdout.write(`suppa-mcp-2: entity-code guards not installed — ${reason}\n`);
44
+ if (loud) process.stderr.write(`suppa-mcp-2: entity-code guards not installed — ${reason}\n`);
40
45
  process.exit(0);
41
46
  }
42
47
 
@@ -102,6 +107,41 @@ function looksLikeSuppaApp(root) {
102
107
  return walk(root, 0);
103
108
  }
104
109
 
110
+ /**
111
+ * Before anything else: did this package actually arrive intact?
112
+ *
113
+ * This runs on EVERY install — CI, global, a repo with no Suppa code — because
114
+ * unlike the guards below it is about this package, not about the repo that
115
+ * pulled it in. Two outages reached users through exactly this gap: a bin npx
116
+ * could not choose, and an interrupted download missing ajv. Both would have
117
+ * been caught here, before a host ever tried to start the server.
118
+ *
119
+ * It never fails the install and never propagates: a package that refuses to
120
+ * install is worse than one that installs and says what is wrong.
121
+ */
122
+ function selfCheck() {
123
+ if (process.env.SUPPA_MCP_NO_SELFTEST) return;
124
+ const cli = join(PACKAGE_ROOT, "dist", "selfcheckCli.js");
125
+ if (!existsSync(cli)) return; // a source checkout before its first build
126
+ // spawnSync, not execFileSync: the report comes back on the child's STDERR
127
+ // (stdout belongs to the MCP protocol), and execFileSync hands back stderr
128
+ // only when the child fails. Reading the wrong stream made this silent.
129
+ const r = spawnSync(process.execPath, [cli], {
130
+ cwd: PACKAGE_ROOT,
131
+ encoding: "utf-8",
132
+ timeout: 60_000,
133
+ });
134
+ const said = String(r.stderr ?? "") + String(r.stdout ?? "");
135
+ if (said.trim()) {
136
+ process.stderr.write(said.endsWith("\n") ? said : said + "\n");
137
+ } else if (r.error) {
138
+ process.stderr.write(
139
+ `suppa-mcp-2: self-check could not run (${r.error.message.split("\n")[0]}).\n`,
140
+ );
141
+ }
142
+ }
143
+ selfCheck();
144
+
105
145
  try {
106
146
  if (process.env.SUPPA_NO_GUARD_INSTALL) skip("SUPPA_NO_GUARD_INSTALL is set");
107
147
  if (process.env.CI) skip("running in CI");
@@ -145,16 +185,16 @@ try {
145
185
  const needsAttention = out
146
186
  .split("\n")
147
187
  .filter((l) => l.trimStart().startsWith("·") && !noise.test(l));
148
- process.stdout.write(
188
+ process.stderr.write(
149
189
  "suppa-mcp-2: entity-code guards in place (agent hooks, AGENTS.md/CLAUDE.md, pre-commit, " +
150
190
  "CI job, npm run schema:gate). SUPPA_NO_GUARD_INSTALL=1 turns this off; " +
151
191
  "`npx suppa-entity-guards .` re-runs it.\n",
152
192
  );
153
- for (const line of needsAttention) process.stdout.write(` ${line.trim()}\n`);
193
+ for (const line of needsAttention) process.stderr.write(` ${line.trim()}\n`);
154
194
  } catch (e) {
155
195
  // An install that cannot be completed is a worse outcome than a repo without
156
196
  // hooks, so this never propagates.
157
- process.stdout.write(
197
+ process.stderr.write(
158
198
  `suppa-mcp-2: could not install the entity-code guards (${
159
199
  e instanceof Error ? e.message.split("\n")[0] : String(e)
160
200
  }). Run \`npx suppa-entity-guards .\` when convenient.\n`,