@yawlabs/mcp 0.76.1 → 0.78.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
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.
6
6
 
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 call is a background npm check for its own updates (`YAW_MCP_AUTO_UPGRADE=0` to disable); `yaw-mcp add` fetches the public server catalog on demand.
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 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.
8
8
 
9
9
  It earns its keep when you hit any of these:
10
10
 
@@ -203,13 +203,15 @@ yaw-mcp keeps its config under a `.yaw-mcp/` directory (mirroring `.git/`, `.vsc
203
203
  | **project** | `<project>/.yaw-mcp/config.json` | Shared via git with the repo. |
204
204
  | **global** | `~/.yaw-mcp/config.json` | Personal default for every project. |
205
205
 
206
- The project `.yaw-mcp/` is found by walking up from the cwd, stopping just before `$HOME` so a `.yaw-mcp/` at `$HOME` is treated as global only. Files may contain `//` and `/* */` comments. Full schema:
206
+ The project `.yaw-mcp/` is found by walking up from the cwd -- stopping just before `$HOME` when started under it (so a `.yaw-mcp/` at `$HOME` is treated as global only); a cwd outside `$HOME` walks to the filesystem root with an ownership check. Files may contain `//` and `/* */` comments. Full schema:
207
207
 
208
208
  ```jsonc
209
209
  {
210
210
  "version": 1, // schema version; newer versions log a warning
211
211
  "servers": ["gh", "pg", "linear"], // allow-list of namespaces (most-specific scope wins)
212
- "blocked": ["prod-db"] // deny-list (UNION across all scopes -- fail-safe on deny)
212
+ "blocked": ["prod-db"], // deny-list (UNION across all scopes -- fail-safe on deny)
213
+ "installNudge": true // opt-in: discover may suggest installing MCP servers for
214
+ // CLIs found in your recent shell history (off by default)
213
215
  }
214
216
  ```
215
217
 
@@ -230,7 +232,15 @@ Rather than putting credentials in a client config, keep a value in an encrypted
230
232
  }
231
233
  ```
232
234
 
233
- At spawn time, if `YAW_MCP_VAULT_PASSPHRASE` is set in yaw-mcp's own env, it decrypts the referenced names and substitutes them into the child's env. If the passphrase is absent or a name isn't stored, the literal `${secret:NAME}` passes through unchanged, so the child surfaces its own "missing credential" error rather than an empty string. The value never leaves your machine.
235
+ At spawn time, if `YAW_MCP_VAULT_PASSPHRASE` is set in yaw-mcp's own env, it decrypts the referenced names and substitutes them into the child's env. If the passphrase is absent or a name isn't stored, the spawn is **refused** -- the literal `${secret:NAME}` is never passed through, since some servers would treat the placeholder as a real token. The value never leaves your machine.
236
+
237
+ **Where the passphrase comes from.** Three ways, in the order you'll meet them:
238
+
239
+ 1. **`YAW_MCP_VAULT_PASSPHRASE` in yaw-mcp's own env** -- the `env` block of the *yaw-mcp* entry in your MCP client config, not the upstream server's (yaw-mcp strips its own secrets from every child env). This is the only option for a spawn, which happens over stdio with no terminal to prompt on.
240
+ 2. **An in-session prompt.** If your client supports MCP [elicitation](https://modelcontextprotocol.io/specification/server/elicitation), a locked vault asks for the passphrase once per session and retries the server. It's held in memory for that session only -- never written to disk, and never handed to the server being started.
241
+ 3. **The CLI prompt**, for `yaw-mcp secrets` runs: no-echo on a real TTY. Note that Git Bash/MSYS can't offer one (Node sees pipes, not a TTY) -- use PowerShell, `winpty`, or the env var there.
242
+
243
+ `yaw-mcp doctor` has a **SECRET VAULT** section showing what's stored, which servers reference it, and whether a passphrase is available -- start there when a server won't load. It reports names and a yes/no, never a value.
234
244
 
235
245
  ```bash
