@yawlabs/mcp 1.0.6 → 1.0.8

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/CHANGELOG.md CHANGED
@@ -4,6 +4,32 @@ All notable changes to `@yawlabs/mcp` (formerly `@yawlabs/mcph`) are documented
4
4
 
5
5
  ## Unreleased -- a fresh Yaw Mode pane names the local-scope entry it will lose
6
6
 
7
+ **Added -- `YAW_MCP_READONLY_DIAGNOSTICS=1` runs `doctor` and `bundles` without writing anything**
8
+
9
+ Yaw Terminal's MCP panel runs `yaw-mcp doctor --json`, `status --json` and `bundles list --json` on every refresh, and `doctor` is not read-only. It sweeps expired `yaw-mcp try` trials: a read-modify-write of each client config the trial was wired into (`~/.claude.json` among them), taken with no lock against the client that owns the file, which drops a UTF-8 BOM and adds a trailing newline on the way through. It also renames a pre-0.12 `~/.yaw-mcp.json` or project `.yaw-mcp.json` / `.yaw-mcp.local.json` into `.yaw-mcp/` as part of loading config, and so does `bundles match`. A refresh the user did not ask for should not do either.
10
+
11
+ With the variable set (`1` or `true` in any case, surrounding whitespace ignored -- the spellings `YAW_MCP_AUTO_LOAD`, `YAW_MCP_FOUNDRY` and `YAW_MCP_REWARD_GRADER` take):
12
+
13
+ - `doctor`, text and `--json`, does not run the trial sweep. It still scans the trials. An expired one is not listed as live and not dropped: each becomes a warning -- ``trial "<slug>": expired but not swept -- YAW_MCP_READONLY_DIAGNOSTICS is set, so this run edits no client config, and its entry may still be wired into <path>; run `yaw-mcp doctor` with YAW_MCP_READONLY_DIAGNOSTICS unset to sweep it, or `yaw-mcp try-cleanup <slug>` `` -- so the run exits 2, the same as for an expired trial the sweep could not remove. TRIALS prints a count and points at WARNINGS.
14
+ - `doctor` and `bundles match` do not migrate a legacy config file. Each file the migration would have moved is a warning instead, naming the file and where the next ordinary run moves it, because the settings in it are not part of that report. The check runs the migrator's own walk and per-file checks, so it names exactly the files a real run would move.
15
+ - `status` and `bundles list` wrote nothing before and write nothing now.
16
+
17
+ **`doctor --json` gains fields only on a run with the variable set**: a top-level `"readOnly": true`, and `trials.unswept` (`{ slug, clientName, clientPath, markerPath, msSinceExpiry }` per expired trial left in place, possibly empty) with `trials.sweepHint` (one display sentence naming both commands, or `null`). Without the variable, `doctor` (text and `--json`), `bundles` and `status` behave and print exactly as before: the trial sweep and the migration still run, and none of the new fields, lines or warnings appear. The variable is not listed in doctor's ENVIRONMENT section, because its 28-character name would re-pad every line of that section on every ordinary run. A run with it set prints `mode: read-only (YAW_MCP_READONLY_DIAGNOSTICS is set) -- no trial sweep, no config migration` under the header instead.
18
+
19
+ The broker never reads the variable. Its startup config load still migrates legacy files even when the variable has leaked into a client's environment, because it is the process that folds them in.
20
+
21
+ **Added -- a startup pre-warm of `npx -y <pkg>@latest` servers so the first `initialize` of a session does not pay the cold-cache tax**
22
+
23
+ A server entry shaped `{ command: "npx", args: ["-y", "@yawlabs/<x>-mcp@latest"] }` resolves `@latest` on every spawn. On a fresh `~/.npm/_npx/` cache -- which npm keeps per-tarball-URL hash and so flushes whenever a package publishes a new build -- the first spawn does a registry round-trip + a tar download + the child's own `initialize`. Together that is reliably >30s, which exceeds the downstream MCP client's `initialize` deadline and surfaces as the user-visible line "MCP request initialize to server mcp timed out after 30000ms". yaw-mcp's own `MCP_CONNECT_TIMEOUT` is 15s by default, so the user loses the activation AND yaw-mcp spends 15s in the attempt before giving up.
24
+
25
+ `prewarmDormantServers` (the existing startup pre-warm) does spawn each server at startup, but (a) it fires from `oninitialized`, so the FIRST activation of the session still pays the cold-cache cost -- the user only sees the win on the second server and onwards, and on the second session onwards; (b) it is gated on `YAW_MCP_PREWARM`, which a user with no pre-warm tolerance can turn off and would not want re-lit by a different knob; and (c) it spawns the full upstream, not just the npx cache prime.
26
+
27
+ A new fire-and-forget pass on `start()` runs `npx -y <pkg>@latest --version` once per unique configured npx package, in parallel, with a 30s per-package timeout (the same 30s as the client deadline -- a prime that takes longer than the budget it is trying to buy back is not earning its keep). The next real `StdioClientTransport` spawn finds a warm cache and connects in well under a second. The pass is no-op when the user has no npx servers or opts out (`YAW_MCP_AUTO_PREWARM=0`), is capped at `YAW_MCP_MAX_AUTO_PREWARM` (default 20, so a metered connection's worst case is bounded), and shares `acquireSidecarsLock` with `maybeRefreshSidecars` so a manual `sidecars install` running at startup defers this pass and vice versa.
28
+
29
+ The spawn mirrors `maybeAutoUpgrade`'s env hygiene (`stripInternalSecretsFromEnv(process.env)` so the vault passphrase never reaches an npx child's transitive pre/postinstall), `stdio: "ignore"` so a slow child cannot wedge the parent, and `shell: process.platform === "win32"` so the npx `.cmd` shim resolves. The new `auto-prewarm.ts` module is a sibling of `auto-upgrade.ts` and `sidecar-refresh.ts`; the public surface is `maybeAutoPrewarmNpxCache(deps)`, plus the pure parsers `isAutoPrewarmDisabled`, `parseAutoPrewarmMax`, `parseAutoPrewarmTimeoutMs` and the pure extractor `extractNpxPackages`, all exported for tests and `doctor`.
30
+
31
+ **The "first activation" caveat remains for the rare user who skips a pre-warm**: a user on a metered link who sets `YAW_MCP_AUTO_PREWARM=0` and then activates a never-touched-before npx server on a cold `_npx` cache still gets the >30s first-spawn tax. There is no on-demand warm without paying the same tax once, and the only way to remove that case would be a one-time payment on the user's first `activate` of the session -- which IS the cold-cache race, just hidden behind a different layer.
32
+
7
33
  **Fixed -- a fresh Yaw Mode pane warns about a local-scope Claude Code entry, and the augment Keeping line stops promising the entry goes home**
