@yawlabs/mcp 0.72.0 → 0.73.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.
Files changed (2) hide show
  1. package/dist/index.js +145 -36
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1524,7 +1524,7 @@ var SUBCOMMAND_SPEC = [
1524
1524
  name: "secrets",
1525
1525
  description: "Manage stored secrets",
1526
1526
  positional: [["set", "get", "list", "remove", "lock", "rotate", "audit"], ["<name>"]],
1527
- flags: ["--value", "--stdin", "--secret", "--server", "--json", "--help"]
1527
+ flags: ["--value", "--stdin", "--force", "--secret", "--server", "--json", "--help"]
1528
1528
  },
1529
1529
  // Other.
1530
1530
  { name: "audit", description: "Run a full-pass audit of loaded servers", flags: ["--json", "--help"] },
@@ -1713,7 +1713,7 @@ function renderPowershell() {
1713
1713
  const caseBranches = SUBCOMMAND_SPEC.map((spec) => {
1714
1714
  const flags = spec.flags.map((f) => `'${f}'`).join(", ");
1715
1715
  const positionalLines = realPositionals(spec).map(
1716
- ({ candidates, index }) => ` if ($tokens.Count -eq ${index + 2}) { $completions += @(${candidates.map((c) => `'${c}'`).join(", ")}) }`
1716
+ ({ candidates, index }) => ` if ($argIndex -eq ${index}) { $completions += @(${candidates.map((c) => `'${c}'`).join(", ")}) }`
1717
1717
  ).join("\n");
1718
1718
  const positionalBlock = positionalLines ? `${positionalLines}
1719
1719
  ` : "";
@@ -1725,9 +1725,17 @@ ${positionalBlock} $completions += @(${flags})
1725
1725
  # Install: append this script to your profile ($PROFILE) and reload.
1726
1726
  Register-ArgumentCompleter -CommandName yaw-mcp -ScriptBlock {
1727
1727
  param($wordToComplete, $commandAst, $cursorPosition)
1728
- $tokens = $commandAst.CommandElements | ForEach-Object { $_.ToString() }
1728
+ $tokens = @($commandAst.CommandElements | ForEach-Object { $_.ToString() })
1729
1729
  $completions = @()
1730
- if ($tokens.Count -le 2) {
1730
+ # $argIndex is the normalized index of the positional being completed: 0 is
1731
+ # the first argument AFTER the subcommand. $tokens[0] is "yaw-mcp" and
1732
+ # $tokens[1] is the subcommand, hence -2. A partially typed word is already
1733
+ # one of $tokens, so back off one more when $wordToComplete is non-empty --
1734
+ # that keeps "install <TAB>" and "install cl<TAB>" both on slot 0. Negative
1735
+ # means the user is still on the subcommand itself.
1736
+ $argIndex = $tokens.Count - 2
1737
+ if ($wordToComplete -ne '') { $argIndex-- }
1738
+ if ($argIndex -lt 0) {
1731
1739
  $completions = @(${subcommandNames}, '--help', '-h', '--version', '-V')
1732
1740
  } else {
1733
1741
  switch ($tokens[1]) {
@@ -1809,6 +1817,20 @@ function quoteForShell(arg, platform) {
1809
1817
  if (arg.includes("'")) return null;
1810
1818
  return `'${arg}'`;
1811
1819
  }
1820
+ function unquotableCharsFor(platform) {
1821
+ return platform === "win32" ? "double quotes, percent signs, newlines or NUL bytes" : "single quotes, newlines or NUL bytes";
1822
+ }
1823
+ function formatLaunchFailure(npxArgs, platform = process.platform) {
1824
+ const offender = npxArgs.find((a) => quoteForShell(a, platform) === null);
1825
+ const detail = offender === void 0 ? "and the target arguments cannot be safely quoted for a shell fallback.\n" : (
1826
+ // JSON.stringify so a newline / NUL in the argument is shown escaped
1827
+ // instead of mangling the diagnostic it appears in.
1828
+ `and this argument cannot be safely quoted for a shell fallback: ${JSON.stringify(offender)}
1829
+ `
1830
+ );
1831
+ return "\nFailed to launch mcp-compliance: npm's npx-cli.js was not found next to this node binary,\n" + detail + `Install npm, or pass a target without ${unquotableCharsFor(platform)}.
1832
+ `;
1833
+ }
1812
1834
  function resolveNpxLaunch(npxArgs, opts = {}) {
1813
1835
  const execPath = opts.execPath ?? process.execPath;
1814
1836
  const platform = opts.platform ?? process.platform;
@@ -1868,9 +1890,7 @@ function runTest(args, err) {
1868
1890
  const npxArgs = ["-y", "@yawlabs/mcp-compliance", "test", "--format", "json", ...args];
1869
1891
  const launch = resolveNpxLaunch(npxArgs);
1870
1892
  if (!launch) {
1871
- fail(
1872
- "\nFailed to launch mcp-compliance: npm's npx-cli.js was not found next to this node binary,\nand the target arguments cannot be safely quoted for a shell fallback. Install npm, or pass\na target without quotes / newlines.\n"
1873
- );
1893
+ fail(formatLaunchFailure(npxArgs));
1874
1894
  return;
1875
1895
  }
1876
1896
  let child;
@@ -4530,7 +4550,7 @@ async function runUpgrade(opts = {}) {
4530
4550
  return { exitCode: 3, lines };
4531
4551
  }
4532
4552
  function readCurrentVersion() {
4533
- return true ? "0.72.0" : "dev";
4553
+ return true ? "0.73.0" : "dev";
4534
4554
  }
4535
4555
 
4536
4556
  // src/learning.ts
@@ -4732,7 +4752,7 @@ function selectFlakyNamespaces(entries, limit) {
4732
4752
  }
4733
4753
 
4734
4754
  // src/doctor-cmd.ts
4735
- var VERSION = true ? "0.72.0" : "dev";
4755
+ var VERSION = true ? "0.73.0" : "dev";
4736
4756
  function isPersistenceDisabled(env) {
4737
4757
  const raw = env.YAW_MCP_DISABLE_PERSISTENCE;
4738
4758
  return raw !== void 0 && raw !== "" && (raw === "1" || raw.toLowerCase() === "true");
@@ -6641,14 +6661,19 @@ var SECRETS_USAGE = `Usage: yaw-mcp secrets <action> [args]
6641
6661
  Actions:
6642
6662
  set <name> Store a secret. Reads value from stdin (one
6643
6663
  line, no echo). Override with --value <v> or
6644
- --stdin (raw, multi-line) for scripting.
6664
+ --stdin (raw, multi-line) for scripting. Setting
6665
+ a name that already exists REPLACES it (confirmed
6666
+ first on a TTY; scripted runs proceed and say
6667
+ "Replaced" instead of "Stored").
6645
6668
  get <name> Decrypt and print one secret value to stdout.
6646
6669
  NOTE: this prints the secret in CLEARTEXT (with
6647
6670
  or without --json). Redirect to a file or pipe
6648
6671
  to a consumer; avoid running it interactively so
6649
6672
  the value does not land in terminal scrollback.
6650
6673
  list Show vault entry names (values stay encrypted).
6651
- remove <name> Delete an entry.
6674
+ remove <name> Delete an entry. Unrecoverable, so it asks you
6675
+ to confirm on a TTY (bare Enter = no) and refuses
6676
+ without --force when there is no TTY to ask on.
6652
6677
  lock Forget the passphrase cached in THIS process's
6653
6678
  memory. The cache never outlives the process, so
6654
6679
  for a one-shot CLI run this is close to a no-op --
@@ -6673,6 +6698,11 @@ Flags:
6673
6698
  --value <v> Inline secret value (set only). Beware shell
6674
6699
  history -- prefer the default stdin prompt.
6675
6700
  --stdin Read the secret from raw stdin (set only).
6701
+ --force Skip the destructive-action confirmation
6702
+ (remove, and a set that overwrites an existing
6703
+ name). Required for remove when stdin or stdout
6704
+ is not a TTY (both ends are needed to ask). NEVER
6705
+ skips the passphrase.
6676
6706
  --secret <name> (audit only) Filter to one secret name.
6677
6707
  --server <ns> (audit only) Filter to one server namespace.
6678
6708
 
@@ -6696,6 +6726,10 @@ function parseSecretsArgs(argv) {
6696
6726
  opts.fromStdin = true;
6697
6727
  continue;
6698
6728
  }
6729
+ if (a === "--force") {
6730
+ opts.force = true;
6731
+ continue;
6732
+ }
6699
6733
  if (a === "--value") {
6700
6734
  const v = argv[++i];
6701
6735
  if (v === void 0 || v.startsWith("-")) {
@@ -6757,6 +6791,14 @@ ${SECRETS_USAGE}` };
6757
6791
 
6758
6792
  ${SECRETS_USAGE}` };
6759
6793
  }
6794
+ if (opts.action === "set" && opts.name !== void 0 && !SECRET_NAME_RE.test(opts.name)) {
6795
+ return {
6796
+ ok: false,
6797
+ error: `yaw-mcp secrets set: invalid secret name "${opts.name}" -- use letters, digits, "_", "." or "-" only; other characters can never be referenced as \${secret:NAME}
6798
+
6799
+ ${SECRETS_USAGE}`
6800
+ };
6801
+ }
6760
6802
  return { ok: true, options: opts };
6761
6803
  }
6762
6804
  async function safeLoadVault(path7, io, json, action) {
@@ -6783,6 +6825,39 @@ function cancelledResult(io, json) {
6783
6825
  `);
6784
6826
  return { exitCode: 130 };
6785
6827
  }
6828
+ function abortedResult(io, json, action) {
6829
+ const msg = "Aborted.";
6830
+ if (json) io.err(`${JSON.stringify({ ok: false, error: msg, aborted: true })}
6831
+ `);
6832
+ else io.err(`yaw-mcp secrets ${action}: ${msg}
6833
+ `);
6834
+ return { exitCode: 1 };
6835
+ }
6836
+ function ttyEnds(opts) {
6837
+ const stdin = opts.io?.stdin ?? process.stdin;
6838
+ const stdout = opts.io?.stdout ?? process.stdout;
6839
+ return {
6840
+ stdin: stdin.isTTY === true,
6841
+ stdout: stdout.isTTY === true
6842
+ };
6843
+ }
6844
+ function isInteractiveTTY(opts) {
6845
+ const ends = ttyEnds(opts);
6846
+ return ends.stdin && ends.stdout;
6847
+ }
6848
+ function nonTTYEnds(opts) {
6849
+ const ends = ttyEnds(opts);
6850
+ if (!ends.stdin && !ends.stdout) return "neither stdin nor stdout is a TTY";
6851
+ return ends.stdin ? "stdout is not a TTY" : "stdin is not a TTY";
6852
+ }
6853
+ async function promptYesNo(opts, question) {
6854
+ const stdin = opts.io?.stdin ?? process.stdin;
6855
+ const stdout = opts.io?.stdout ?? process.stdout;
6856
+ const answer = await readLineFromTTY(stdin, stdout, `${question} [y/N] `, true);
6857
+ if (answer === CANCELLED) return CANCELLED;
6858
+ const a = answer.trim().toLowerCase();
6859
+ return a === "y" || a === "yes";
6860
+ }
6786
6861
  async function resolvePassphrase(opts) {
6787
6862
  if (opts.passphrase !== void 0) return opts.passphrase.length > 0 ? opts.passphrase : null;
6788
6863
  const fromEnv = process.env.YAW_MCP_VAULT_PASSPHRASE;
@@ -6798,10 +6873,9 @@ async function resolvePassphrase(opts) {
6798
6873
  }
6799
6874
  const stdin = opts.io?.stdin ?? process.stdin;
6800
6875
  const stdout = opts.io?.stdout ?? process.stdout;
6801
- const isTTY = stdin.isTTY === true && stdout.isTTY === true;
6802
- if (!isTTY) return null;
6876
+ if (!isInteractiveTTY(opts)) return null;
6803
6877
  for (let attempt = 0; attempt < MAX_PASSPHRASE_PROMPTS; attempt++) {
6804
- const entered = await readPassphraseFromTTY(stdin, stdout);
6878
+ const entered = await readLineFromTTY(stdin, stdout);
6805
6879
  if (entered === CANCELLED) return CANCELLED;
6806
6880
  if (entered.length > 0) return entered;
6807
6881
  stdout.write("Passphrase cannot be empty.\n");
@@ -6823,16 +6897,15 @@ async function resolveNewPassphrase(opts) {
6823
6897
  }
6824
6898
  const stdin = opts.io?.stdin ?? process.stdin;
6825
6899
  const stdout = opts.io?.stdout ?? process.stdout;
6826
- const isTTY = stdin.isTTY === true && stdout.isTTY === true;
6827
- if (!isTTY) return null;
6900
+ if (!isInteractiveTTY(opts)) return null;
6828
6901
  for (let attempt = 0; attempt < MAX_PASSPHRASE_PROMPTS; attempt++) {
6829
- const first = await readPassphraseFromTTY(stdin, stdout, "New vault passphrase: ");
6902
+ const first = await readLineFromTTY(stdin, stdout, "New vault passphrase: ");
6830
6903
  if (first === CANCELLED) return CANCELLED;
6831
6904
  if (first.length === 0) {
6832
6905
  stdout.write("Passphrase cannot be empty.\n");
6833
6906
  continue;
6834
6907
  }
6835
- const second = await readPassphraseFromTTY(stdin, stdout, "Confirm new passphrase: ");
6908
+ const second = await readLineFromTTY(stdin, stdout, "Confirm new passphrase: ");
6836
6909
  if (second === CANCELLED) return CANCELLED;
6837
6910
  if (first === second) return first;
6838
6911
  stdout.write("Passphrases did not match. Try again.\n");
@@ -6844,7 +6917,7 @@ var MIN_PASSPHRASE_WARN_LEN = 12;
6844
6917
  var CTRL_C = "";
6845
6918
  var CTRL_D = "";
6846
6919
  var DEL = "\x7F";
6847
- function readPassphraseFromTTY(stdin, stdout, prompt = "Vault passphrase: ") {
6920
+ function readLineFromTTY(stdin, stdout, prompt = "Vault passphrase: ", echo = false) {
6848
6921
  stdout.write(prompt);
6849
6922
  return new Promise((resolve7) => {
6850
6923
  const chunks = [];
@@ -6880,10 +6953,15 @@ function readPassphraseFromTTY(stdin, stdout, prompt = "Vault passphrase: ") {
6880
6953
  return;
6881
6954
  }
6882
6955
  if (ch === "\b" || ch === DEL) {
6883
- if (chunks.length > 0) chunks.pop();
6956
+ if (chunks.length > 0) {
6957
+ chunks.pop();
6958
+ if (echo) stdout.write("\b \b");
6959
+ }
6884
6960
  continue;
6885
6961
  }
6962
+ if (ch < " ") continue;
6886
6963
  chunks.push(ch);
6964
+ if (echo) stdout.write(ch);
6887
6965
  }
6888
6966
  }
6889
6967
  stdin.on("data", onData);
@@ -6894,8 +6972,7 @@ async function readStdinValue(io, forceRaw) {
6894
6972
  const stdout = io?.stdout ?? process.stdout;
6895
6973
  const isTTY = stdin.isTTY === true;
6896
6974
  if (isTTY && !forceRaw) {
6897
- stdout.write("Secret value: ");
6898
- return readPassphraseFromTTY(stdin, stdout);
6975
+ return readLineFromTTY(stdin, stdout, "Secret value: ");
6899
6976
  }
6900
6977
  const chunks = [];
6901
6978
  stdin.setEncoding("utf8");
@@ -6953,6 +7030,31 @@ async function runSecrets(opts, io = {
6953
7030
  return { exitCode: 1 };
6954
7031
  }
6955
7032
  }
7033
+ const replacing = opts.action === "set" && loaded.vault !== null && Object.hasOwn(loaded.vault.entries, opts.name);
7034
+ if (opts.action === "remove" && !opts.force) {
7035
+ if (isInteractiveTTY(opts)) {
7036
+ const confirmed = await promptYesNo(opts, `Permanently delete secret "${opts.name}"? This cannot be undone.`);
7037
+ if (confirmed === CANCELLED) return cancelledResult(io, opts.json);
7038
+ if (!confirmed) return abortedResult(io, opts.json, "remove");
7039
+ } else {
7040
+ const msg = `refusing to delete "${opts.name}" without confirmation and ${nonTTYEnds(opts)}.`;
7041
+ const hint = "Re-run with --force to delete it. This cannot be undone.";
7042
+ if (opts.json) io.err(`${JSON.stringify({ ok: false, error: `${msg} ${hint}` })}
7043
+ `);
7044
+ else io.err(`yaw-mcp secrets remove: ${msg}
7045
+ ${hint}
7046
+ `);
7047
+ return { exitCode: 2 };
7048
+ }
7049
+ }
7050
+ if (replacing && !opts.force && isInteractiveTTY(opts)) {
7051
+ const confirmed = await promptYesNo(
7052
+ opts,
7053
+ `Secret "${opts.name}" already exists. Replace it? The stored value is overwritten.`
7054
+ );
7055
+ if (confirmed === CANCELLED) return cancelledResult(io, opts.json);
7056
+ if (!confirmed) return abortedResult(io, opts.json, "set");
7057
+ }
6956
7058
  let vault = loaded.vault ?? newVault();
6957
7059
  const isFresh = !existsSync8(path7);
6958
7060
  const passphrase = await resolvePassphrase(opts);
@@ -7004,7 +7106,9 @@ async function runSecrets(opts, io = {
7004
7106
  return { exitCode: 1 };
7005
7107
  }
7006
7108
  await saveVault(path7, vault);
7007
- if (opts.json) io.out(`${JSON.stringify({ ok: true, name, fresh_vault: isFresh })}
7109
+ if (opts.json) io.out(`${JSON.stringify({ ok: true, name, fresh_vault: isFresh, replaced: replacing })}
7110
+ `);
7111
+ else if (replacing) io.out(`Replaced secret "${name}".
7008
7112
  `);
7009
7113
  else io.out(`${isFresh ? "Created vault and " : ""}Stored secret "${name}".
7010
7114
  `);
@@ -7293,7 +7397,7 @@ function defaultSpawn2(cmd, args) {
7293
7397
  async function maybeAutoUpgrade(deps = {}) {
7294
7398
  const optOut = process.env.YAW_MCP_AUTO_UPGRADE;
7295
7399
  if (optOut === "0" || optOut?.toLowerCase() === "false") return;
7296
- const current = deps.currentVersion ?? (true ? "0.72.0" : "dev");
7400
+ const current = deps.currentVersion ?? (true ? "0.73.0" : "dev");
7297
7401
  if (current === "dev") return;
7298
7402
  const method = (deps.isSeaImpl ? await deps.isSeaImpl() : await detectSea()) ? "binary" : detectInstallMethod(deps.argvPath ?? process.argv[1]);
7299
7403
  const latest = await (deps.fetchLatestImpl ?? fetchLatestVersion2)();
@@ -9954,14 +10058,14 @@ async function resolveServerEnv(env, namespace) {
9954
10058
  return resolved;
9955
10059
  }
9956
10060
  async function recordResolveAudit(namespace, env, missing) {
9957
- const missingSet = new Set(missing);
9958
- const referenced = collectSecretNames(env);
9959
- for (const name of referenced) {
9960
- if (missingSet.has(name)) continue;
9961
- await appendAuditEvent({ server: namespace, secret: name, event: "injected" });
10061
+ if (missing.length > 0) {
10062
+ for (const name of new Set(missing)) {
10063
+ await appendAuditEvent({ server: namespace, secret: name, event: "missing" });
10064
+ }
10065
+ return;
9962
10066
  }
9963
- for (const name of missingSet) {
9964
- await appendAuditEvent({ server: namespace, secret: name, event: "missing" });
10067
+ for (const name of collectSecretNames(env)) {
10068
+ await appendAuditEvent({ server: namespace, secret: name, event: "injected" });
9965
10069
  }
9966
10070
  }
9967
10071
  function collectSecretNames(env) {
@@ -10037,7 +10141,7 @@ async function connectToUpstream(config, onDisconnect, onListChanged) {
10037
10141
  }
10038
10142
  async function connectToUpstreamOnce(config, onDisconnect, onListChanged, attempt, disableOamRewrite) {
10039
10143
  const client = new Client(
10040
- { name: "yaw-mcp", version: true ? "0.72.0" : "dev" },
10144
+ { name: "yaw-mcp", version: true ? "0.73.0" : "dev" },
10041
10145
  { capabilities: {} }
10042
10146
  );
10043
10147
  let transport;
@@ -10405,7 +10509,7 @@ var ConnectServer = class _ConnectServer {
10405
10509
  this.apiUrl = apiUrl5;
10406
10510
  this.token = token5;
10407
10511
  this.server = new Server(
10408
- { name: "yaw-mcp", version: true ? "0.72.0" : "dev" },
10512
+ { name: "yaw-mcp", version: true ? "0.73.0" : "dev" },
10409
10513
  {
10410
10514
  capabilities: {
10411
10515
  tools: { listChanged: true },
@@ -13082,7 +13186,7 @@ function suggestFlag(input, limit = 2) {
13082
13186
  const q = input.toLowerCase();
13083
13187
  const hits = [];
13084
13188
  for (const alias of FLAG_ALIASES) {
13085
- if (alias.toLowerCase() === q) continue;
13189
+ if (alias === input) continue;
13086
13190
  const d = levenshtein(q, alias.toLowerCase());
13087
13191
  if (d <= 2) hits.push({ name: alias, d });
13088
13192
  }
@@ -13422,7 +13526,7 @@ if (subcommand === "compliance") {
13422
13526
  `);
13423
13527
  process.exitCode = 0;
13424
13528
  } else if (subcommand === "--version" || subcommand === "-V") {
13425
- process.stdout.write(`yaw-mcp ${true ? "0.72.0" : "dev"}
13529
+ process.stdout.write(`yaw-mcp ${true ? "0.73.0" : "dev"}
13426
13530
  `);
13427
13531
  process.exitCode = 0;
13428
13532
  } else if (subcommand && !subcommand.startsWith("-")) {
@@ -13438,7 +13542,12 @@ if (subcommand === "compliance") {
13438
13542
  `);
13439
13543
  process.exit(2);
13440
13544
  } else {
13441
- runServer();
13545
+ runServer().catch((err) => {
13546
+ const msg = err instanceof Error ? err.message : String(err);
13547
+ process.stderr.write(`yaw-mcp: ${msg}
13548
+ `);
13549
+ process.exitCode = 1;
13550
+ });
13442
13551
  }
13443
13552
  }
13444
13553
  async function runServer() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yawlabs/mcp",
3
- "version": "0.72.0",
3
+ "version": "0.73.0",
4
4
  "mcpName": "io.github.YawLabs/mcp",
5
5
  "description": "Yaw MCP -- MCP servers, managed. Free to run locally; Yaw Team adds cross-machine sync.",
6
6
  "license": "UNLICENSED",