236
246
  yaw-mcp secrets set <name> # store a value (no-echo prompt, or --value/--stdin)
@@ -276,9 +286,10 @@ Common ones (run `yaw-mcp --help` for the full list):
276
286
  |----------|-------------|
277
287
  | `YAW_MCP_SERVER_CAP` | Max concurrently active servers. Default `6`; `0` disables the cap. |
278
288
  | `YAW_MCP_MIN_COMPLIANCE` | Minimum grade (`A`-`F`) an installed server must report before `activate` loads it. |
279
- | `YAW_MCP_VAULT_PASSPHRASE` | Passphrase for the local secret vault. Required for spawn-time `${secret:NAME}` substitution. |
289
+ | `YAW_MCP_VAULT_PASSPHRASE` | Passphrase for the local secret vault. Required for spawn-time `${secret:NAME}` substitution -- set it in yaw-mcp's own env, not the upstream server's. Clients supporting elicitation prompt for it instead. |
280
290
  | `YAW_MCP_AUTO_ACTIVATE` | `0` disables discover auto-loading a clearly-winning server. Default on. |
281
291
  | `YAW_MCP_AUTO_UPGRADE` | `0` disables the background self-upgrade check at startup. Default on. |
292
+ | `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. |
282
293
  | `YAW_MCP_AUTO_LOAD` | `1` pre-activates the top recurring pack at startup (needs persistence). Default off. |
283
294
  | `YAW_MCP_PRUNE_RESPONSES` | `0` disables response pruning. Default on. |
284
295
  | `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. |
@@ -1,12 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ acquireUpgradeLock,
3
4
  detectRunningInstallPrefix,
4
5
  maybeAutoUpgrade,
5
6
  quoteArgForDisplay,
6
7
  quoteShellArgIfNeeded
7
- } from "./chunk-U3KC5QAD.js";
8
- import "./chunk-C3AQHLOR.js";
8
+ } from "./chunk-AB63LGSO.js";
9
+ import "./chunk-3RRZQPA5.js";
9
10
  export {
11
+ acquireUpgradeLock,
10
12
  detectRunningInstallPrefix,
11
13
  maybeAutoUpgrade,
12
14
  quoteArgForDisplay,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  log
4
- } from "./chunk-C3AQHLOR.js";
4
+ } from "./chunk-3RRZQPA5.js";
5
5
 
6
6
  // src/oam-spawn.ts
7
7
  import { spawn } from "child_process";
@@ -317,6 +317,7 @@ function isUnderHome(dir, homeResolved) {
317
317
  return rel !== ".." && !rel.startsWith(`..${path.sep}`);
318
318
  }
319
319
  var ALLOW_UNOWNED_ENV = "YAW_MCP_ALLOW_UNOWNED_PROJECT_DIRS";
320
+ var warnedUntrustedDirs = /* @__PURE__ */ new Set();
320
321
  async function ownedByCurrentUser(candidate) {
321
322
  const geteuid = process.geteuid;
322
323
  if (typeof geteuid !== "function") return process.env[ALLOW_UNOWNED_ENV] === "1";
@@ -344,10 +345,13 @@ async function findProjectConfigDir(start, home = homedir2()) {
344
345
  } else if (boundedByHome || await ownedByCurrentUser(candidate)) {
345
346
  return candidate;
346
347
  } else {
347
- log("warn", "Skipping an untrusted .yaw-mcp/ dir outside $HOME", {
348
- candidate,
349
- hint: `owned by another user, or ownership is unverifiable on this platform (set ${ALLOW_UNOWNED_ENV}=1 to trust it)`
350
- });
348
+ if (!warnedUntrustedDirs.has(candidate)) {
349
+ warnedUntrustedDirs.add(candidate);
350
+ log("warn", "Skipping an untrusted .yaw-mcp/ dir outside $HOME", {
351
+ candidate,
352
+ hint: `owned by another user, or ownership is unverifiable on this platform (set ${ALLOW_UNOWNED_ENV}=1 to trust it)`
353
+ });
354
+ }
351
355
  }
352
356
  } catch {
353
357
  }