8
34
 
9
35
  In a fresh Yaw Mode pane, `install claude-code --scope local` wrote the entry into the overlay's `.claude.json` -- `projects[<dir>]` lives in `<CLAUDE_CONFIG_DIR>/.claude.json`, and a fresh pane keeps nothing of its overlay -- and said nothing about it. It now prints: ``Note: a fresh Yaw Mode pane does not keep its config dir, so the Claude Code entry in <overlay>/.claude.json goes when this pane closes. Run `yaw-mcp install claude-code --scope local --project-dir <dir>` from a normal shell to keep it.``
package/README.md CHANGED
@@ -1,12 +1,10 @@
1
1
  # @yawlabs/mcp
2
2
 
3
- [![Follow @TokenLimitNews on X](https://img.shields.io/badge/follow-%40TokenLimitNews-000000?logo=x&logoColor=white)](https://x.com/TokenLimitNews)
4
-
5
3
  **One install. Every MCP server. Managed from one place.**
6
4
 
7
5
  Yaw MCP (the `yaw-mcp` CLI) is an MCP server that fronts every other MCP server you use. Point each AI client (Claude Code, Claude Desktop, Cursor, VS Code) at it once, and your servers load lazily from a single connection instead of a hand-edited `mcpServers` block per client.
8
6
 
9
- It runs entirely on your machine. No account, no sign-in, no telemetry -- your servers live in a local `bundles.json` and your credentials in a local encrypted vault. Running as an MCP server, its only outbound calls are two background npm checks: one for its own updates (`YAW_MCP_AUTO_UPGRADE=0` to disable), and, if you have run `yaw-mcp sidecars install`, a once-a-day check that the managed sidecar packages are current (`YAW_MCP_SIDECAR_REFRESH=0` to disable). `yaw-mcp add` fetches the public server catalog on demand. Nothing else leaves your machine.
7
+ It runs entirely on your machine. No account, no sign-in, no telemetry -- your servers live in a local `bundles.json` and your credentials in a local encrypted vault. Running as an MCP server, its only outbound calls are three background npm checks: one for its own updates (`YAW_MCP_AUTO_UPGRADE=0` to disable), a once-per-startup pre-warm of `npx -y <pkg>@latest` servers so the first activation does not pay the cold-cache tax (`YAW_MCP_AUTO_PREWARM=0` to disable), and, if you have run `yaw-mcp sidecars install`, a once-a-day check that the managed sidecar packages are current (`YAW_MCP_SIDECAR_REFRESH=0` to disable). `yaw-mcp add` fetches the public server catalog on demand. Nothing else leaves your machine.
10
8
 
11
9
  It earns its keep when you hit any of these:
12
10
 
@@ -409,6 +407,9 @@ Common ones (run `yaw-mcp --help` for the full list):
409
407
  | `YAW_MCP_AUTO_UPGRADE` | `0` disables the background self-upgrade check at startup. Default on. |
410
408
  | `YAW_MCP_SIDECAR_REFRESH` | `0` disables the daily background check that keeps managed sidecars current. Only ever runs if you have run `yaw-mcp sidecars install`; explicit pins and semver ranges are never moved. Default on. |
411
409
  | `YAW_MCP_PREWARM` | `0` stops yaw-mcp spawning a server at startup just to learn its tool list. Learning is rare -- the list persists and is only re-learned once it ages out -- but the session that does it starts the upstream twice, once to read the list and once for the activate that follows, which matters if the server startup is not idempotent. Off, a server whose tools are not already known shows none of them until you activate it; `discover` still lists it. Default on. |
410
+ | `YAW_MCP_AUTO_PREWARM` | `0` disables the once-per-startup `npx -y <pkg>@latest` cache pre-warm that primes `~/.npm/_npx/<hash>/node_modules/<pkg>` for every active npx server. The pre-warm runs `npx ... --version` once per unique package in parallel, in a 30s budget per package, and resolves before the user's first `initialize` for that server lands. Without it, a fresh `_npx` cache makes a single spawn do a registry round-trip + a tar download + the child's own initialize -- reliably >30s, which exceeds the MCP client's `initialize` deadline and surfaces as "MCP request initialize to server mcp timed out after 30000ms". Default on. |
411
+ | `YAW_MCP_MAX_AUTO_PREWARM` | Upper bound on the number of npx packages the pre-warm will touch in a single startup. Default `20`. Real curated bundles use 6-10; the cap bounds worst-case download volume on a metered connection. |
412
+ | `YAW_MCP_AUTO_PREWARM_TIMEOUT` | Per-package timeout in milliseconds. Default `30000`. The whole pass runs in parallel, so the global wall-clock upper bound is the same. Lower this on a tight network; raise it for a slow registry. |
412
413
  | `OAM_BIN` | Path to the `oam` binary to use instead of the one on `PATH`. A path that does not exist is reported by `doctor` as an unusable oam (fix the variable), not as oam being absent. |
413
414
  | `OAM_MAX_HEAP_MB` | Raises the V8 heap cap oam applies to a hosted server (4 GiB by default since oam 0.9.2). Set it in that server's `env` when a hosted sidecar dies with a heap out-of-memory error, or give that server `"runtime": "node"`. |
414
415
  | `YAW_MCP_AUTO_LOAD` | `1` pre-activates the top recurring pack at startup (needs persistence). Default off. |
@@ -420,6 +421,7 @@ Common ones (run `yaw-mcp --help` for the full list):
420
421
  | `MCP_CALL_TIMEOUT` | Milliseconds to wait for a single proxied `tools/call`. Default `60000` (the SDK's own bound); raise it for legitimately slow servers. Same `1..2147483647` whole-millisecond parse, invalid values fall back with one warn. |
421
422
  | `YAW_MCP_IDLE_THRESHOLD` | Non-matching tool calls a loaded server tolerates before it is unloaded. Default `10`; bursty servers earn more patience automatically. The older name `MCP_CONNECT_IDLE_THRESHOLD` still works as a fallback. |
422
423
  | `YAW_MCP_DISABLE_PERSISTENCE` | `1` keeps learning + pack history process-scoped (CI, containers). Default off. |
424
+ | `YAW_MCP_READONLY_DIAGNOSTICS` | `1` makes `doctor` (text and `--json`) and `bundles` write nothing, for a caller that runs them in the background on a timer. `doctor` still scans `yaw-mcp try` trials but does not sweep expired ones out of your client configs: each is reported as a warning (so the run exits 2) and listed in `--json`'s `trials.unswept`, with `trials.sweepHint` naming the fix -- a plain `yaw-mcp doctor` with the variable unset, or `yaw-mcp try-cleanup <slug>`. A pre-0.12 `~/.yaw-mcp.json` or project `.yaw-mcp.json` / `.yaw-mcp.local.json` is not moved into `.yaw-mcp/`; each is reported as a warning instead (its settings are not loaded for that run). `--json` carries `"readOnly": true` on such a run. `status` never writes, so it is unaffected. Default off. |
423
425
  | `LOG_LEVEL` | `debug` \| `info` \| `warn` \| `error`. Default `info`. |
424
426
 
425
427
  ## Requirements
@@ -439,3 +441,4 @@ The source is published so you can read and audit it before running it -- `yaw-m
439
441
  - [@yawlabs/mcp-compliance](https://www.npmjs.com/package/@yawlabs/mcp-compliance) -- test your MCP servers for spec compliance
440
442
  - [CHANGELOG](./CHANGELOG.md) -- release notes
441
443
  - [GitHub](https://github.com/YawLabs/mcp) -- source and issues
444
+ - [![Follow @TokenLimitNews on X](https://img.shields.io/badge/follow-%40TokenLimitNews-000000?logo=x&logoColor=white)](https://x.com/TokenLimitNews)
@@ -9,7 +9,7 @@ import {
9
9
  readCheckMemo,
10
10
  recordAttemptAt,
11
11
  writeCheckMemo
12
- } from "./chunk-FP6ABRPZ.js";
12
+ } from "./chunk-A73UTVAV.js";
13
13
  export {
14
14
  acquireUpgradeLock,
15
15
  attemptedRecentlyAt,
@@ -4415,7 +4415,7 @@ async function oamFloorLines(probe) {
4415
4415
  }
4416
4416
  async function defaultRunningPrefix(argvPath) {
4417
4417
  if (process.env.VITEST) return null;
4418
- const { detectRunningInstallPrefix: detectRunningInstallPrefix2 } = await import("./auto-upgrade-RHEVUE4T.js");
4418
+ const { detectRunningInstallPrefix: detectRunningInstallPrefix2 } = await import("./auto-upgrade-I24ES4PC.js");
4419
4419
  return detectRunningInstallPrefix2(argvPath);
4420
4420
  }
4421
4421
  async function defaultSpawn(cmd, args, cwd) {
@@ -4476,7 +4476,7 @@ async function runUpgrade(opts = {}) {
4476
4476
  if (method === "global-npm") {
4477
4477
  const rawPrefix = await (opts.runningPrefix ?? defaultRunningPrefix)(argvPath);
4478
4478
  if (rawPrefix !== null) {
4479
- const { quoteArgForDisplay: quoteArgForDisplay2, quoteShellArgIfNeeded: quoteShellArgIfNeeded2 } = await import("./auto-upgrade-RHEVUE4T.js");
4479
+ const { quoteArgForDisplay: quoteArgForDisplay2, quoteShellArgIfNeeded: quoteShellArgIfNeeded2 } = await import("./auto-upgrade-I24ES4PC.js");
4480
4480
  const spawnForm = quoteShellArgIfNeeded2(rawPrefix, opts.platform);
4481
4481
  const displayForm = quoteArgForDisplay2(rawPrefix, opts.platform);
4482
4482
  if (spawnForm !== null && displayForm !== null) {
@@ -4593,7 +4593,7 @@ async function runUpgrade(opts = {}) {
4593
4593
  return { exitCode: 3, lines };
4594
4594
  }
4595
4595
  function readCurrentVersion() {
4596
- return true ? "1.0.6" : "dev";
4596
+ return true ? "1.0.8" : "dev";
4597
4597
  }
4598
4598
 
4599
4599
  // src/auto-upgrade.ts
@@ -4875,7 +4875,7 @@ function defaultSpawn2(cmd, args, onDone = () => {
4875
4875
  async function maybeAutoUpgrade(deps = {}) {
4876
4876
  const optOut = process.env.YAW_MCP_AUTO_UPGRADE;
4877
4877
  if (optOut === "0" || optOut?.toLowerCase() === "false") return;
4878
- const current = deps.currentVersion ?? (true ? "1.0.6" : "dev");
4878
+ const current = deps.currentVersion ?? (true ? "1.0.8" : "dev");
4879
4879
  if (current === "dev") return;
4880
4880
  const argvPath = deps.argvPath ?? process.argv[1];
4881
4881
  const method = (deps.isSeaImpl ? await deps.isSeaImpl() : await detectSea()) ? "binary" : detectInstallMethod(argvPath, realpathSync2, ["unknown", "local-node-modules"]);
package/dist/index.js CHANGED
@@ -93,7 +93,7 @@ import {
93
93
  unparseableConfigFix,
94
94
  userConfigDir,
95
95
  yawModeOverlay
96
- } from "./chunk-FP6ABRPZ.js";
96
+ } from "./chunk-A73UTVAV.js";
97
97
 
98
98
  // src/audit-cmd.ts
99
99
  import { homedir as homedir6 } from "os";
@@ -3196,7 +3196,7 @@ async function connectToUpstreamOnce(config, onDisconnect, onListChanged, bridge
3196
3196
  if (downstreamCaps?.sampling) capabilities.sampling = downstreamCaps.sampling;
3197
3197
  if (downstreamCaps?.roots) capabilities.roots = {};
3198
3198
  const client = new Client(
3199
- { name: "yaw-mcp", version: true ? "1.0.6" : "dev" },
3199
+ { name: "yaw-mcp", version: true ? "1.0.8" : "dev" },
3200
3200
  { capabilities }
3201
3201
  );
3202
3202
  if (bridge && capabilities.elicitation) {
@@ -4026,7 +4026,7 @@ async function exists(path5) {
4026
4026
  return false;
4027
4027
  }
4028
4028
  }
4029
- async function migrateFile(legacy, target, scope) {
4029
+ async function migrateFile(legacy, target, scope, plan) {
4030
4030
  let st;
4031
4031
  try {
4032
4032
  st = await lstat(legacy);
@@ -4066,6 +4066,10 @@ async function migrateFile(legacy, target, scope) {
4066
4066
  });
4067
4067
  return;
4068
4068
  }
4069
+ if (plan !== null) {
4070
+ plan.push({ scope, legacy, target });
4071
+ return;
4072
+ }
4069
4073
  try {
4070
4074
  await mkdir3(dirname5(target), { recursive: true });
4071
4075
  await rename2(legacy, target);
@@ -4092,10 +4096,18 @@ async function migrateFile(legacy, target, scope) {
4092
4096
  }
4093
4097
  }
4094
4098
  async function migrateLegacyConfigPaths(opts) {
4099
+ await walkLegacyConfigPaths(opts, null);
4100
+ }
4101
+ async function planLegacyConfigMigration(opts) {
4102
+ const plan = [];
4103
+ await walkLegacyConfigPaths(opts, plan);
4104
+ return plan;
4105
+ }
4106
+ async function walkLegacyConfigPaths(opts, plan) {
4095
4107
  const { cwd, home } = opts;
4096
4108
  const legacyGlobal = join7(home, LEGACY_GLOBAL_FILENAME);
4097
4109
  const newGlobal = join7(userConfigDir(home), NEW_CONFIG_FILENAME);
4098
- await migrateFile(legacyGlobal, newGlobal, "global");
4110
+ await migrateFile(legacyGlobal, newGlobal, "global", plan);
4099
4111
  const homeLocal = join7(home, LEGACY_LOCAL_FILENAME);
4100
4112
  if (await exists(homeLocal)) {
4101
4113
  log("warn", "yaw-mcp config: legacy machine-local file at $HOME has no new location -- leaving it in place", {
@@ -4109,10 +4121,10 @@ async function migrateLegacyConfigPaths(opts) {
4109
4121
  const newDir = join7(legacyProjectRoot, CONFIG_DIRNAME);
4110
4122
  const legacyLocal = join7(legacyProjectRoot, LEGACY_LOCAL_FILENAME);
4111
4123
  const newLocal = join7(newDir, NEW_LOCAL_FILENAME);
4112
- await migrateFile(legacyLocal, newLocal, "local");
4124
+ await migrateFile(legacyLocal, newLocal, "local", plan);
4113
4125
  const legacyProject = join7(legacyProjectRoot, LEGACY_PROJECT_FILENAME);
4114
4126
  const newProject = join7(newDir, NEW_CONFIG_FILENAME);
4115
- await migrateFile(legacyProject, newProject, "project");
4127
+ await migrateFile(legacyProject, newProject, "project", plan);
4116
4128
  }
4117
4129
  }
4118
4130
  async function findLegacyProjectRoot(cwd, home) {
@@ -4134,6 +4146,15 @@ async function findLegacyProjectRoot(cwd, home) {
4134
4146
  var CONFIG_FILENAME = "config.json";
4135
4147
  var LOCAL_CONFIG_FILENAME = "config.local.json";
4136
4148
  var CURRENT_SCHEMA_VERSION = 1;
4149
+ var READONLY_DIAGNOSTICS_ENV = "YAW_MCP_READONLY_DIAGNOSTICS";
4150
+ function isReadOnlyDiagnostics(env = process.env) {
4151
+ const raw = env[READONLY_DIAGNOSTICS_ENV]?.trim();
4152
+ if (raw === void 0 || raw === "") return false;
4153
+ return raw === "1" || raw.toLowerCase() === "true";
4154
+ }
4155
+ function legacyMigrationSkippedWarning(p) {
4156
+ return `${p.legacy}: pre-0.12 config file not migrated -- ${READONLY_DIAGNOSTICS_ENV} is set, so this run moves no files and the settings in it are NOT part of this report. The next yaw-mcp start (or this command with ${READONLY_DIAGNOSTICS_ENV} unset) moves it to ${p.target}.`;
4157
+ }
4137
4158
  var DEPRECATED_KEYS = ["token", "apiBase"];
4138
4159
  var KNOWN_CONFIG_KEYS = /* @__PURE__ */ new Set([
4139
4160
  "$schema",
@@ -4295,7 +4316,17 @@ async function loadYawMcpConfig(opts = {}) {
4295
4316
  const home = resolve3(opts.home ?? homedir7());
4296
4317
  const warnings = [];
4297
4318
  const loadedFiles = [];
4298
- await migrateLegacyConfigPathsOnce(cwd, home);
4319
+ if (opts.readOnly) {
4320
+ const pending2 = await planLegacyConfigMigration({ cwd, home }).catch((err) => {
4321
+ log("warn", "Legacy config migration check failed", {
4322
+ error: err instanceof Error ? err.message : String(err)
4323
+ });
4324
+ return [];
4325
+ });
4326
+ for (const p of pending2) warnings.push(legacyMigrationSkippedWarning(p));
4327
+ } else {
4328
+ await migrateLegacyConfigPathsOnce(cwd, home);
4329
+ }
4299
4330
  const projectConfigDir = await findProjectConfigDir(cwd, home, opts.env).catch((err) => {
4300
4331
  log("warn", "Failed searching for project .yaw-mcp/ dir", {
4301
4332
  error: err instanceof Error ? err.message : String(err)
@@ -4427,7 +4458,7 @@ async function runBundlesCommand(opts = {}) {
4427
4458
  }
4428
4459
  const env = opts.env ?? process.env;
4429
4460
  const loaded = await loadLocalBundles({ cwd: opts.cwd, home: opts.home, env });
4430
- const config = await loadYawMcpConfig({ cwd: opts.cwd, home: opts.home, env });
4461
+ const config = await loadYawMcpConfig({ cwd: opts.cwd, home: opts.home, env, readOnly: isReadOnlyDiagnostics(env) });
4431
4462
  for (const w of loaded.warnings) printErr(`warning: ${w}`);
4432
4463
  for (const w of config.warnings) printErr(`warning: ${w}`);
4433
4464
  const enabled = (loaded.config?.servers ?? []).filter((s) => s.isActive).map((s) => s.namespace);
@@ -11031,7 +11062,7 @@ function foldBundleWarnings(warnings, probe) {
11031
11062
  const prefix = `${probe.path}:`;
11032
11063
  return warnings.filter((w) => !w.startsWith(prefix));
11033
11064
  }
11034
- var VERSION = true ? "1.0.6" : "dev";
11065
+ var VERSION = true ? "1.0.8" : "dev";
11035
11066
  var DOCTOR_USAGE = `Usage: yaw-mcp doctor [--json]
11036
11067
 
11037
11068
  Print a diagnostic of your yaw-mcp setup.
@@ -11058,8 +11089,9 @@ async function collectDoctorBase(opts) {
11058
11089
  const appData = resolveAppDataDir({ home: opts.home, env: opts.env });
11059
11090
  const os = opts.os ?? CURRENT_OS;
11060
11091
  const env = opts.env ?? process.env;
11092
+ const readOnly = isReadOnlyDiagnostics(env);
11061
11093
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
11062
- const config = await loadYawMcpConfig({ cwd, home, env });
11094
+ const config = await loadYawMcpConfig({ cwd, home, env, readOnly });
11063
11095
  const trustProbe = await probeProjectTrust({ cwd, home, env }).catch(() => null);
11064
11096
  const trustWarning = projectTrustWarning(trustProbe);
11065
11097
  if (trustWarning) config.warnings = [...config.warnings, trustWarning];
@@ -11070,6 +11102,7 @@ async function collectDoctorBase(opts) {
11070
11102
  appData,
11071
11103
  os,
11072
11104
  env,
11105
+ readOnly,
11073
11106
  timestamp,
11074
11107
  config,
11075
11108
  trustProbe,
@@ -11127,10 +11160,11 @@ async function runDoctor(opts = {}) {
11127
11160
  write(`${s}
11128
11161
  `);
11129
11162
  };
11130
- const { cwd, home, appData, os, env, timestamp, config, trustProbe, claudeConfigDir, clientEnv: clientEnv2 } = await collectDoctorBase(opts);
11163
+ const { cwd, home, appData, os, env, readOnly, timestamp, config, trustProbe, claudeConfigDir, clientEnv: clientEnv2 } = await collectDoctorBase(opts);
11131
11164
  print(`yaw-mcp doctor -- ${timestamp}`);
11132
11165
  print(`yaw-mcp version: ${VERSION}`);
11133
11166
  print(`platform: ${os}`);
11167
+ if (readOnly) print(`mode: read-only (${READONLY_DIAGNOSTICS_ENV} is set) -- no trial sweep, no config migration`);
11134
11168
  print("");
11135
11169
  print("CONFIG FILES");
11136
11170
  if (config.loadedFiles.length === 0) {
@@ -11168,7 +11202,7 @@ async function runDoctor(opts = {}) {
11168
11202
  print
11169
11203
  });
11170
11204
  renderReliabilitySection({ disabled: persistenceDisabled, persisted: persistedState, print });
11171
- const trialWarnings = await renderTrialsSection({ home, print, now: opts.now });
11205
+ const trialWarnings = await renderTrialsSection({ home, print, now: opts.now, readOnly });
11172
11206
  if (trialWarnings.length > 0) config.warnings = [...config.warnings, ...trialWarnings];
11173
11207
  const clients = probeClients({
11174
11208
  home,
@@ -11258,13 +11292,9 @@ async function runDoctor(opts = {}) {
11258
11292
  async function runDoctorJson(opts) {
11259
11293
  const lines = [];
11260
11294
  const write = opts.out ?? createStreamWriter(process.stdout);
11261
- const { cwd, home, appData, os, env, timestamp, config, trustProbe, claudeConfigDir, clientEnv: clientEnv2 } = await collectDoctorBase(opts);
11262
- const trialScan = await scanTrials({ home, now: opts.now });
11263
- const trialGc = await gcExpiredTrials({
11264
- home,
11265
- now: opts.now,
11266
- scan: trialScan
11267
- }).catch(() => ({ cleared: 0, failed: 0, failures: [] }));
11295
+ const { cwd, home, appData, os, env, readOnly, timestamp, config, trustProbe, claudeConfigDir, clientEnv: clientEnv2 } = await collectDoctorBase(opts);
11296
+ const trialStatus = await collectTrialStatus({ home, now: opts.now, readOnly });
11297
+ const { scan: trialScan, gc: trialGc } = trialStatus;
11268
11298
  const clients = probeClients({
11269
11299
  home,
11270
11300
  os,
@@ -11363,7 +11393,19 @@ async function runDoctorJson(opts) {
11363
11393
  clientPath: marker.clientPath,
11364
11394
  msUntilExpiry
11365
11395
  })),
11366
- malformed: trialScan.malformed
11396
+ malformed: trialScan.malformed,
11397
+ // Read-only runs only, so an ordinary run's `trials` block is unchanged
11398
+ // (see DoctorJsonSnapshot.trials.unswept).
11399
+ ...readOnly ? {
11400
+ unswept: trialStatus.unswept.map(({ marker, path: path5, msUntilExpiry }) => ({
11401
+ slug: marker.slug,
11402
+ clientName: marker.clientName,
11403
+ clientPath: marker.clientPath,
11404
+ markerPath: path5,
11405
+ msSinceExpiry: Math.max(0, -msUntilExpiry)
11406
+ })),
11407
+ sweepHint: trialStatus.unswept.length > 0 ? TRIAL_SWEEP_HINT : null
11408
+ } : {}
11367
11409
  };
11368
11410
  const oamStatus = await collectOamRuntimeStatus({
11369
11411
  env,
@@ -11374,8 +11416,8 @@ async function runDoctorJson(opts) {
11374
11416
  });
11375
11417
  config.warnings = [...config.warnings, ...foldBundleWarnings(oamStatus.bundleWarnings, trustProbe)];
11376
11418
  const vault = await collectVaultStatus({ home, env, servers: oamStatus.servers });
11377
- if (trialGc.failures.length > 0) {
11378
- config.warnings = [...config.warnings, ...trialGc.failures.map(trialGcFailureWarning)];
11419
+ if (trialStatus.warnings.length > 0) {
11420
+ config.warnings = [...config.warnings, ...trialStatus.warnings];
11379
11421
  }
11380
11422
  config.warnings = [...config.warnings, ...clientLaunchWarnings(clients)];
11381
11423
  const oamRuntime = {
@@ -11424,6 +11466,8 @@ async function runDoctorJson(opts) {
11424
11466
  timestamp,
11425
11467
  version: VERSION,
11426
11468
  platform: os,
11469
+ // Present only on a read-only run -- see DoctorJsonSnapshot.readOnly.
11470
+ ...readOnly ? { readOnly: true } : {},
11427
11471
  // DEPRECATED keys, emitted with their original nested shape and null
11428
11472
  // members so `doctor --json` stays parseable for consumers reading
11429
11473
  // `.token.source` / `.apiBase.value`. See DoctorJsonSnapshot.
@@ -11824,16 +11868,35 @@ function renderReliabilitySection(opts) {
11824
11868
  }
11825
11869
  print("");
11826
11870
  }
11827
- async function renderTrialsSection(opts) {
11828
- const { home, print, now } = opts;
11871
+ var TRIAL_SWEEP_HINT = `Expired trials are not swept while ${READONLY_DIAGNOSTICS_ENV} is set. Run \`yaw-mcp doctor\` with it unset to sweep them all, or \`yaw-mcp try-cleanup <slug>\` to remove one.`;
11872
+ function trialUnsweptWarning(entry) {
11873
+ const { slug, clientPath } = entry.marker;
11874
+ return `trial "${slug}": expired but not swept -- ${READONLY_DIAGNOSTICS_ENV} is set, so this run edits no client config, and its entry may still be wired into ${clientPath}; run \`yaw-mcp doctor\` with ${READONLY_DIAGNOSTICS_ENV} unset to sweep it, or \`yaw-mcp try-cleanup ${slug}\``;
11875
+ }
11876
+ async function collectTrialStatus(opts) {
11877
+ const { home, now, readOnly } = opts;
11829
11878
  const scan = await scanTrials({ home, now });
11879
+ if (readOnly) {
11880
+ return {
11881
+ scan,
11882
+ gc: { cleared: 0, failed: 0, failures: [] },
11883
+ unswept: scan.expired,
11884
+ warnings: scan.expired.map(trialUnsweptWarning)
11885
+ };
11886
+ }
11830
11887
  const gc = await gcExpiredTrials({ home, now, scan }).catch(() => ({
11831
11888
  cleared: 0,
11832
11889
  failed: 0,
11833
11890
  failures: []
11834
11891
  }));
11835
- const warnings = gc.failures.map(trialGcFailureWarning);
11836
- if (scan.live.length === 0 && gc.cleared === 0 && gc.failed === 0 && scan.malformed.length === 0) return warnings;
11892
+ return { scan, gc, unswept: [], warnings: gc.failures.map(trialGcFailureWarning) };
11893
+ }
11894
+ async function renderTrialsSection(opts) {
11895
+ const { home, print, now, readOnly } = opts;
11896
+ const { scan, gc, unswept, warnings } = await collectTrialStatus({ home, now, readOnly });
11897
+ if (scan.live.length === 0 && gc.cleared === 0 && gc.failed === 0 && unswept.length === 0 && scan.malformed.length === 0) {
11898
+ return warnings;
11899
+ }
11837
11900
  print("TRIALS (yaw-mcp try)");
11838
11901
  if (gc.cleared > 0) {
11839
11902
  print(` swept ${gc.cleared} expired trial${gc.cleared === 1 ? "" : "s"} this run`);
@@ -11841,6 +11904,11 @@ async function renderTrialsSection(opts) {
11841
11904
  if (gc.failed > 0) {
11842
11905
  print(` ${gc.failed} expired trial${gc.failed === 1 ? "" : "s"} could not be swept -- see WARNINGS`);
11843
11906
  }
11907
+ if (unswept.length > 0) {
11908
+ print(
11909
+ ` ${unswept.length} expired trial${unswept.length === 1 ? "" : "s"} not swept (${READONLY_DIAGNOSTICS_ENV} is set) -- see WARNINGS`
11910
+ );
11911
+ }
11844
11912
  for (const { marker, msUntilExpiry } of scan.live) {
11845
11913
  print(` ${marker.slug} -> ${marker.clientName} (${marker.clientPath}) -- expires in ${formatTtl(msUntilExpiry)}`);
11846
11914
  }
@@ -15265,6 +15333,138 @@ import {
15265
15333
  ReadResourceRequestSchema
15266
15334
  } from "@modelcontextprotocol/sdk/types.js";
15267
15335
 
15336
+ // src/auto-prewarm.ts
15337
+ import { spawn as spawn4 } from "child_process";
15338
+ var DEFAULT_MAX_AUTO_PREWARM = 20;
15339
+ var DEFAULT_AUTO_PREWARM_TIMEOUT_MS = 3e4;
15340
+ var AUTO_PREWARM_DISABLE_ENV = "YAW_MCP_AUTO_PREWARM";
15341
+ var AUTO_PREWARM_MAX_ENV = "YAW_MCP_MAX_AUTO_PREWARM";
15342
+ var AUTO_PREWARM_TIMEOUT_ENV = "YAW_MCP_AUTO_PREWARM_TIMEOUT";
15343
+ var NPX_PACKAGE_PATTERN = /^@?[\w.-]+\/[\w.-]+@[\w.*+-]+$|^[\w.-]+@[\w.*+-]+$/;
15344
+ function extractNpxPackages(servers) {
15345
+ const seen = /* @__PURE__ */ new Set();
15346
+ const out = [];
15347
+ for (const server of servers) {
15348
+ if (server.type !== "local") continue;
15349
+ if (server.command !== "npx") continue;
15350
+ const args = server.args ?? [];
15351
+ if (args[0] !== "-y") continue;
15352
+ for (const arg of args.slice(1)) {
15353
+ if (typeof arg !== "string") continue;
15354
+ if (!NPX_PACKAGE_PATTERN.test(arg)) continue;
15355
+ if (seen.has(arg)) continue;
15356
+ seen.add(arg);
15357
+ out.push(arg);
15358
+ break;
15359
+ }
15360
+ }
15361
+ return out;
15362
+ }
15363
+ function isAutoPrewarmDisabled(env = process.env) {
15364
+ const raw = env[AUTO_PREWARM_DISABLE_ENV];
15365
+ if (raw === void 0) return false;
15366
+ const trimmed = raw.trim();
15367
+ if (trimmed === "") return false;
15368
+ return trimmed === "0" || trimmed.toLowerCase() === "false";
15369
+ }
15370
+ function parseAutoPrewarmMax(env = process.env, fallback = DEFAULT_MAX_AUTO_PREWARM) {
15371
+ const raw = env[AUTO_PREWARM_MAX_ENV];
15372
+ if (raw === void 0 || raw === "") return fallback;
15373
+ const n = Number.parseInt(raw, 10);
15374
+ return Number.isFinite(n) && n > 0 ? n : fallback;
15375
+ }
15376
+ function parseAutoPrewarmTimeoutMs(env = process.env, fallback = DEFAULT_AUTO_PREWARM_TIMEOUT_MS) {
15377
+ const raw = env[AUTO_PREWARM_TIMEOUT_ENV];
15378
+ if (raw === void 0 || raw === "") return fallback;
15379
+ const n = Number.parseInt(raw, 10);
15380
+ return Number.isFinite(n) && n > 0 ? n : fallback;
15381
+ }
15382
+ function defaultAcquireLockImpl() {
15383
+ if (process.env.VITEST) return () => {
15384
+ };
15385
+ return acquireSidecarsLock(sidecarsRoot());
15386
+ }
15387
+ function defaultSpawn(pkg, timeoutMs) {
15388
+ let errorFired = false;
15389
+ let done;
15390
+ const donePromise = new Promise((resolve8) => {
15391
+ done = resolve8;
15392
+ });
15393
+ const opts = {
15394
+ stdio: "ignore",
15395
+ // Mirror auto-upgrade.ts:736. npm runs every transitive pre/postinstall
15396
+ // with this env; YAW_MCP_VAULT_PASSPHRASE in particular is in process.env
15397
+ // only by operator choice and must not be forwarded to a download.
15398
+ env: stripInternalSecretsFromEnv(process.env),
15399
+ detached: false,
15400
+ shell: process.platform === "win32"
15401
+ };
15402
+ const child = spawn4("npx", ["-y", pkg, "--version"], opts);
15403
+ const finish = (reason, ok) => {
15404
+ done({ reason, ok });
15405
+ };
15406
+ child.on("close", (code) => {
15407
+ if (errorFired) return;
15408
+ finish("exit", code === 0);
15409
+ });
15410
+ child.on("error", (err) => {
15411
+ errorFired = true;
15412
+ log("warn", "auto-prewarm: npx spawn failed", { package: pkg, error: err?.message });
15413
+ finish("spawn-error", false);
15414
+ });
15415
+ const timer = setTimeout(() => {
15416
+ log("warn", "auto-prewarm: npx prime exceeded timeout; aborting", { package: pkg, timeoutMs });
15417
+ try {
15418
+ child.kill("SIGTERM");
15419
+ } catch {
15420
+ }
15421
+ finish("timeout", false);
15422
+ }, timeoutMs);
15423
+ timer.unref();
15424
+ donePromise.finally(() => clearTimeout(timer));
15425
+ return { package: pkg, child, done: donePromise };
15426
+ }
15427
+ async function maybeAutoPrewarmNpxCache(deps = {}) {
15428
+ try {
15429
+ if ((deps.isDisabled ?? (() => isAutoPrewarmDisabled()))()) return;
15430
+ const listServers = deps.listActiveServers ?? (() => []);
15431
+ const max = deps.maxPackages ?? (() => parseAutoPrewarmMax());
15432
+ const timeoutMs = deps.perPackageTimeoutMs ?? (() => parseAutoPrewarmTimeoutMs());
15433
+ const spawnOne = deps.spawnImpl ?? ((pkg) => defaultSpawn(pkg, timeoutMs()));
15434
+ const acquire = deps.acquireLockImpl ?? defaultAcquireLockImpl;
15435
+ const packages = extractNpxPackages(listServers());
15436
+ if (packages.length === 0) return;
15437
+ const capped = packages.length > max() ? packages.slice(0, max()) : packages;
15438
+ if (packages.length > capped.length) {
15439
+ log(
15440
+ "info",
15441
+ `auto-prewarm: capping at ${capped.length} of ${packages.length} npx packages (YAW_MCP_MAX_AUTO_PREWARM)`,
15442
+ { capped: capped.length, total: packages.length }
15443
+ );
15444
+ }
15445
+ const release = acquire();
15446
+ if (release === null) {
15447
+ log("info", "auto-prewarm: another process holds the sidecars lock; skipping this pass");
15448
+ return;
15449
+ }
15450
+ const start = Date.now();
15451
+ const results = await Promise.all(capped.map((pkg) => spawnOne(pkg).done));
15452
+ release();
15453
+ const okCount = results.filter((r) => r.ok).length;
15454
+ const failed = capped.length - okCount;
15455
+ const elapsedMs = Date.now() - start;
15456
+ const level = failed === 0 ? "info" : "warn";
15457
+ log(level, `auto-prewarmed ${okCount} of ${capped.length} npx packages in ${elapsedMs}ms (failed: ${failed})`, {
15458
+ ok: okCount,
15459
+ failed,
15460
+ total: capped.length,
15461
+ elapsedMs
15462
+ });
15463
+ } catch (err) {
15464
+ log("warn", "auto-prewarm: unexpected failure", { error: err?.message });
15465
+ }
15466
+ }
15467
+
15268
15468
  // src/cost-estimate.ts
15269
15469
  var BYTES_PER_TOKEN = 4;
15270
15470
  var CACHED_TOOL_SCHEMA_PAD_BYTES = 200;
@@ -17728,7 +17928,7 @@ var ConnectServer = class _ConnectServer {
17728
17928
  static SHUTDOWN_DRAIN_MS = 2e3;
17729
17929
  constructor() {
17730
17930
  this.server = new Server(
17731
- { name: "yaw-mcp", version: true ? "1.0.6" : "dev" },
17931
+ { name: "yaw-mcp", version: true ? "1.0.8" : "dev" },
17732
17932
  {
17733
17933
  capabilities: {
17734
17934
  tools: { listChanged: true },
@@ -18341,6 +18541,7 @@ var ConnectServer = class _ConnectServer {
18341
18541
  await this.server.connect(transport);
18342
18542
  maybeAutoUpgrade().catch((err) => log("warn", "Auto-upgrade check failed", { error: err?.message }));
18343
18543
  maybeRefreshSidecars().catch((err) => log("warn", "Sidecar refresh check failed", { error: err?.message }));
18544
+ maybeAutoPrewarmNpxCache().catch((err) => log("warn", "Auto-prewarm check failed", { error: err?.message }));
18344
18545
  log("info", "yaw-mcp started", {
18345
18546
  servers: this.config?.servers.length ?? 0
18346
18547
  });
@@ -21131,7 +21332,7 @@ function registerShutdownTriggers(shutdown, targets) {
21131
21332
  // src/status-cmd.ts
21132
21333
  import { existsSync as existsSync10 } from "fs";
21133
21334
  import { homedir as homedir23 } from "os";
21134
- var VERSION2 = true ? "1.0.6" : "dev";
21335
+ var VERSION2 = true ? "1.0.8" : "dev";
21135
21336
  var STATUS_SCHEMA_VERSION = 1;
21136
21337
  var STATUS_USAGE = `Usage: yaw-mcp status [--json]
21137
21338
 
@@ -21757,6 +21958,13 @@ if (subcommand === "compliance") {
21757
21958
  are written -- never the raw intent -- but
21758
21959
  ordinary words survive, so do not enable it on
21759
21960
  intents that carry names or other PII.
21961
+ YAW_MCP_READONLY_DIAGNOSTICS Set to \`1\` to make \`doctor\` and \`bundles\`
21962
+ write nothing, for a caller that runs them in
21963
+ the background: expired \`yaw-mcp try\` trials
21964
+ are reported as warnings instead of swept out
21965
+ of client configs, and a pre-0.12 config file
21966
+ is reported instead of moved into .yaw-mcp/
21967
+ (default: off; \`status\` never writes).
21760
21968
  YAW_MCP_CATALOG_URL Override the catalog \`add\`/\`try\` resolve slugs
21761
21969
  against (default https://yaw.sh/data/mcp-catalog.json).
21762
21970
 
@@ -21883,7 +22091,7 @@ if (subcommand === "compliance") {
21883
22091
  `);
21884
22092
  process.exitCode = 0;
21885
22093
  } else if (subcommand === "--version" || subcommand === "-V") {
21886
- process.stdout.write(`yaw-mcp ${true ? "1.0.6" : "dev"}
22094
+ process.stdout.write(`yaw-mcp ${true ? "1.0.8" : "dev"}
21887
22095
  `);
21888
22096
  process.exitCode = 0;
21889
22097
  } else if (subcommand !== void 0 && !subcommand.startsWith("-")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yawlabs/mcp",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "mcpName": "io.github.YawLabs/mcp",
5
5
  "description": "MCP gateway and orchestrator: one local install fronts every MCP server for Claude Code, Cursor, and VS Code, loading tools on demand.",
6
6
  "license": "SEE LICENSE IN LICENSE.md",