@@ -393,7 +397,7 @@ function npxSpec(args) {
393
397
  const spec = args[idx];
394
398
  return spec.startsWith("-") ? null : spec;
395
399
  }
396
- var MIN_OAM_VERSION = "0.11.0";
400
+ var MIN_OAM_VERSION = "0.12.1";
397
401
  var OAM_INSTALL_SH = "curl -fsSL https://oamjs.org/install.sh | sh";
398
402
  var OAM_INSTALL_PS1 = "irm https://oamjs.org/install.ps1 | iex";
399
403
  function oamInstallCommand(os) {
@@ -408,7 +412,7 @@ function oamPublishesBinaryForThisMachine() {
408
412
  return oamPublishesBinaryFor(process.platform, process.arch);
409
413
  }
410
414
  function oamNoBinaryReason() {
411
- return `no published oam binary for ${process.platform}-${process.arch} yet \u2014 build from source at https://oamjs.org`;
415
+ return `no published oam binary for ${process.platform}-${process.arch} yet -- build from source at https://oamjs.org`;
412
416
  }
413
417
  function oamInstallAdvice(os) {
414
418
  if (os === CURRENT_OS && !oamPublishesBinaryForThisMachine()) return oamNoBinaryReason();
@@ -485,10 +489,13 @@ function isExecutableFile(candidate, platform) {
485
489
  }
486
490
  function resolveBinAbsolute(bin, env = process.env, platform = process.platform) {
487
491
  if (isAbsolute2(bin)) return isExecutableFile(bin, platform) ? winNormalize(bin, platform) : null;
492
+ if (bin.includes("/") || platform === "win32" && bin.includes("\\")) return null;
488
493
  const pathVar = env.PATH ?? env.Path ?? env.path ?? "";
489
494
  if (!pathVar) return null;
490
495
  const dirs = pathVar.split(platform === "win32" ? ";" : ":").filter(Boolean);
491
- const exts = platform === "win32" ? ["", ...(env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean)] : [""];
496
+ const pathext = (env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean);
497
+ const carriesExt = pathext.some((e) => bin.toLowerCase().endsWith(e.toLowerCase()));
498
+ const exts = platform === "win32" ? carriesExt ? ["", ...pathext] : pathext : [""];
492
499
  for (const dir of dirs) {
493
500
  const clean = dir.replace(/^"|"$/g, "");
494
501
  for (const ext of exts) {
@@ -513,18 +520,26 @@ function createProbeCollector(max = OAM_PROBE_MAX_OUTPUT) {
513
520
  let head = "";
514
521
  let carry = "";
515
522
  let found = null;
523
+ let pending = null;
516
524
  return {
517
525
  push(chunk) {
518
526
  if (found !== null) return;
519
- found = parseOamVersion(carry + chunk);
520
- carry = (carry + chunk).slice(-VERSION_CARRY);
527
+ const scan = carry + chunk;
528
+ const hit = parseOamVersion(scan);
529
+ if (hit !== null) {
530
+ if (scan.endsWith(hit)) pending = hit;
531
+ else found = hit;
532
+ }
533
+ carry = scan.slice(-VERSION_CARRY);
521
534
  if (head.length >= max) return;
522
535
  head += chunk.slice(0, max - head.length);
523
536
  },
524
537
  /** The version if one appeared anywhere, else the capped head (which
525
- * parses to null either way, so the caller's contract is unchanged). */
538
+ * parses to null either way, so the caller's contract is unchanged).
539
+ * Called after the stream closes, so a still-pending match is final: no
540
+ * further chunk can extend it. */
526
541
  result() {
527
- return found ?? head;
542
+ return found ?? pending ?? head;
528
543
  },
529
544
  /** Test hook: bytes actually retained. */
530
545
  retainedLength() {
@@ -631,6 +646,12 @@ async function probeOamUncached(run, generation) {
631
646
  });
632
647
  return publish({ bin: null, binPath: null, version, belowMin: true, failure: null, failureDetail: null });
633
648
  }
649
+ if (version === null) {
650
+ log("debug", "oam --version printed no parsable version; the minimum-version gate did not run for this binary", {
651
+ bin,
652
+ minVersion: MIN_OAM_VERSION
653
+ });
654
+ }
634
655
  return publish({
635
656
  bin,
636
657
  // Resolved once, alongside the probe that proved the name spawns, so the
@@ -678,13 +699,17 @@ function nodeLaunchKind(command) {
678
699
  if (base === "npx") return "npx";
679
700
  return null;
680
701
  }
702
+ var TS_ENTRY_RE = /\.[mc]?ts$/i;
681
703
  function rewriteForOam(command, args, deps) {
682
704
  const bin = deps.oamBin;
683
705
  if (!bin) return { command, args };
684
- const toOam = (entry, rest) => ({
685
- command: bin,
686
- args: rest.length > 0 ? ["run", entry, "--", ...rest] : ["run", entry]
687
- });
706
+ const toOam = (entry, rest) => {
707
+ const flags = TS_ENTRY_RE.test(entry) ? ["--no-check"] : [];
708
+ return {
709
+ command: bin,
710
+ args: rest.length > 0 ? ["run", ...flags, entry, "--", ...rest] : ["run", ...flags, entry]
711
+ };
712
+ };
688
713
  const kind = nodeLaunchKind(command);
689
714
  if (kind === "node") {
690
715
  const [entry, ...rest] = args;
@@ -788,14 +813,15 @@ function npmrcCache(file) {
788
813
  } catch {
789
814
  return null;
790
815
  }
816
+ let last = null;
791
817
  for (const line of text.split(/\r?\n/)) {
792
818
  const m = /^\s*cache\s*=(.*)$/.exec(line);
793
819
  if (!m) continue;
794
820
  const value = npmrcValue(m[1]);
795
821
  if (!value) continue;
796
- return value.startsWith("~/") ? join2(homedir3(), value.slice(2)) : value;
822
+ last = value.startsWith("~/") ? join2(homedir3(), value.slice(2)) : value;
797
823
  }
798
- return null;
824
+ return last;
799
825
  }
800
826
  var npmCacheDirCache = /* @__PURE__ */ new Map();
801
827
  function npmCacheDir(fromUrl = import.meta.url) {
@@ -884,17 +910,20 @@ function packageEntry(pkgDir, pkg) {
884
910
  }
885
911
  function resolveNpmEntry(pkg, fromUrl = import.meta.url, npmCache = npmCacheDir(fromUrl), managedRoot = sidecarsNodeModules(), wantVersion = null) {
886
912
  const parts = pkg.split("/");
913
+ const own = ownNodeModules(fromUrl);
914
+ const ownCache = own.filter((nodeModules) => nodeModules.includes(NPX_CACHE_MARKER));
915
+ const ownDurable = own.filter((nodeModules) => !nodeModules.includes(NPX_CACHE_MARKER));
887
916
  const durable = [
888
917
  ...managedRoot ? [{ nodeModules: managedRoot, source: "managed" }] : [],
889
- // The broker's OWN node_modules sits UNDER _npx whenever yaw-mcp was
890
- // itself launched via `npx -y @yawlabs/mcp` -- the common install shape,
891
- // not an edge case. Calling that "durable" would advertise `npm install
892
- // <pkg>@latest`, which cannot refresh a content-hashed cache directory.
893
- // resolveStableNpmEntry draws the same distinction for the same reason.
894
- ...ownNodeModules(fromUrl).map((nodeModules) => ({
895
- nodeModules,
896
- source: nodeModules.includes(NPX_CACHE_MARKER) ? "npx-cache" : "durable"
897
- }))
918
+ // Only the copies that are genuinely durable take part in the take-outright
919
+ // loop. A sidecar sitting in the broker's OWN _npx hash dir is a cache copy
920
+ // like any other, so it belongs in the highest-version scan below -- taking
921
+ // it outright let an old build in our own hash dir beat a NEWER copy in a
922
+ // sibling cache dir, which is the opposite of the rule that scan exists to
923
+ // enforce. (Only the ranking was wrong: the replaced branch already keyed
924
+ // `source` off NPX_CACHE_MARKER, so an own `_npx` copy was tagged
925
+ // "npx-cache" and did get the `npx -y <pkg>@latest` refresh advice.)
926
+ ...ownDurable.map((nodeModules) => ({ nodeModules, source: "durable" }))
898
927
  ];
899
928
  for (const { nodeModules, source } of durable) {
900
929
  const hit = packageEntry(join2(nodeModules, ...parts), pkg);
@@ -903,7 +932,7 @@ function resolveNpmEntry(pkg, fromUrl = import.meta.url, npmCache = npmCacheDir(
903
932
  notePinnedSidecar(pkg, hit.version, source, nodeModules);
904
933
  return hit.entry;
905
934
  }
906
- const roots = /* @__PURE__ */ new Set([...npxCacheNodeModules(fromUrl), ...npmCacheNpxNodeModules(npmCache)]);
935
+ const roots = /* @__PURE__ */ new Set([...ownCache, ...npxCacheNodeModules(fromUrl), ...npmCacheNpxNodeModules(npmCache)]);
907
936
  let best = null;
908
937
  let bestRoot = null;
909
938
  let bestParsed = null;
@@ -978,7 +1007,7 @@ function resolveStableNpmEntry(pkg, fromUrl = import.meta.url) {
978
1007
  }
979
1008
  async function resolveOamSpawn(command, args, optedIn = true) {
980
1009
  const probe = await probeOam();
981
- if (optedIn && probe.bin === null && !probe.belowMin && !warnedOamUnavailable) {
1010
+ if (optedIn && probe.bin === null && !probe.belowMin && !warnedOamUnavailable && nodeLaunchKind(command) !== null) {
982
1011
  warnedOamUnavailable = true;
983
1012
  if (probe.failure !== null) {
984
1013
  log("warn", "a server opted in to oam but oam is installed and unusable; running it on node instead", {
@@ -1039,6 +1068,7 @@ export {
1039
1068
  sidecarsRoot,
1040
1069
  sidecarsNodeModules,
1041
1070
  userConfigDir,
1071
+ realpathOrSelf,
1042
1072
  isUnderHome,
1043
1073
  findProjectConfigDir,
1044
1074
  guidePath,
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/logger.ts
4
+ var LOG_LEVELS = { debug: 0, info: 1, warn: 2, error: 3 };
5
+ function minLevel() {
6
+ return LOG_LEVELS[process.env.LOG_LEVEL?.toLowerCase()] ?? LOG_LEVELS.info;
7
+ }
8
+ var stderrErrorGuarded = false;
9
+ function guardStderrErrors() {
10
+ if (stderrErrorGuarded) return;
11
+ stderrErrorGuarded = true;
12
+ try {
13
+ if (process.stderr.listenerCount("error") === 0) {
14
+ process.stderr.on("error", () => {
15
+ });
16
+ }
17
+ } catch {
18
+ }
19
+ }
20
+ function log(level, msg, data) {
21
+ if (LOG_LEVELS[level] < minLevel()) return;
22
+ guardStderrErrors();
23
+ const ts = (/* @__PURE__ */ new Date()).toISOString();
24
+ let entry;
25
+ try {
26
+ entry = JSON.stringify({ ...data, level, msg, ts });
27
+ } catch {
28
+ entry = JSON.stringify({ level, msg, ts, dataOmitted: true });
29
+ }
30
+ try {
31
+ process.stderr.write(`${entry}
32
+ `);
33
+ } catch {
34
+ }
35
+ }
36
+
37
+ export {
38
+ log
39
+ };