@yawlabs/mcp 0.75.2 → 0.76.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/CHANGELOG.md +32 -0
- package/dist/auto-upgrade-UCSHJTHO.js +12 -0
- package/dist/{chunk-VHPGG3GN.js → chunk-32TGMWW7.js} +320 -46
- package/dist/chunk-C3AQHLOR.js +15 -0
- package/dist/chunk-SP5LWLFP.js +540 -0
- package/dist/index.js +683 -961
- package/dist/{oam-spawn-Z5CASEBY.js → oam-spawn-6TZ42IGK.js} +12 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,29 +1,57 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
CLAUDE_CODE_ALLOW_PATTERN,
|
|
3
4
|
CONFIG_DIRNAME,
|
|
5
|
+
CURRENT_OS,
|
|
6
|
+
ENTRY_NAME,
|
|
7
|
+
INSTALL_TARGETS,
|
|
8
|
+
LEGACY_ENTRY_NAMES,
|
|
4
9
|
MIN_OAM_VERSION,
|
|
10
|
+
buildLaunchEntry,
|
|
5
11
|
cacheDir,
|
|
6
12
|
compareVersions,
|
|
13
|
+
findLegacyEntry,
|
|
7
14
|
findProjectConfigDir,
|
|
8
15
|
guidePath,
|
|
9
16
|
isOamCommand,
|
|
10
17
|
isOamLaunch,
|
|
18
|
+
isProjectLocalEntry,
|
|
11
19
|
isRegistrySpec,
|
|
12
|
-
|
|
20
|
+
isUnderHome,
|
|
13
21
|
nodeLaunchKind,
|
|
14
22
|
npxSpec,
|
|
15
23
|
npxSpecIndex,
|
|
16
24
|
oamFailureLabel,
|
|
25
|
+
oamHeapOomHint,
|
|
26
|
+
oamInstallAdvice,
|
|
17
27
|
oamInstallCommand,
|
|
28
|
+
oamNoBinaryReason,
|
|
29
|
+
oamPublishesBinaryForThisMachine,
|
|
18
30
|
packageName,
|
|
19
31
|
probeOam,
|
|
32
|
+
resolveClaudeCodeSettingsPath,
|
|
33
|
+
resolveInstallPath,
|
|
20
34
|
resolveOamSpawn,
|
|
21
35
|
resolveStableNpmEntry,
|
|
22
36
|
sidecarsNodeModules,
|
|
23
37
|
sidecarsRoot,
|
|
24
38
|
specConstraint,
|
|
25
39
|
userConfigDir
|
|
26
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-32TGMWW7.js";
|
|
41
|
+
import {
|
|
42
|
+
BINARY_DOWNLOAD_URL,
|
|
43
|
+
buildUpgradePlan,
|
|
44
|
+
detectInstallMethod,
|
|
45
|
+
detectSea,
|
|
46
|
+
fetchLatestVersion,
|
|
47
|
+
maybeAutoUpgrade,
|
|
48
|
+
parseUpgradeArgs,
|
|
49
|
+
refineInstallMethod,
|
|
50
|
+
runUpgrade
|
|
51
|
+
} from "./chunk-SP5LWLFP.js";
|
|
52
|
+
import {
|
|
53
|
+
log
|
|
54
|
+
} from "./chunk-C3AQHLOR.js";
|
|
27
55
|
|
|
28
56
|
// src/audit-cmd.ts
|
|
29
57
|
import { homedir as homedir4 } from "os";
|
|
@@ -36,6 +64,26 @@ import { join } from "path";
|
|
|
36
64
|
// src/atomic-write.ts
|
|
37
65
|
import { chmod, mkdir, rename, stat, unlink, writeFile } from "fs/promises";
|
|
38
66
|
import path from "path";
|
|
67
|
+
import { setTimeout as delay } from "timers/promises";
|
|
68
|
+
var RENAME_RETRY_CODES = /* @__PURE__ */ new Set(["EPERM", "EBUSY", "EACCES"]);
|
|
69
|
+
var RENAME_RETRY_DELAYS_MS = [10, 50, 100];
|
|
70
|
+
async function renameWithRetry(tmp, target) {
|
|
71
|
+
if (process.platform !== "win32") {
|
|
72
|
+
await rename(tmp, target);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
for (const ms of RENAME_RETRY_DELAYS_MS) {
|
|
76
|
+
try {
|
|
77
|
+
await rename(tmp, target);
|
|
78
|
+
return;
|
|
79
|
+
} catch (err) {
|
|
80
|
+
const code = err.code;
|
|
81
|
+
if (code === void 0 || !RENAME_RETRY_CODES.has(code)) throw err;
|
|
82
|
+
await delay(ms);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
await rename(tmp, target);
|
|
86
|
+
}
|
|
39
87
|
var tmpSeq = 0;
|
|
40
88
|
async function atomicWriteFile(filePath, contents, encoding = "utf8", mode, dirMode) {
|
|
41
89
|
const dir = path.dirname(filePath);
|
|
@@ -57,7 +105,7 @@ async function atomicWriteFile(filePath, contents, encoding = "utf8", mode, dirM
|
|
|
57
105
|
} catch {
|
|
58
106
|
}
|
|
59
107
|
}
|
|
60
|
-
await
|
|
108
|
+
await renameWithRetry(tmp, filePath);
|
|
61
109
|
} catch (err) {
|
|
62
110
|
await unlink(tmp).catch(() => void 0);
|
|
63
111
|
throw err;
|
|
@@ -238,7 +286,8 @@ function validateEntry(entry) {
|
|
|
238
286
|
if (score < MIN_SCORE || score > MAX_SCORE) return null;
|
|
239
287
|
const gradedAt = typeof e.gradedAt === "string" && e.gradedAt.length > 0 ? e.gradedAt : "";
|
|
240
288
|
if (!gradedAt) return null;
|
|
241
|
-
|
|
289
|
+
const suiteVersion = typeof e.suiteVersion === "string" && e.suiteVersion.length > 0 ? e.suiteVersion : void 0;
|
|
290
|
+
return suiteVersion ? { grade, score, gradedAt, suiteVersion } : { grade, score, gradedAt };
|
|
242
291
|
}
|
|
243
292
|
async function readGradesCache(home = homedir()) {
|
|
244
293
|
const path6 = gradesCachePath(home);
|
|
@@ -327,7 +376,8 @@ function trustStorePath(home = homedir2()) {
|
|
|
327
376
|
}
|
|
328
377
|
function normalizeTrustKey(p) {
|
|
329
378
|
const resolved = resolve(p);
|
|
330
|
-
|
|
379
|
+
const caseInsensitiveFs = process.platform === "win32" || process.platform === "darwin";
|
|
380
|
+
return caseInsensitiveFs ? resolved.toLowerCase() : resolved;
|
|
331
381
|
}
|
|
332
382
|
function hashTrustContent(contents) {
|
|
333
383
|
return createHash("sha256").update(contents).digest("hex");
|
|
@@ -488,7 +538,7 @@ function validateEntry2(entry, warnings) {
|
|
|
488
538
|
const command = typeof e.command === "string" ? e.command : void 0;
|
|
489
539
|
const args = Array.isArray(e.args) ? e.args.filter((a) => typeof a === "string") : void 0;
|
|
490
540
|
const env = e.env && typeof e.env === "object" && !Array.isArray(e.env) ? Object.fromEntries(
|
|
491
|
-
Object.entries(e.env).filter(([, v]) => typeof v === "string")
|
|
541
|
+
Object.entries(e.env).filter(([, v]) => typeof v === "string" && v.trim() !== "")
|
|
492
542
|
) : void 0;
|
|
493
543
|
const url = typeof e.url === "string" ? e.url : void 0;
|
|
494
544
|
const description = typeof e.description === "string" ? e.description : void 0;
|
|
@@ -940,14 +990,14 @@ function findServer(servers, namespace) {
|
|
|
940
990
|
return servers.find((s) => s.namespace === namespace);
|
|
941
991
|
}
|
|
942
992
|
async function defaultRunner(target) {
|
|
943
|
-
const { runComplianceSuite } = await import("@yawlabs/mcp-compliance");
|
|
993
|
+
const { runComplianceSuite, SPEC_VERSION } = await import("@yawlabs/mcp-compliance");
|
|
944
994
|
const report = await runComplianceSuite({
|
|
945
995
|
type: "stdio",
|
|
946
996
|
command: target.command,
|
|
947
997
|
args: target.args,
|
|
948
998
|
env: target.env
|
|
949
999
|
});
|
|
950
|
-
return { grade: report.grade, score: report.score };
|
|
1000
|
+
return { grade: report.grade, score: report.score, suiteVersion: SPEC_VERSION };
|
|
951
1001
|
}
|
|
952
1002
|
async function runAudit(opts = {}) {
|
|
953
1003
|
const write = opts.out ?? ((s) => process.stdout.write(s));
|
|
@@ -969,7 +1019,8 @@ async function runAudit(opts = {}) {
|
|
|
969
1019
|
return { exitCode: 2, lines };
|
|
970
1020
|
}
|
|
971
1021
|
const home = opts.home ?? homedir4();
|
|
972
|
-
const { config, path: path6 } = await loadLocalBundles({ cwd: opts.cwd, home });
|
|
1022
|
+
const { config, path: path6, warnings } = await loadLocalBundles({ cwd: opts.cwd, home });
|
|
1023
|
+
for (const w of warnings) printErr(`warning: ${w}`);
|
|
973
1024
|
const servers = config?.servers ?? [];
|
|
974
1025
|
const server = findServer(servers, namespace);
|
|
975
1026
|
if (!server) {
|
|
@@ -1012,7 +1063,11 @@ async function runAudit(opts = {}) {
|
|
|
1012
1063
|
let cachePath = null;
|
|
1013
1064
|
let cacheError = null;
|
|
1014
1065
|
try {
|
|
1015
|
-
cachePath = await writeGrade(
|
|
1066
|
+
cachePath = await writeGrade(
|
|
1067
|
+
namespace,
|
|
1068
|
+
report.suiteVersion ? { grade: report.grade, score: report.score, gradedAt, suiteVersion: report.suiteVersion } : { grade: report.grade, score: report.score, gradedAt },
|
|
1069
|
+
home
|
|
1070
|
+
);
|
|
1016
1071
|
} catch (err) {
|
|
1017
1072
|
cacheError = err instanceof Error ? err.message : String(err);
|
|
1018
1073
|
log("error", "audit: grade cache write failed", { namespace, error: cacheError });
|
|
@@ -1060,7 +1115,10 @@ var CURATED_BUNDLES = [
|
|
|
1060
1115
|
id: "growth-stack",
|
|
1061
1116
|
name: "Growth Stack",
|
|
1062
1117
|
description: "HubSpot + Slack + GA for lifecycle + funnel signals",
|
|
1063
|
-
|
|
1118
|
+
// NOT "ga": the catalog slug is `ga`, but every install path derives the
|
|
1119
|
+
// namespace from the row's NAME ("Google Analytics"), so the installed
|
|
1120
|
+
// namespace is `googleanalytics` and the slug form can never match.
|
|
1121
|
+
namespaces: ["hubspot", "slack", "googleanalytics"],
|
|
1064
1122
|
category: "growth"
|
|
1065
1123
|
},
|
|
1066
1124
|
{
|
|
@@ -1120,7 +1178,7 @@ import { join as join5, resolve as resolve3 } from "path";
|
|
|
1120
1178
|
|
|
1121
1179
|
// src/migrate.ts
|
|
1122
1180
|
import { mkdir as mkdir2, rename as rename2, stat as stat2 } from "fs/promises";
|
|
1123
|
-
import { dirname,
|
|
1181
|
+
import { dirname, join as join4, resolve as resolve2 } from "path";
|
|
1124
1182
|
var LEGACY_GLOBAL_FILENAME = ".yaw-mcp.json";
|
|
1125
1183
|
var LEGACY_PROJECT_FILENAME = ".yaw-mcp.json";
|
|
1126
1184
|
var LEGACY_LOCAL_FILENAME = ".yaw-mcp.local.json";
|
|
@@ -1203,15 +1261,6 @@ async function migrateLegacyConfigPaths(opts) {
|
|
|
1203
1261
|
await migrateFile(legacyProject, newProject, "project");
|
|
1204
1262
|
}
|
|
1205
1263
|
}
|
|
1206
|
-
function normalizeForCompare(p) {
|
|
1207
|
-
return process.platform === "win32" ? p.toLowerCase() : p;
|
|
1208
|
-
}
|
|
1209
|
-
function isUnderHome(dir, homeResolved) {
|
|
1210
|
-
if (normalizeForCompare(dir) === normalizeForCompare(homeResolved)) return false;
|
|
1211
|
-
const rel = relative(homeResolved, dir);
|
|
1212
|
-
const relNorm = normalizeForCompare(rel);
|
|
1213
|
-
return relNorm !== "" && !relNorm.startsWith("..") && !isAbsolute(rel);
|
|
1214
|
-
}
|
|
1215
1264
|
async function findLegacyProjectRoot(cwd, home) {
|
|
1216
1265
|
const homeResolved = resolve2(home);
|
|
1217
1266
|
let dir = resolve2(cwd);
|
|
@@ -1726,7 +1775,7 @@ function renderBash() {
|
|
|
1726
1775
|
const topLevelFlags = "--help -h --version -V";
|
|
1727
1776
|
const cases = SUBCOMMAND_SPEC.map((spec) => {
|
|
1728
1777
|
const posClauses = realPositionals(spec).map(
|
|
1729
|
-
({ candidates, index }) => ` if [[ $cword -eq $((${index} + 2)) ]]; then
|
|
1778
|
+
({ candidates, index }) => ` if [[ $cword -eq $((${index} + 2)) && $cur != -* ]]; then
|
|
1730
1779
|
COMPREPLY=( $(compgen -W "${candidates.join(" ")}" -- "$cur") )
|
|
1731
1780
|
return 0
|
|
1732
1781
|
fi`
|
|
@@ -1984,13 +2033,13 @@ function killTree(child) {
|
|
|
1984
2033
|
}
|
|
1985
2034
|
}
|
|
1986
2035
|
function runTest(args, err) {
|
|
1987
|
-
return new Promise((
|
|
2036
|
+
return new Promise((resolve7) => {
|
|
1988
2037
|
let settled = false;
|
|
1989
2038
|
const fail = (message) => {
|
|
1990
2039
|
if (settled) return;
|
|
1991
2040
|
settled = true;
|
|
1992
2041
|
err(message);
|
|
1993
|
-
|
|
2042
|
+
resolve7(null);
|
|
1994
2043
|
};
|
|
1995
2044
|
const npxArgs = ["-y", "@yawlabs/mcp-compliance", "test", "--format", "json", ...args];
|
|
1996
2045
|
const launch = resolveNpxLaunch(npxArgs);
|
|
@@ -2022,7 +2071,7 @@ Failed to launch mcp-compliance: ${e instanceof Error ? e.message : String(e)}
|
|
|
2022
2071
|
process.off("SIGINT", onInterrupt);
|
|
2023
2072
|
process.off("SIGTERM", onInterrupt);
|
|
2024
2073
|
};
|
|
2025
|
-
|
|
2074
|
+
const stdoutChunks = [];
|
|
2026
2075
|
let stdoutBytes = 0;
|
|
2027
2076
|
const timer = setTimeout(() => {
|
|
2028
2077
|
if (settled) return;
|
|
@@ -2032,7 +2081,7 @@ Failed to launch mcp-compliance: ${e instanceof Error ? e.message : String(e)}
|
|
|
2032
2081
|
err(`
|
|
2033
2082
|
mcp-compliance timed out after ${CHILD_TIMEOUT_MS / 1e3}s; killed.
|
|
2034
2083
|
`);
|
|
2035
|
-
|
|
2084
|
+
resolve7(null);
|
|
2036
2085
|
}, CHILD_TIMEOUT_MS);
|
|
2037
2086
|
timer.unref?.();
|
|
2038
2087
|
child.stdout?.on("data", (chunk) => {
|
|
@@ -2046,10 +2095,10 @@ mcp-compliance timed out after ${CHILD_TIMEOUT_MS / 1e3}s; killed.
|
|
|
2046
2095
|
err(`
|
|
2047
2096
|
mcp-compliance produced more than ${MAX_STDOUT_BYTES / (1024 * 1024)} MB of output; killed.
|
|
2048
2097
|
`);
|
|
2049
|
-
|
|
2098
|
+
resolve7(null);
|
|
2050
2099
|
return;
|
|
2051
2100
|
}
|
|
2052
|
-
|
|
2101
|
+
stdoutChunks.push(chunk);
|
|
2053
2102
|
});
|
|
2054
2103
|
child.on("error", (e) => {
|
|
2055
2104
|
if (settled) return;
|
|
@@ -2064,21 +2113,22 @@ Failed to launch mcp-compliance: ${e.message}
|
|
|
2064
2113
|
settled = true;
|
|
2065
2114
|
clearTimeout(timer);
|
|
2066
2115
|
releaseSignals();
|
|
2116
|
+
const stdout = Buffer.concat(stdoutChunks).toString("utf8");
|
|
2067
2117
|
try {
|
|
2068
2118
|
const parsed = JSON.parse(stdout);
|
|
2069
2119
|
if (!isRenderableReport(parsed)) {
|
|
2070
2120
|
err(`
|
|
2071
2121
|
mcp-compliance returned unexpected JSON (exit ${code}).
|
|
2072
2122
|
`);
|
|
2073
|
-
|
|
2123
|
+
resolve7(null);
|
|
2074
2124
|
return;
|
|
2075
2125
|
}
|
|
2076
|
-
|
|
2126
|
+
resolve7({ report: parsed, code });
|
|
2077
2127
|
} catch {
|
|
2078
2128
|
err(`
|
|
2079
2129
|
mcp-compliance exited ${code} without valid JSON output.
|
|
2080
2130
|
`);
|
|
2081
|
-
|
|
2131
|
+
resolve7(null);
|
|
2082
2132
|
}
|
|
2083
2133
|
});
|
|
2084
2134
|
});
|
|
@@ -2096,8 +2146,8 @@ Target: ${url}
|
|
|
2096
2146
|
// src/doctor-cmd.ts
|
|
2097
2147
|
import { closeSync, existsSync as existsSync6, fstatSync, openSync, readFileSync as readFileSync2, readSync } from "fs";
|
|
2098
2148
|
import { readFile as readFile9 } from "fs/promises";
|
|
2099
|
-
import { homedir as
|
|
2100
|
-
import { isAbsolute
|
|
2149
|
+
import { homedir as homedir9 } from "os";
|
|
2150
|
+
import { isAbsolute, join as join8 } from "path";
|
|
2101
2151
|
|
|
2102
2152
|
// src/cli-shadows.ts
|
|
2103
2153
|
var EMPTY = [];
|
|
@@ -2472,220 +2522,6 @@ function renderActiveServersSection(activeServers) {
|
|
|
2472
2522
|
].join("\n");
|
|
2473
2523
|
}
|
|
2474
2524
|
|
|
2475
|
-
// src/install-targets.ts
|
|
2476
|
-
import { homedir as homedir6 } from "os";
|
|
2477
|
-
import { isAbsolute as isAbsolute2, join as join6, resolve as resolve4 } from "path";
|
|
2478
|
-
var CURRENT_OS = process.platform === "darwin" ? "macos" : process.platform === "win32" ? "windows" : "linux";
|
|
2479
|
-
var INSTALL_TARGETS = [
|
|
2480
|
-
{
|
|
2481
|
-
clientId: "claude-code",
|
|
2482
|
-
label: "Claude Code",
|
|
2483
|
-
jsonShape: "mcpServers",
|
|
2484
|
-
availableOn: ["macos", "linux", "windows"],
|
|
2485
|
-
scopes: [
|
|
2486
|
-
{
|
|
2487
|
-
scope: "user",
|
|
2488
|
-
label: "User (global)",
|
|
2489
|
-
description: "Private to this machine; applies to every project.",
|
|
2490
|
-
requiresProjectDir: false
|
|
2491
|
-
},
|
|
2492
|
-
{
|
|
2493
|
-
scope: "project",
|
|
2494
|
-
label: "Project",
|
|
2495
|
-
description: "Commit to share with your team.",
|
|
2496
|
-
requiresProjectDir: true
|
|
2497
|
-
},
|
|
2498
|
-
{
|
|
2499
|
-
scope: "local",
|
|
2500
|
-
label: "Local",
|
|
2501
|
-
description: "Per-project override; typically gitignored.",
|
|
2502
|
-
requiresProjectDir: true
|
|
2503
|
-
}
|
|
2504
|
-
]
|
|
2505
|
-
},
|
|
2506
|
-
{
|
|
2507
|
-
clientId: "claude-desktop",
|
|
2508
|
-
label: "Claude Desktop",
|
|
2509
|
-
jsonShape: "mcpServers",
|
|
2510
|
-
availableOn: ["macos", "windows"],
|
|
2511
|
-
notes: "Claude Desktop reads one file per OS \u2014 no project scope. Restart the app after editing.",
|
|
2512
|
-
scopes: [
|
|
2513
|
-
{
|
|
2514
|
-
scope: "user",
|
|
2515
|
-
label: "User",
|
|
2516
|
-
description: "The only config file Claude Desktop reads.",
|
|
2517
|
-
requiresProjectDir: false
|
|
2518
|
-
}
|
|
2519
|
-
]
|
|
2520
|
-
},
|
|
2521
|
-
{
|
|
2522
|
-
clientId: "cursor",
|
|
2523
|
-
label: "Cursor",
|
|
2524
|
-
jsonShape: "mcpServers",
|
|
2525
|
-
availableOn: ["macos", "linux", "windows"],
|
|
2526
|
-
scopes: [
|
|
2527
|
-
{
|
|
2528
|
-
scope: "user",
|
|
2529
|
-
label: "User (global)",
|
|
2530
|
-
description: "Private to this machine; applies to every Cursor project.",
|
|
2531
|
-
requiresProjectDir: false
|
|
2532
|
-
},
|
|
2533
|
-
{
|
|
2534
|
-
scope: "project",
|
|
2535
|
-
label: "Project",
|
|
2536
|
-
description: "Commit to share with your team.",
|
|
2537
|
-
requiresProjectDir: true
|
|
2538
|
-
}
|
|
2539
|
-
]
|
|
2540
|
-
},
|
|
2541
|
-
{
|
|
2542
|
-
clientId: "vscode",
|
|
2543
|
-
label: "VS Code",
|
|
2544
|
-
jsonShape: "servers",
|
|
2545
|
-
availableOn: ["macos", "linux", "windows"],
|
|
2546
|
-
notes: "VS Code uses `servers` (not `mcpServers`) as the top-level key in .vscode/mcp.json.",
|
|
2547
|
-
scopes: [
|
|
2548
|
-
{
|
|
2549
|
-
scope: "project",
|
|
2550
|
-
label: "Workspace",
|
|
2551
|
-
description: "Per-project config; commit to share.",
|
|
2552
|
-
requiresProjectDir: true
|
|
2553
|
-
}
|
|
2554
|
-
]
|
|
2555
|
-
}
|
|
2556
|
-
];
|
|
2557
|
-
function resolveInstallPath(opts) {
|
|
2558
|
-
const home = opts.home ?? homedir6();
|
|
2559
|
-
const appData = opts.appData ?? process.env.APPDATA ?? join6(home, "AppData", "Roaming");
|
|
2560
|
-
const { clientId, scope, os, projectDir, claudeConfigDir } = opts;
|
|
2561
|
-
const target = INSTALL_TARGETS.find((t) => t.clientId === clientId);
|
|
2562
|
-
if (!target) throw new Error(`Unknown client: ${clientId}`);
|
|
2563
|
-
const scopeSpec = target.scopes.find((s) => s.scope === scope);
|
|
2564
|
-
if (!scopeSpec) throw new Error(`Client ${clientId} does not support scope ${scope}`);
|
|
2565
|
-
if (!target.availableOn.includes(os)) {
|
|
2566
|
-
throw new Error(`${target.label} is not available on ${os}`);
|
|
2567
|
-
}
|
|
2568
|
-
if (scopeSpec.requiresProjectDir && !projectDir) {
|
|
2569
|
-
throw new Error(`Scope ${scope} for ${clientId} requires a project directory`);
|
|
2570
|
-
}
|
|
2571
|
-
const absoluteProjectDir = projectDir && !isAbsolute2(projectDir) ? resolve4(projectDir) : projectDir;
|
|
2572
|
-
const p = pathFor(clientId, scope, os, {
|
|
2573
|
-
home,
|
|
2574
|
-
appData,
|
|
2575
|
-
projectDir: absoluteProjectDir ?? "",
|
|
2576
|
-
claudeConfigDir: claudeConfigDir && claudeConfigDir.length > 0 ? claudeConfigDir : void 0
|
|
2577
|
-
});
|
|
2578
|
-
return p;
|
|
2579
|
-
}
|
|
2580
|
-
function pathFor(client, scope, os, base) {
|
|
2581
|
-
const { home, appData, projectDir, claudeConfigDir } = base;
|
|
2582
|
-
const sep2 = os === "windows" ? "\\" : "/";
|
|
2583
|
-
const joinPath = (...parts) => parts.join(sep2);
|
|
2584
|
-
if (client === "claude-code") {
|
|
2585
|
-
if (scope === "user") {
|
|
2586
|
-
if (claudeConfigDir) {
|
|
2587
|
-
const absolute = join6(claudeConfigDir, ".claude.json");
|
|
2588
|
-
return { absolute, display: absolute, containerPath: ["mcpServers"] };
|
|
2589
|
-
}
|
|
2590
|
-
const display = os === "windows" ? "%USERPROFILE%\\.claude.json" : "~/.claude.json";
|
|
2591
|
-
return { absolute: join6(home, ".claude.json"), display, containerPath: ["mcpServers"] };
|
|
2592
|
-
}
|
|
2593
|
-
if (scope === "project") {
|
|
2594
|
-
return {
|
|
2595
|
-
absolute: join6(projectDir, ".mcp.json"),
|
|
2596
|
-
display: joinPath("<project folder>", ".mcp.json"),
|
|
2597
|
-
containerPath: ["mcpServers"]
|
|
2598
|
-
};
|
|
2599
|
-
}
|
|
2600
|
-
if (claudeConfigDir) {
|
|
2601
|
-
const absolute = join6(claudeConfigDir, ".claude.json");
|
|
2602
|
-
return { absolute, display: absolute, containerPath: ["projects", projectDir, "mcpServers"] };
|
|
2603
|
-
}
|
|
2604
|
-
return {
|
|
2605
|
-
absolute: join6(home, ".claude.json"),
|
|
2606
|
-
display: os === "windows" ? "%USERPROFILE%\\.claude.json" : "~/.claude.json",
|
|
2607
|
-
containerPath: ["projects", projectDir, "mcpServers"]
|
|
2608
|
-
};
|
|
2609
|
-
}
|
|
2610
|
-
if (client === "claude-desktop") {
|
|
2611
|
-
if (os === "macos") {
|
|
2612
|
-
return {
|
|
2613
|
-
absolute: join6(home, "Library", "Application Support", "Claude", "claude_desktop_config.json"),
|
|
2614
|
-
display: "~/Library/Application Support/Claude/claude_desktop_config.json",
|
|
2615
|
-
containerPath: ["mcpServers"]
|
|
2616
|
-
};
|
|
2617
|
-
}
|
|
2618
|
-
if (os === "windows") {
|
|
2619
|
-
return {
|
|
2620
|
-
absolute: join6(appData, "Claude", "claude_desktop_config.json"),
|
|
2621
|
-
display: "%APPDATA%\\Claude\\claude_desktop_config.json",
|
|
2622
|
-
containerPath: ["mcpServers"]
|
|
2623
|
-
};
|
|
2624
|
-
}
|
|
2625
|
-
throw new Error("Claude Desktop is not available on Linux");
|
|
2626
|
-
}
|
|
2627
|
-
if (client === "cursor") {
|
|
2628
|
-
if (scope === "user") {
|
|
2629
|
-
const display = os === "windows" ? "%USERPROFILE%\\.cursor\\mcp.json" : "~/.cursor/mcp.json";
|
|
2630
|
-
return { absolute: join6(home, ".cursor", "mcp.json"), display, containerPath: ["mcpServers"] };
|
|
2631
|
-
}
|
|
2632
|
-
return {
|
|
2633
|
-
absolute: join6(projectDir, ".cursor", "mcp.json"),
|
|
2634
|
-
display: joinPath("<project folder>", ".cursor", "mcp.json"),
|
|
2635
|
-
containerPath: ["mcpServers"]
|
|
2636
|
-
};
|
|
2637
|
-
}
|
|
2638
|
-
if (client === "vscode") {
|
|
2639
|
-
return {
|
|
2640
|
-
absolute: join6(projectDir, ".vscode", "mcp.json"),
|
|
2641
|
-
display: joinPath("<project folder>", ".vscode", "mcp.json"),
|
|
2642
|
-
containerPath: ["servers"]
|
|
2643
|
-
};
|
|
2644
|
-
}
|
|
2645
|
-
throw new Error(`Unhandled client: ${client}`);
|
|
2646
|
-
}
|
|
2647
|
-
function buildLaunchEntry(opts) {
|
|
2648
|
-
if (opts.upstream) {
|
|
2649
|
-
const { command, args, env } = opts.upstream;
|
|
2650
|
-
if (opts.os === "windows") {
|
|
2651
|
-
const wrapped = { command: "cmd", args: ["/c", command, ...args] };
|
|
2652
|
-
if (env && Object.keys(env).length > 0) wrapped.env = { ...env };
|
|
2653
|
-
return wrapped;
|
|
2654
|
-
}
|
|
2655
|
-
const entry = { command, args: [...args] };
|
|
2656
|
-
if (env && Object.keys(env).length > 0) entry.env = { ...env };
|
|
2657
|
-
return entry;
|
|
2658
|
-
}
|
|
2659
|
-
const pkg = opts.pkg ?? "@yawlabs/mcp@latest";
|
|
2660
|
-
if (opts.oamBinPath && isAbsolute2(opts.oamBinPath) && opts.oamEntry && !opts.pkg) {
|
|
2661
|
-
return { command: opts.oamBinPath, args: ["run", "--no-check", opts.oamEntry] };
|
|
2662
|
-
}
|
|
2663
|
-
return opts.os === "windows" ? { command: "cmd", args: ["/c", "npx", "-y", pkg] } : { command: "npx", args: ["-y", pkg] };
|
|
2664
|
-
}
|
|
2665
|
-
function isProjectLocalEntry(entryPath, cwd) {
|
|
2666
|
-
const norm = (p) => p.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
|
|
2667
|
-
const entry = norm(entryPath);
|
|
2668
|
-
const here = norm(cwd);
|
|
2669
|
-
const idx = entry.indexOf("/node_modules/");
|
|
2670
|
-
if (idx <= 0) return false;
|
|
2671
|
-
const root = entry.slice(0, idx);
|
|
2672
|
-
return here === root || here.startsWith(`${root}/`);
|
|
2673
|
-
}
|
|
2674
|
-
var ENTRY_NAME = "mcp";
|
|
2675
|
-
var LEGACY_ENTRY_NAMES = ["mcp.hosting", "mcph", "yaw-mcp"];
|
|
2676
|
-
function findLegacyEntry(container) {
|
|
2677
|
-
return LEGACY_ENTRY_NAMES.find((n) => n in container) ?? null;
|
|
2678
|
-
}
|
|
2679
|
-
var CLAUDE_CODE_ALLOW_PATTERN = "mcp__mcp__*";
|
|
2680
|
-
function resolveClaudeCodeSettingsPath(scope, opts) {
|
|
2681
|
-
const { home, projectDir, claudeConfigDir } = opts;
|
|
2682
|
-
const cfgDir = claudeConfigDir && claudeConfigDir.length > 0 ? claudeConfigDir : null;
|
|
2683
|
-
if (scope === "user") return cfgDir ? join6(cfgDir, "settings.json") : join6(home, ".claude", "settings.json");
|
|
2684
|
-
if (scope === "project" && projectDir) return join6(projectDir, ".claude", "settings.json");
|
|
2685
|
-
if (scope === "local" && projectDir) return join6(projectDir, ".claude", "settings.local.json");
|
|
2686
|
-
return null;
|
|
2687
|
-
}
|
|
2688
|
-
|
|
2689
2525
|
// src/persistence.ts
|
|
2690
2526
|
import { readFile as readFile6 } from "fs/promises";
|
|
2691
2527
|
import path2 from "path";
|
|
@@ -2714,7 +2550,7 @@ function emptyState() {
|
|
|
2714
2550
|
async function loadState(filePath = statePath()) {
|
|
2715
2551
|
try {
|
|
2716
2552
|
const raw = await readFile6(filePath, "utf8");
|
|
2717
|
-
const parsed = JSON.parse(raw);
|
|
2553
|
+
const parsed = JSON.parse(raw.charCodeAt(0) === 65279 ? raw.slice(1) : raw);
|
|
2718
2554
|
if (!parsed || typeof parsed !== "object") return emptyState();
|
|
2719
2555
|
if (!isReadableStateVersion(parsed.version)) return emptyState();
|
|
2720
2556
|
const p = parsed;
|
|
@@ -2822,12 +2658,12 @@ function errorMessage(err) {
|
|
|
2822
2658
|
// src/sidecars-cmd.ts
|
|
2823
2659
|
import { spawn as spawn2 } from "child_process";
|
|
2824
2660
|
import { existsSync as existsSync3, mkdirSync, readFileSync } from "fs";
|
|
2825
|
-
import { homedir as
|
|
2826
|
-
import { join as
|
|
2661
|
+
import { homedir as homedir6 } from "os";
|
|
2662
|
+
import { join as join6 } from "path";
|
|
2827
2663
|
function collectSidecarSpecs(servers) {
|
|
2828
2664
|
const byPkg = /* @__PURE__ */ new Map();
|
|
2829
2665
|
for (const s of servers) {
|
|
2830
|
-
if (s.type !== "local" || s.command !== "npx") continue;
|
|
2666
|
+
if (s.type !== "local" || s.command === void 0 || nodeLaunchKind(s.command) !== "npx") continue;
|
|
2831
2667
|
const spec = npxSpec(s.args ?? []);
|
|
2832
2668
|
if (spec === null) continue;
|
|
2833
2669
|
if (!isRegistrySpec(spec)) continue;
|
|
@@ -2846,7 +2682,7 @@ function collectSidecarSpecs(servers) {
|
|
|
2846
2682
|
function collectNonRegistrySpecs(servers) {
|
|
2847
2683
|
const out = [];
|
|
2848
2684
|
for (const s of servers) {
|
|
2849
|
-
if (s.type !== "local" || s.command !== "npx") continue;
|
|
2685
|
+
if (s.type !== "local" || s.command === void 0 || nodeLaunchKind(s.command) !== "npx") continue;
|
|
2850
2686
|
const spec = npxSpec(s.args ?? []);
|
|
2851
2687
|
if (spec === null || isRegistrySpec(spec)) continue;
|
|
2852
2688
|
out.push({ namespace: s.namespace ?? "(unnamed)", spec });
|
|
@@ -2872,8 +2708,22 @@ function sidecarsManifest(specs) {
|
|
|
2872
2708
|
)}
|
|
2873
2709
|
`;
|
|
2874
2710
|
}
|
|
2875
|
-
function
|
|
2876
|
-
|
|
2711
|
+
function sidecarsPlatformPath(home = homedir6()) {
|
|
2712
|
+
return join6(sidecarsRoot(home), "platform.json");
|
|
2713
|
+
}
|
|
2714
|
+
function installedPlatform(home = homedir6()) {
|
|
2715
|
+
try {
|
|
2716
|
+
const raw = JSON.parse(readFileSync(sidecarsPlatformPath(home), "utf8"));
|
|
2717
|
+
if (typeof raw?.platform === "string" && typeof raw?.arch === "string") {
|
|
2718
|
+
return { platform: raw.platform, arch: raw.arch };
|
|
2719
|
+
}
|
|
2720
|
+
return null;
|
|
2721
|
+
} catch {
|
|
2722
|
+
return null;
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
2725
|
+
function installedVersion(pkg, home = homedir6()) {
|
|
2726
|
+
const pj = join6(sidecarsNodeModules(home), ...pkg.split("/"), "package.json");
|
|
2877
2727
|
try {
|
|
2878
2728
|
const v = JSON.parse(readFileSync(pj, "utf8")).version;
|
|
2879
2729
|
return typeof v === "string" ? v : null;
|
|
@@ -2897,7 +2747,7 @@ function jsonDocument(root, over = {}) {
|
|
|
2897
2747
|
`;
|
|
2898
2748
|
}
|
|
2899
2749
|
function defaultRunNpm(args, cwd) {
|
|
2900
|
-
return new Promise((
|
|
2750
|
+
return new Promise((resolve7) => {
|
|
2901
2751
|
const isWindows = process.platform === "win32";
|
|
2902
2752
|
let child;
|
|
2903
2753
|
try {
|
|
@@ -2915,11 +2765,11 @@ function defaultRunNpm(args, cwd) {
|
|
|
2915
2765
|
shell: isWindows
|
|
2916
2766
|
});
|
|
2917
2767
|
} catch {
|
|
2918
|
-
|
|
2768
|
+
resolve7(-1);
|
|
2919
2769
|
return;
|
|
2920
2770
|
}
|
|
2921
|
-
child.on("error", () =>
|
|
2922
|
-
child.on("close", (code, signal) =>
|
|
2771
|
+
child.on("error", () => resolve7(-1));
|
|
2772
|
+
child.on("close", (code, signal) => resolve7(code ?? (signal ? -1 : 0)));
|
|
2923
2773
|
});
|
|
2924
2774
|
}
|
|
2925
2775
|
var SIDECARS_USAGE = `Usage: yaw-mcp sidecars install [--json]
|
|
@@ -2962,7 +2812,9 @@ ${SIDECARS_USAGE}` };
|
|
|
2962
2812
|
return { ok: true, options: { json } };
|
|
2963
2813
|
}
|
|
2964
2814
|
async function unhostedReasons(servers, opts, home) {
|
|
2965
|
-
const npx = servers.filter(
|
|
2815
|
+
const npx = servers.filter(
|
|
2816
|
+
(s) => s.type === "local" && s.command !== void 0 && nodeLaunchKind(s.command) === "npx"
|
|
2817
|
+
);
|
|
2966
2818
|
if (npx.length === 0) return [];
|
|
2967
2819
|
const probe = await (opts.oamProbe ?? probeOam)();
|
|
2968
2820
|
const { runtime: configDefault } = await describeDefaultRuntime({ cwd: opts.cwd, home });
|
|
@@ -2984,7 +2836,7 @@ async function unhostedReasons(servers, opts, home) {
|
|
|
2984
2836
|
return [...new Set(verdicts.map((v) => v.reason))];
|
|
2985
2837
|
}
|
|
2986
2838
|
async function runSidecarsInstall(opts = {}) {
|
|
2987
|
-
const home = opts.home ??
|
|
2839
|
+
const home = opts.home ?? homedir6();
|
|
2988
2840
|
const write = opts.out ?? ((s) => process.stdout.write(s));
|
|
2989
2841
|
const lines = [];
|
|
2990
2842
|
const print = (s = "") => {
|
|
@@ -3035,7 +2887,7 @@ async function runSidecarsInstall(opts = {}) {
|
|
|
3035
2887
|
return { exitCode: 0, installed: [], lines };
|
|
3036
2888
|
}
|
|
3037
2889
|
mkdirSync(root, { recursive: true });
|
|
3038
|
-
await atomicWriteFile(
|
|
2890
|
+
await atomicWriteFile(join6(root, "package.json"), sidecarsManifest(specs));
|
|
3039
2891
|
print(`Installing ${specs.length} server package(s) into ${root}`);
|
|
3040
2892
|
if (bundles.path !== null) {
|
|
3041
2893
|
print(` from ${bundles.path}`);
|
|
@@ -3060,6 +2912,11 @@ async function runSidecarsInstall(opts = {}) {
|
|
|
3060
2912
|
if (opts.json) write(jsonDocument(root, { error: `npm exited ${code}`, conflicts, skipped }));
|
|
3061
2913
|
return { exitCode: 1, installed: [], lines };
|
|
3062
2914
|
}
|
|
2915
|
+
await atomicWriteFile(
|
|
2916
|
+
sidecarsPlatformPath(home),
|
|
2917
|
+
`${JSON.stringify({ platform: process.platform, arch: process.arch }, null, 2)}
|
|
2918
|
+
`
|
|
2919
|
+
);
|
|
3063
2920
|
const updateCode = await runNpm(["update", "--no-audit", "--no-fund"], root);
|
|
3064
2921
|
const updateError = updateCode === 0 ? null : `npm update exited ${updateCode}`;
|
|
3065
2922
|
const installed = specs.map((s) => ({
|
|
@@ -3094,15 +2951,15 @@ async function runSidecarsInstall(opts = {}) {
|
|
|
3094
2951
|
if (opts.json) write(jsonDocument(root, { installed, conflicts, skipped, error, updateError, unhosted }));
|
|
3095
2952
|
return { exitCode: nothingLanded ? 1 : 0, installed, lines };
|
|
3096
2953
|
}
|
|
3097
|
-
function hasManagedSidecars(home =
|
|
2954
|
+
function hasManagedSidecars(home = homedir6()) {
|
|
3098
2955
|
return existsSync3(sidecarsNodeModules(home));
|
|
3099
2956
|
}
|
|
3100
2957
|
|
|
3101
2958
|
// src/try-cmd.ts
|
|
3102
2959
|
import { existsSync as existsSync5 } from "fs";
|
|
3103
2960
|
import { chmod as chmod4, mkdir as mkdir3, readdir, readFile as readFile8, unlink as unlink2 } from "fs/promises";
|
|
3104
|
-
import { homedir as
|
|
3105
|
-
import { join as
|
|
2961
|
+
import { homedir as homedir8 } from "os";
|
|
2962
|
+
import { join as join7, resolve as resolve5 } from "path";
|
|
3106
2963
|
|
|
3107
2964
|
// src/catalog.ts
|
|
3108
2965
|
var DEFAULT_CATALOG_URL = "https://yaw.sh/data/mcp-catalog.json";
|
|
@@ -3138,7 +2995,21 @@ function tokenizeCommand(cmd) {
|
|
|
3138
2995
|
if (has) out.push(cur);
|
|
3139
2996
|
return out;
|
|
3140
2997
|
}
|
|
3141
|
-
|
|
2998
|
+
var CATALOG_STALE_AFTER_DAYS = 90;
|
|
2999
|
+
function warnIfCatalogStale(body, opts) {
|
|
3000
|
+
const stamp = body?.generated_at;
|
|
3001
|
+
if (typeof stamp !== "string") return;
|
|
3002
|
+
const generated = Date.parse(stamp);
|
|
3003
|
+
if (Number.isNaN(generated)) return;
|
|
3004
|
+
const ageDays = Math.floor(((opts.now?.() ?? Date.now()) - generated) / 864e5);
|
|
3005
|
+
if (ageDays < CATALOG_STALE_AFTER_DAYS) return;
|
|
3006
|
+
const warn = opts.warn ?? ((line) => process.stderr.write(`${line}
|
|
3007
|
+
`));
|
|
3008
|
+
warn(
|
|
3009
|
+
`yaw-mcp: note: the Yaw MCP catalog was generated ${stamp.slice(0, 10)} (${ageDays} days ago); its entries may be out of date.`
|
|
3010
|
+
);
|
|
3011
|
+
}
|
|
3012
|
+
async function defaultFetchCatalog(url = DEFAULT_CATALOG_URL, deps = {}) {
|
|
3142
3013
|
const ac = new AbortController();
|
|
3143
3014
|
const timer = setTimeout(() => ac.abort(), FETCH_TIMEOUT_MS);
|
|
3144
3015
|
let body;
|
|
@@ -3169,6 +3040,7 @@ async function defaultFetchCatalog(url = DEFAULT_CATALOG_URL) {
|
|
|
3169
3040
|
if (!Array.isArray(servers)) {
|
|
3170
3041
|
throw new Error(`the Yaw MCP catalog at ${url} was not in the expected shape.`);
|
|
3171
3042
|
}
|
|
3043
|
+
warnIfCatalogStale(body, deps);
|
|
3172
3044
|
return servers.filter(
|
|
3173
3045
|
(s) => typeof s === "object" && s !== null && typeof s.slug === "string"
|
|
3174
3046
|
);
|
|
@@ -3216,12 +3088,16 @@ async function resolveCatalogSlug(slug, opts = {}) {
|
|
|
3216
3088
|
// src/install-cmd.ts
|
|
3217
3089
|
import { existsSync as existsSync4 } from "fs";
|
|
3218
3090
|
import { readFile as readFile7 } from "fs/promises";
|
|
3219
|
-
import { homedir as
|
|
3220
|
-
import { resolve as
|
|
3091
|
+
import { homedir as homedir7 } from "os";
|
|
3092
|
+
import { resolve as resolve4 } from "path";
|
|
3221
3093
|
import { createInterface } from "readline/promises";
|
|
3222
3094
|
import { Writable } from "stream";
|
|
3223
3095
|
function oamAbsentNote(os) {
|
|
3224
|
-
|
|
3096
|
+
const head = "Runtime: node (oam is not installed, which is fine -- node is the supported default. ";
|
|
3097
|
+
if (os === CURRENT_OS && !oamPublishesBinaryForThisMachine()) {
|
|
3098
|
+
return `${head}oam is not an option on this machine: ${oamNoBinaryReason()}.)`;
|
|
3099
|
+
}
|
|
3100
|
+
return `${head}To host yaw-mcp on oam instead: \`${oamInstallCommand(os)}\`, then re-run install.)`;
|
|
3225
3101
|
}
|
|
3226
3102
|
function oamIsAbsent(probe) {
|
|
3227
3103
|
return probe.bin === null && probe.binPath === null && !probe.belowMin && probe.failure === null;
|
|
@@ -3268,7 +3144,12 @@ ${USAGE}`);
|
|
|
3268
3144
|
}
|
|
3269
3145
|
const os = opts.os ?? CURRENT_OS;
|
|
3270
3146
|
if (!target.availableOn.includes(os)) {
|
|
3271
|
-
const fix = target.clientId === "claude-desktop" && os === "linux" ? "Anthropic ships Claude Desktop on macOS and Windows only. Install Claude Code or Cursor instead." :
|
|
3147
|
+
const fix = target.clientId === "claude-desktop" && os === "linux" ? "Anthropic ships Claude Desktop on macOS and Windows only. Install Claude Code or Cursor instead." : (
|
|
3148
|
+
// NOT "pass --os to override": install resolves paths against THIS
|
|
3149
|
+
// machine, so a cross-OS --os write is refused at the flag boundary
|
|
3150
|
+
// (see parseInstallArgs) — only the --dry-run preview is offered.
|
|
3151
|
+
"Pick a different client, or preview another OS's config with --os <os> --dry-run."
|
|
3152
|
+
);
|
|
3272
3153
|
err(`yaw-mcp install: ${target.label} is not available on ${os}.
|
|
3273
3154
|
${fix}`);
|
|
3274
3155
|
return { written: [], wouldWrite: [], messages, exitCode: 2 };
|
|
@@ -3281,7 +3162,7 @@ ${USAGE}`);
|
|
|
3281
3162
|
);
|
|
3282
3163
|
return { written: [], wouldWrite: [], messages, exitCode: 2 };
|
|
3283
3164
|
}
|
|
3284
|
-
const projectDir = scopeSpec.requiresProjectDir ?
|
|
3165
|
+
const projectDir = scopeSpec.requiresProjectDir ? resolve4(opts.projectDir ?? opts.cwd ?? process.cwd()) : void 0;
|
|
3285
3166
|
let resolved;
|
|
3286
3167
|
try {
|
|
3287
3168
|
resolved = resolveInstallPath({
|
|
@@ -3448,7 +3329,7 @@ ${USAGE}`);
|
|
|
3448
3329
|
clientJson = `${JSON.stringify(merged, null, 2)}
|
|
3449
3330
|
`;
|
|
3450
3331
|
}
|
|
3451
|
-
const home = opts.home ??
|
|
3332
|
+
const home = opts.home ?? homedir7();
|
|
3452
3333
|
const settingsPatch = opts.clientId === "claude-code" ? await prepareClaudeCodeSettingsPatch({
|
|
3453
3334
|
scope,
|
|
3454
3335
|
home,
|
|
@@ -3509,8 +3390,11 @@ ${settingsPatch.nextJson}`);
|
|
|
3509
3390
|
`Note: legacy "${legacyEntry}" entry remains at ${resolved.absolute}. Remove it to avoid running yaw-mcp twice.`
|
|
3510
3391
|
);
|
|
3511
3392
|
}
|
|
3512
|
-
log2(
|
|
3513
|
-
|
|
3393
|
+
log2(
|
|
3394
|
+
target.clientId === "claude-code" && scope === "project" ? `
|
|
3395
|
+
Done: ${target.label} is configured. Restart it in this project and approve the .mcp.json server when prompted \u2014 Claude Code keeps project-scope (.mcp.json) servers disabled until you approve them.` : `
|
|
3396
|
+
Done: ${target.label} is configured. Restart it to pick up the new MCP server.`
|
|
3397
|
+
);
|
|
3514
3398
|
return { written, wouldWrite: [], messages, exitCode: 0 };
|
|
3515
3399
|
}
|
|
3516
3400
|
async function prepareClaudeCodeSettingsPatch(opts) {
|
|
@@ -3559,7 +3443,7 @@ async function prepareClaudeCodeSettingsPatch(opts) {
|
|
|
3559
3443
|
function legacyAllowPatternFor(entryName) {
|
|
3560
3444
|
return `mcp__${entryName.replace(/[^A-Za-z0-9]/g, "_")}__*`;
|
|
3561
3445
|
}
|
|
3562
|
-
var LEGACY_CLAUDE_CODE_ALLOW_PATTERNS =
|
|
3446
|
+
var LEGACY_CLAUDE_CODE_ALLOW_PATTERNS = LEGACY_ENTRY_NAMES.map(legacyAllowPatternFor);
|
|
3563
3447
|
function mergePermissionsAllow(existing, patterns, retain = []) {
|
|
3564
3448
|
const out = { ...existing };
|
|
3565
3449
|
const prev = out.permissions;
|
|
@@ -3716,6 +3600,12 @@ ${USAGE}` };
|
|
|
3716
3600
|
positional.push(a);
|
|
3717
3601
|
}
|
|
3718
3602
|
}
|
|
3603
|
+
if (opts.os && opts.os !== CURRENT_OS && !opts.dryRun && !opts.listOnly) {
|
|
3604
|
+
return {
|
|
3605
|
+
ok: false,
|
|
3606
|
+
error: `yaw-mcp install: --os ${opts.os} does not match this machine (${CURRENT_OS}), and install can only resolve config paths for the machine it runs on \u2014 a cross-OS write would create a ${CURRENT_OS}-shaped junk tree. Add --dry-run to preview, or run install on the ${opts.os} machine itself.`
|
|
3607
|
+
};
|
|
3608
|
+
}
|
|
3719
3609
|
if (opts.listOnly || opts.all) {
|
|
3720
3610
|
if (positional.length > 0) {
|
|
3721
3611
|
return {
|
|
@@ -3740,7 +3630,7 @@ ${USAGE}` };
|
|
|
3740
3630
|
return { ok: true, options: opts };
|
|
3741
3631
|
}
|
|
3742
3632
|
async function runInstallList(opts, log2, messages) {
|
|
3743
|
-
const home = opts.home ??
|
|
3633
|
+
const home = opts.home ?? homedir7();
|
|
3744
3634
|
const cwd = opts.cwd ?? process.cwd();
|
|
3745
3635
|
const os = opts.os ?? CURRENT_OS;
|
|
3746
3636
|
const probes = await probeClientsAsync({ home, os, cwd, claudeConfigDir: opts.claudeConfigDir });
|
|
@@ -4032,11 +3922,11 @@ function parseDurationMs(s) {
|
|
|
4032
3922
|
const factor = unit === "s" ? 1e3 : unit === "m" ? 6e4 : unit === "h" ? 36e5 : 864e5;
|
|
4033
3923
|
return n * factor;
|
|
4034
3924
|
}
|
|
4035
|
-
function trialsDir(home =
|
|
4036
|
-
return
|
|
3925
|
+
function trialsDir(home = homedir8()) {
|
|
3926
|
+
return join7(home, CONFIG_DIRNAME, TRIALS_DIRNAME);
|
|
4037
3927
|
}
|
|
4038
|
-
function trialMarkerPath(slug, home =
|
|
4039
|
-
return
|
|
3928
|
+
function trialMarkerPath(slug, home = homedir8()) {
|
|
3929
|
+
return join7(trialsDir(home), `${slug}.json`);
|
|
4040
3930
|
}
|
|
4041
3931
|
function rejectUntrustedMarker(marker) {
|
|
4042
3932
|
if (!marker.entryName.startsWith(TRIAL_ENTRY_PREFIX)) {
|
|
@@ -4122,7 +4012,7 @@ async function runTry(opts) {
|
|
|
4122
4012
|
return { exitCode: 2, written: [] };
|
|
4123
4013
|
}
|
|
4124
4014
|
const env = opts.env ?? process.env;
|
|
4125
|
-
const home = opts.home ??
|
|
4015
|
+
const home = opts.home ?? homedir8();
|
|
4126
4016
|
const cwd = opts.cwd ?? process.cwd();
|
|
4127
4017
|
const os = opts.os ?? CURRENT_OS;
|
|
4128
4018
|
const now = opts.now ? opts.now() : Date.now();
|
|
@@ -4147,7 +4037,7 @@ async function runTry(opts) {
|
|
|
4147
4037
|
}
|
|
4148
4038
|
const clientId = opts.clientId ?? await autoDetectClient({ home, os, cwd, claudeConfigDir });
|
|
4149
4039
|
const scope = clientId === "vscode" ? "project" : "user";
|
|
4150
|
-
const projectDir = scope === "project" ?
|
|
4040
|
+
const projectDir = scope === "project" ? resolve5(cwd) : void 0;
|
|
4151
4041
|
let resolved;
|
|
4152
4042
|
try {
|
|
4153
4043
|
resolved = resolveInstallPath({ clientId, scope, os, home, projectDir, claudeConfigDir });
|
|
@@ -4327,7 +4217,7 @@ async function runTryCleanup(opts) {
|
|
|
4327
4217
|
return { exitCode: 2, written: [] };
|
|
4328
4218
|
}
|
|
4329
4219
|
const env = opts.env ?? process.env;
|
|
4330
|
-
const home = opts.home ??
|
|
4220
|
+
const home = opts.home ?? homedir8();
|
|
4331
4221
|
const baseUrl = opts.baseUrl ?? env.YAW_MCP_BASE_URL ?? DEFAULT_BASE_URL;
|
|
4332
4222
|
const markerPath = trialMarkerPath(slug, home);
|
|
4333
4223
|
if (!existsSync5(markerPath)) {
|
|
@@ -4394,7 +4284,7 @@ function formatTtl(ms) {
|
|
|
4394
4284
|
return `${Math.round(clamped / 864e5)}d`;
|
|
4395
4285
|
}
|
|
4396
4286
|
async function scanTrials(opts = {}) {
|
|
4397
|
-
const home = opts.home ??
|
|
4287
|
+
const home = opts.home ?? homedir8();
|
|
4398
4288
|
const now = opts.now ? opts.now() : Date.now();
|
|
4399
4289
|
const dir = trialsDir(home);
|
|
4400
4290
|
const result = { live: [], expired: [], malformed: [] };
|
|
@@ -4407,7 +4297,7 @@ async function scanTrials(opts = {}) {
|
|
|
4407
4297
|
}
|
|
4408
4298
|
for (const filename of entries) {
|
|
4409
4299
|
if (!filename.endsWith(".json")) continue;
|
|
4410
|
-
const path6 =
|
|
4300
|
+
const path6 = join7(dir, filename);
|
|
4411
4301
|
try {
|
|
4412
4302
|
const raw = await readFile8(path6, "utf8");
|
|
4413
4303
|
const parsed = JSON.parse(raw);
|
|
@@ -4432,7 +4322,7 @@ async function scanTrials(opts = {}) {
|
|
|
4432
4322
|
return result;
|
|
4433
4323
|
}
|
|
4434
4324
|
async function gcExpiredTrials(opts) {
|
|
4435
|
-
const home = opts.home ??
|
|
4325
|
+
const home = opts.home ?? homedir8();
|
|
4436
4326
|
const env = opts.env ?? process.env;
|
|
4437
4327
|
const baseUrl = opts.baseUrl ?? env.YAW_MCP_BASE_URL ?? DEFAULT_BASE_URL;
|
|
4438
4328
|
const postEvent = opts.postEvent ?? defaultPostEvent;
|
|
@@ -4469,357 +4359,6 @@ async function gcExpiredTrials(opts) {
|
|
|
4469
4359
|
return { cleared, failed };
|
|
4470
4360
|
}
|
|
4471
4361
|
|
|
4472
|
-
// src/upgrade-cmd.ts
|
|
4473
|
-
import { spawn as spawn3 } from "child_process";
|
|
4474
|
-
import { realpathSync } from "fs";
|
|
4475
|
-
var BINARY_DOWNLOAD_URL = "https://github.com/YawLabs/mcp/releases/latest";
|
|
4476
|
-
var POSIX_GLOBAL_LIB_PREFIX = /^(?:[A-Za-z]:)?(?:\/usr(?:\/local)?|\/opt\/[^/]+)\/lib\/node_modules\/@yawlabs\/mcp\//;
|
|
4477
|
-
var MANAGED_NODE_LIB_PREFIX = /\/(?:\.local|\.nvm|\.fnm|fnm|\.asdf|\.volta|\.nodenv|\.nvs|n)\/(?:[^/]+\/)*lib\/node_modules\/@yawlabs\/mcp\//;
|
|
4478
|
-
var UPGRADE_USAGE = `Usage: yaw-mcp upgrade [--run] [--json]
|
|
4479
|
-
|
|
4480
|
-
Show (or execute) the command to upgrade @yawlabs/mcp to the latest version.
|
|
4481
|
-
|
|
4482
|
-
--run Run the upgrade in place (global npm, pnpm, bun, and local npm
|
|
4483
|
-
installs). No-op for npx installs -- they always fetch the latest.
|
|
4484
|
-
--json Emit a machine-readable snapshot ({ current, latest, stale,
|
|
4485
|
-
method, command }) instead of prose.
|
|
4486
|
-
NOTE: --json is a report-only snapshot; it never spawns an upgrade
|
|
4487
|
-
even when combined with --run. Use --run without --json to
|
|
4488
|
-
actually perform the upgrade.`;
|
|
4489
|
-
function parseUpgradeArgs(argv) {
|
|
4490
|
-
const opts = {};
|
|
4491
|
-
for (const a of argv) {
|
|
4492
|
-
if (a === "--run") opts.run = true;
|
|
4493
|
-
else if (a === "--json") opts.json = true;
|
|
4494
|
-
else if (a === "--help" || a === "-h") return { ok: false, error: UPGRADE_USAGE, help: true };
|
|
4495
|
-
else return { ok: false, error: `yaw-mcp upgrade: unknown argument "${a}"
|
|
4496
|
-
|
|
4497
|
-
${UPGRADE_USAGE}` };
|
|
4498
|
-
}
|
|
4499
|
-
return { ok: true, options: opts };
|
|
4500
|
-
}
|
|
4501
|
-
function detectInstallMethod(argvPath) {
|
|
4502
|
-
if (!argvPath) return "unknown";
|
|
4503
|
-
const normalized = argvPath.replace(/\\/g, "/");
|
|
4504
|
-
if (/\/_npx\/[0-9a-f]+\/node_modules\/@yawlabs\/mcp\//.test(normalized)) return "npx";
|
|
4505
|
-
if (/\/app\.asar\.unpacked\//.test(normalized)) return "bundled-app";
|
|
4506
|
-
if (/\/npm\/node_modules\/@yawlabs\/mcp\//.test(normalized)) return "global-npm";
|
|
4507
|
-
if (POSIX_GLOBAL_LIB_PREFIX.test(normalized)) return "global-npm";
|
|
4508
|
-
if (MANAGED_NODE_LIB_PREFIX.test(normalized)) return "global-npm";
|
|
4509
|
-
if (/\/AppData\/Roaming\/npm\/node_modules\/@yawlabs\/mcp\//.test(normalized)) return "global-npm";
|
|
4510
|
-
if (/\/bin\/node_modules\/@yawlabs\/mcp\//.test(normalized)) return "global-npm";
|
|
4511
|
-
if (/\/pnpm\/global\/\d+\/node_modules\/@yawlabs\/mcp\//.test(normalized)) return "pnpm-global";
|
|
4512
|
-
if (/\/\.bun\/install\/global\/node_modules\/@yawlabs\/mcp\//.test(normalized)) return "bun-global";
|
|
4513
|
-
if (/\/node_modules\/@yawlabs\/mcp\//.test(normalized)) return "local-node-modules";
|
|
4514
|
-
if (/\/(yaw-mcp|mcph)\/(dist|src)\//.test(normalized)) return "dev-checkout";
|
|
4515
|
-
return "unknown";
|
|
4516
|
-
}
|
|
4517
|
-
function localInstallRoot(argvPath) {
|
|
4518
|
-
if (!argvPath) return null;
|
|
4519
|
-
const idx = argvPath.replace(/\\/g, "/").indexOf("/node_modules/");
|
|
4520
|
-
return idx > 0 ? argvPath.slice(0, idx) : null;
|
|
4521
|
-
}
|
|
4522
|
-
async function npmGlobalPrefix() {
|
|
4523
|
-
if (process.env.VITEST) return null;
|
|
4524
|
-
return new Promise((resolve8) => {
|
|
4525
|
-
const child = spawn3("npm", ["prefix", "-g"], {
|
|
4526
|
-
shell: process.platform === "win32",
|
|
4527
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
4528
|
-
});
|
|
4529
|
-
let out = "";
|
|
4530
|
-
const timer = setTimeout(() => {
|
|
4531
|
-
child.kill();
|
|
4532
|
-
resolve8(null);
|
|
4533
|
-
}, 3e3);
|
|
4534
|
-
child.stdout?.on("data", (d) => {
|
|
4535
|
-
out += String(d);
|
|
4536
|
-
});
|
|
4537
|
-
child.on("close", (code) => {
|
|
4538
|
-
clearTimeout(timer);
|
|
4539
|
-
resolve8(code === 0 && out.trim() ? out.trim() : null);
|
|
4540
|
-
});
|
|
4541
|
-
child.on("error", () => {
|
|
4542
|
-
clearTimeout(timer);
|
|
4543
|
-
resolve8(null);
|
|
4544
|
-
});
|
|
4545
|
-
});
|
|
4546
|
-
}
|
|
4547
|
-
function comparablePath(p) {
|
|
4548
|
-
let real = p;
|
|
4549
|
-
try {
|
|
4550
|
-
real = realpathSync(p);
|
|
4551
|
-
} catch {
|
|
4552
|
-
}
|
|
4553
|
-
const normalized = real.replace(/\\/g, "/");
|
|
4554
|
-
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
4555
|
-
}
|
|
4556
|
-
async function refineInstallMethod(method, argvPath, npmPrefix = npmGlobalPrefix) {
|
|
4557
|
-
if (method !== "local-node-modules" && method !== "unknown") return method;
|
|
4558
|
-
if (!argvPath) return method;
|
|
4559
|
-
const prefix = await npmPrefix();
|
|
4560
|
-
if (!prefix) return method;
|
|
4561
|
-
const entry = comparablePath(argvPath);
|
|
4562
|
-
const pfx = comparablePath(prefix);
|
|
4563
|
-
if (entry.startsWith(`${pfx}/node_modules/`) || entry.startsWith(`${pfx}/lib/node_modules/`)) {
|
|
4564
|
-
return "global-npm";
|
|
4565
|
-
}
|
|
4566
|
-
return method;
|
|
4567
|
-
}
|
|
4568
|
-
function buildUpgradePlan(input) {
|
|
4569
|
-
const { current, latest, method } = input;
|
|
4570
|
-
const stale = latest !== null && current !== "dev" && compareSemverLocal(current, latest) < 0;
|
|
4571
|
-
let command;
|
|
4572
|
-
switch (method) {
|
|
4573
|
-
case "global-npm":
|
|
4574
|
-
command = "npm install -g @yawlabs/mcp@latest";
|
|
4575
|
-
break;
|
|
4576
|
-
case "pnpm-global":
|
|
4577
|
-
command = "pnpm add -g @yawlabs/mcp@latest";
|
|
4578
|
-
break;
|
|
4579
|
-
case "bun-global":
|
|
4580
|
-
command = "bun add -g @yawlabs/mcp@latest";
|
|
4581
|
-
break;
|
|
4582
|
-
case "npx":
|
|
4583
|
-
command = null;
|
|
4584
|
-
break;
|
|
4585
|
-
case "bundled-app":
|
|
4586
|
-
command = null;
|
|
4587
|
-
break;
|
|
4588
|
-
case "local-node-modules":
|
|
4589
|
-
command = "npm install @yawlabs/mcp@latest";
|
|
4590
|
-
break;
|
|
4591
|
-
case "dev-checkout":
|
|
4592
|
-
command = "git pull && npm run build";
|
|
4593
|
-
break;
|
|
4594
|
-
case "binary":
|
|
4595
|
-
command = null;
|
|
4596
|
-
break;
|
|
4597
|
-
default:
|
|
4598
|
-
command = "npm install -g @yawlabs/mcp@latest";
|
|
4599
|
-
break;
|
|
4600
|
-
}
|
|
4601
|
-
return { current, latest, stale, method, command };
|
|
4602
|
-
}
|
|
4603
|
-
function compareSemverLocal(a, b) {
|
|
4604
|
-
const parse = (s) => {
|
|
4605
|
-
const cleaned = s.replace(/\+.*$/, "");
|
|
4606
|
-
const m = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(cleaned);
|
|
4607
|
-
if (!m) return null;
|
|
4608
|
-
const release = [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
4609
|
-
const prerelease = m[4] ? m[4].split(".") : [];
|
|
4610
|
-
return { release, prerelease };
|
|
4611
|
-
};
|
|
4612
|
-
const pa = parse(a);
|
|
4613
|
-
const pb = parse(b);
|
|
4614
|
-
if (!pa || !pb) return 0;
|
|
4615
|
-
for (let i = 0; i < 3; i++) {
|
|
4616
|
-
if (pa.release[i] < pb.release[i]) return -1;
|
|
4617
|
-
if (pa.release[i] > pb.release[i]) return 1;
|
|
4618
|
-
}
|
|
4619
|
-
if (pa.prerelease.length === 0 && pb.prerelease.length === 0) return 0;
|
|
4620
|
-
if (pa.prerelease.length === 0) return 1;
|
|
4621
|
-
if (pb.prerelease.length === 0) return -1;
|
|
4622
|
-
const len = Math.min(pa.prerelease.length, pb.prerelease.length);
|
|
4623
|
-
for (let i = 0; i < len; i++) {
|
|
4624
|
-
const ai = pa.prerelease[i];
|
|
4625
|
-
const bi = pb.prerelease[i];
|
|
4626
|
-
const aNum = /^\d+$/.test(ai);
|
|
4627
|
-
const bNum = /^\d+$/.test(bi);
|
|
4628
|
-
if (aNum && bNum) {
|
|
4629
|
-
const na = Number(ai);
|
|
4630
|
-
const nb = Number(bi);
|
|
4631
|
-
if (na < nb) return -1;
|
|
4632
|
-
if (na > nb) return 1;
|
|
4633
|
-
} else if (aNum !== bNum) {
|
|
4634
|
-
return aNum ? -1 : 1;
|
|
4635
|
-
} else {
|
|
4636
|
-
if (ai < bi) return -1;
|
|
4637
|
-
if (ai > bi) return 1;
|
|
4638
|
-
}
|
|
4639
|
-
}
|
|
4640
|
-
if (pa.prerelease.length < pb.prerelease.length) return -1;
|
|
4641
|
-
if (pa.prerelease.length > pb.prerelease.length) return 1;
|
|
4642
|
-
return 0;
|
|
4643
|
-
}
|
|
4644
|
-
var REGISTRY_FETCH_TIMEOUT_MS = 3e3;
|
|
4645
|
-
async function fetchLatestVersion(opts = {}) {
|
|
4646
|
-
if (opts.override) {
|
|
4647
|
-
try {
|
|
4648
|
-
return await opts.override();
|
|
4649
|
-
} catch {
|
|
4650
|
-
return null;
|
|
4651
|
-
}
|
|
4652
|
-
}
|
|
4653
|
-
const ac = new AbortController();
|
|
4654
|
-
const timer = setTimeout(() => ac.abort(), opts.timeoutMs ?? REGISTRY_FETCH_TIMEOUT_MS);
|
|
4655
|
-
try {
|
|
4656
|
-
const res = await fetch("https://registry.npmjs.org/@yawlabs/mcp/latest", {
|
|
4657
|
-
signal: ac.signal,
|
|
4658
|
-
headers: { accept: "application/json" }
|
|
4659
|
-
});
|
|
4660
|
-
if (!res.ok) return null;
|
|
4661
|
-
const body = await res.json();
|
|
4662
|
-
return typeof body.version === "string" ? body.version : null;
|
|
4663
|
-
} catch {
|
|
4664
|
-
return null;
|
|
4665
|
-
} finally {
|
|
4666
|
-
clearTimeout(timer);
|
|
4667
|
-
}
|
|
4668
|
-
}
|
|
4669
|
-
async function oamFloorLines(probe) {
|
|
4670
|
-
if (!probe && process.env.VITEST) return [];
|
|
4671
|
-
try {
|
|
4672
|
-
const { MIN_OAM_VERSION: MIN_OAM_VERSION2, probeOam: probeOam2 } = await import("./oam-spawn-Z5CASEBY.js");
|
|
4673
|
-
const oam = probe ? await probe() : await probeOam2();
|
|
4674
|
-
if (!oam.belowMin) return [];
|
|
4675
|
-
return [
|
|
4676
|
-
"",
|
|
4677
|
-
`oam: v${oam.version ?? "unknown"} is installed but below the v${MIN_OAM_VERSION2} floor yaw-mcp`,
|
|
4678
|
-
" requires, so MCP sidecars run on node instead of oam. Update it:",
|
|
4679
|
-
"",
|
|
4680
|
-
" oam self-update"
|
|
4681
|
-
];
|
|
4682
|
-
} catch {
|
|
4683
|
-
return [];
|
|
4684
|
-
}
|
|
4685
|
-
}
|
|
4686
|
-
async function defaultSpawn(cmd, args, cwd) {
|
|
4687
|
-
return new Promise((resolve8) => {
|
|
4688
|
-
const child = spawn3(cmd, args, { stdio: "inherit", shell: process.platform === "win32", cwd });
|
|
4689
|
-
child.on("close", (code) => resolve8(typeof code === "number" ? code : 1));
|
|
4690
|
-
child.on("error", () => resolve8(1));
|
|
4691
|
-
});
|
|
4692
|
-
}
|
|
4693
|
-
async function detectSea() {
|
|
4694
|
-
if (process.env.ELECTRON_RUN_AS_NODE) return false;
|
|
4695
|
-
const exe = process.execPath.replace(/\\/g, "/").split("/").pop()?.toLowerCase() ?? "";
|
|
4696
|
-
if (exe === "node" || exe === "node.exe") return false;
|
|
4697
|
-
try {
|
|
4698
|
-
const sea = await import("sea");
|
|
4699
|
-
return typeof sea.isSea === "function" && sea.isSea() === true;
|
|
4700
|
-
} catch {
|
|
4701
|
-
return false;
|
|
4702
|
-
}
|
|
4703
|
-
}
|
|
4704
|
-
async function runUpgrade(opts = {}) {
|
|
4705
|
-
const write = opts.out ?? ((s) => process.stdout.write(s));
|
|
4706
|
-
const writeErr = opts.err ?? ((s) => process.stderr.write(s));
|
|
4707
|
-
const lines = [];
|
|
4708
|
-
const print = (s = "") => {
|
|
4709
|
-
lines.push(s);
|
|
4710
|
-
write(`${s}
|
|
4711
|
-
`);
|
|
4712
|
-
};
|
|
4713
|
-
const printErr = (s) => {
|
|
4714
|
-
lines.push(s);
|
|
4715
|
-
writeErr(`${s}
|
|
4716
|
-
`);
|
|
4717
|
-
};
|
|
4718
|
-
const fetcher = opts.fetchLatest ?? fetchLatestVersion;
|
|
4719
|
-
const current = opts.currentVersion ?? readCurrentVersion();
|
|
4720
|
-
const argvPath = opts.argvPath ?? process.argv[1];
|
|
4721
|
-
const sea = opts.isSea ? opts.isSea() : await detectSea();
|
|
4722
|
-
const method = sea ? "binary" : await refineInstallMethod(detectInstallMethod(argvPath), argvPath, opts.npmPrefix);
|
|
4723
|
-
let latest;
|
|
4724
|
-
try {
|
|
4725
|
-
latest = await fetcher();
|
|
4726
|
-
} catch {
|
|
4727
|
-
latest = null;
|
|
4728
|
-
}
|
|
4729
|
-
const plan = buildUpgradePlan({ current, latest, method });
|
|
4730
|
-
if (opts.json) {
|
|
4731
|
-
print(JSON.stringify(plan, null, 2));
|
|
4732
|
-
return { exitCode: plan.stale && !opts.run ? 1 : 0, lines };
|
|
4733
|
-
}
|
|
4734
|
-
if (latest === null) {
|
|
4735
|
-
print("yaw-mcp upgrade: couldn't reach the npm registry (offline? firewall?).");
|
|
4736
|
-
if (plan.command) {
|
|
4737
|
-
print("When you're back online, run:");
|
|
4738
|
-
print("");
|
|
4739
|
-
print(` ${plan.command}`);
|
|
4740
|
-
} else if (method === "bundled-app") {
|
|
4741
|
-
print("This copy of yaw-mcp ships inside Yaw Terminal and updates with the app \u2014 nothing to run.");
|
|
4742
|
-
} else if (method === "binary") {
|
|
4743
|
-
print("yaw-mcp is a standalone binary \u2014 download the latest build and replace");
|
|
4744
|
-
print(`this executable: ${BINARY_DOWNLOAD_URL}`);
|
|
4745
|
-
} else {
|
|
4746
|
-
print("Your install uses `npx -y` \u2014 just restart the MCP client when you're back online.");
|
|
4747
|
-
}
|
|
4748
|
-
return { exitCode: 0, lines };
|
|
4749
|
-
}
|
|
4750
|
-
print(`Current: ${current}`);
|
|
4751
|
-
print(`Latest: ${latest}`);
|
|
4752
|
-
print(`Install: ${method}`);
|
|
4753
|
-
for (const line of await oamFloorLines(opts.oamProbe)) print(line);
|
|
4754
|
-
if (!plan.stale) {
|
|
4755
|
-
print("");
|
|
4756
|
-
print("OK: You're on the latest version -- nothing to do.");
|
|
4757
|
-
return { exitCode: 0, lines };
|
|
4758
|
-
}
|
|
4759
|
-
print("");
|
|
4760
|
-
if (method === "npx") {
|
|
4761
|
-
print("Your install uses `npx -y` \u2014 restart the MCP client and it will fetch the new version.");
|
|
4762
|
-
return { exitCode: 0, lines };
|
|
4763
|
-
}
|
|
4764
|
-
if (method === "bundled-app") {
|
|
4765
|
-
print("This copy of yaw-mcp ships inside Yaw Terminal and updates with the app \u2014");
|
|
4766
|
-
print("there is nothing to run here. Update Yaw Terminal to get the new version.");
|
|
4767
|
-
return { exitCode: 0, lines };
|
|
4768
|
-
}
|
|
4769
|
-
if (method === "binary") {
|
|
4770
|
-
print("yaw-mcp is running as a standalone binary \u2014 manual upgrade required.");
|
|
4771
|
-
print("There's no package manager to upgrade it, and `--run` can't automate");
|
|
4772
|
-
print("this: download the latest build and replace this executable:");
|
|
4773
|
-
print("");
|
|
4774
|
-
print(` ${BINARY_DOWNLOAD_URL}`);
|
|
4775
|
-
return { exitCode: opts.run ? 2 : 1, lines };
|
|
4776
|
-
}
|
|
4777
|
-
const installRoot = method === "local-node-modules" ? localInstallRoot(argvPath) : null;
|
|
4778
|
-
const runSpec = method === "global-npm" ? { cmd: "npm", args: ["install", "-g", "@yawlabs/mcp@latest"] } : method === "pnpm-global" ? { cmd: "pnpm", args: ["add", "-g", "@yawlabs/mcp@latest"] } : method === "bun-global" ? { cmd: "bun", args: ["add", "-g", "@yawlabs/mcp@latest"] } : method === "local-node-modules" && installRoot !== null ? { cmd: "npm", args: ["install", "@yawlabs/mcp@latest"], cwd: installRoot } : null;
|
|
4779
|
-
if (!opts.run) {
|
|
4780
|
-
if (runSpec) {
|
|
4781
|
-
print("Run `yaw-mcp upgrade --run` to upgrade in place, or run it yourself:");
|
|
4782
|
-
} else {
|
|
4783
|
-
print("Manual upgrade required (--run can't safely automate this install method). Run it yourself:");
|
|
4784
|
-
}
|
|
4785
|
-
print("");
|
|
4786
|
-
if (installRoot) {
|
|
4787
|
-
print(`in ${installRoot}:`);
|
|
4788
|
-
}
|
|
4789
|
-
print(` ${plan.command}`);
|
|
4790
|
-
return { exitCode: 1, lines };
|
|
4791
|
-
}
|
|
4792
|
-
if (!runSpec) {
|
|
4793
|
-
printErr(
|
|
4794
|
-
`yaw-mcp upgrade --run: a "${method}" install can't be upgraded automatically (manual upgrade required). Run it yourself:`
|
|
4795
|
-
);
|
|
4796
|
-
printErr("");
|
|
4797
|
-
printErr(` ${plan.command}`);
|
|
4798
|
-
return { exitCode: 2, lines };
|
|
4799
|
-
}
|
|
4800
|
-
const runner = opts.spawnImpl ?? defaultSpawn;
|
|
4801
|
-
if (runSpec.cwd) {
|
|
4802
|
-
print(`Running in ${runSpec.cwd}:`);
|
|
4803
|
-
} else {
|
|
4804
|
-
print("Running:");
|
|
4805
|
-
}
|
|
4806
|
-
print(` ${plan.command}`);
|
|
4807
|
-
print("");
|
|
4808
|
-
const code = await runner(runSpec.cmd, runSpec.args, runSpec.cwd);
|
|
4809
|
-
if (code === 0) {
|
|
4810
|
-
print("");
|
|
4811
|
-
print(`OK: Upgraded @yawlabs/mcp to ${latest}`);
|
|
4812
|
-
return { exitCode: 0, lines };
|
|
4813
|
-
}
|
|
4814
|
-
printErr(`yaw-mcp upgrade: ${runSpec.cmd} exited ${code}. Try running the command yourself:`);
|
|
4815
|
-
printErr("");
|
|
4816
|
-
printErr(` ${plan.command}`);
|
|
4817
|
-
return { exitCode: 3, lines };
|
|
4818
|
-
}
|
|
4819
|
-
function readCurrentVersion() {
|
|
4820
|
-
return true ? "0.75.2" : "dev";
|
|
4821
|
-
}
|
|
4822
|
-
|
|
4823
4362
|
// src/learning.ts
|
|
4824
4363
|
var LEARNING_MIN_OBSERVATIONS = 3;
|
|
4825
4364
|
var LEARNING_MAX_BOOST = 1.1;
|
|
@@ -5051,7 +4590,7 @@ function foldBundleWarnings(warnings, probe) {
|
|
|
5051
4590
|
const prefix = `${probe.path}:`;
|
|
5052
4591
|
return warnings.filter((w) => !w.startsWith(prefix));
|
|
5053
4592
|
}
|
|
5054
|
-
var VERSION = true ? "0.
|
|
4593
|
+
var VERSION = true ? "0.76.0" : "dev";
|
|
5055
4594
|
async function runDoctor(opts = {}) {
|
|
5056
4595
|
if (opts.json) return runDoctorJson(opts);
|
|
5057
4596
|
const lines = [];
|
|
@@ -5062,7 +4601,7 @@ async function runDoctor(opts = {}) {
|
|
|
5062
4601
|
`);
|
|
5063
4602
|
};
|
|
5064
4603
|
const cwd = opts.cwd ?? process.cwd();
|
|
5065
|
-
const home = opts.home ??
|
|
4604
|
+
const home = opts.home ?? homedir9();
|
|
5066
4605
|
const os = opts.os ?? CURRENT_OS;
|
|
5067
4606
|
const env = opts.env ?? process.env;
|
|
5068
4607
|
print(`yaw-mcp doctor \u2014 ${(/* @__PURE__ */ new Date()).toISOString()}`);
|
|
@@ -5085,11 +4624,17 @@ async function runDoctor(opts = {}) {
|
|
|
5085
4624
|
const projectGuide = await loadProjectGuide(cwd, home, env).catch(() => null);
|
|
5086
4625
|
renderProjectGuideSection({ guide: projectGuide, print });
|
|
5087
4626
|
renderEnvSection({ env, print });
|
|
5088
|
-
const oamStatus = await collectOamRuntimeStatus({
|
|
4627
|
+
const oamStatus = await collectOamRuntimeStatus({
|
|
4628
|
+
env,
|
|
4629
|
+
cwd,
|
|
4630
|
+
home,
|
|
4631
|
+
probeFn: opts.oamProbe ?? probeOam,
|
|
4632
|
+
sidecarLatest: sidecarLatestFetcher(opts)
|
|
4633
|
+
});
|
|
5089
4634
|
config.warnings = [...config.warnings, ...foldBundleWarnings(oamStatus.bundleWarnings, trustProbe)];
|
|
5090
4635
|
renderOamRuntimeSection({ status: oamStatus, print, os });
|
|
5091
4636
|
const persistenceDisabled = isPersistenceDisabled(env);
|
|
5092
|
-
const stateFilePath =
|
|
4637
|
+
const stateFilePath = join8(userConfigDir(home), STATE_FILENAME);
|
|
5093
4638
|
const statePeek = persistenceDisabled ? null : await peekStateFile(stateFilePath);
|
|
5094
4639
|
const persistedState = statePeek?.kind === "ok" ? await loadState(stateFilePath) : null;
|
|
5095
4640
|
renderStateSection({
|
|
@@ -5180,7 +4725,7 @@ async function runDoctorJson(opts) {
|
|
|
5180
4725
|
const lines = [];
|
|
5181
4726
|
const write = opts.out ?? ((s) => process.stdout.write(s));
|
|
5182
4727
|
const cwd = opts.cwd ?? process.cwd();
|
|
5183
|
-
const home = opts.home ??
|
|
4728
|
+
const home = opts.home ?? homedir9();
|
|
5184
4729
|
const os = opts.os ?? CURRENT_OS;
|
|
5185
4730
|
const env = opts.env ?? process.env;
|
|
5186
4731
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5206,7 +4751,7 @@ async function runDoctorJson(opts) {
|
|
|
5206
4751
|
envOverrides[name] = raw === void 0 || raw === "" ? null : raw;
|
|
5207
4752
|
}
|
|
5208
4753
|
const persistDisabled = isPersistenceDisabled(env);
|
|
5209
|
-
const stateFilePath =
|
|
4754
|
+
const stateFilePath = join8(userConfigDir(home), STATE_FILENAME);
|
|
5210
4755
|
const statePeek = persistDisabled ? null : await peekStateFile(stateFilePath);
|
|
5211
4756
|
const stateUsable = statePeek !== null && (statePeek.kind === "ok" || statePeek.kind === "missing");
|
|
5212
4757
|
const persisted = stateUsable ? await loadState(stateFilePath) : null;
|
|
@@ -5281,7 +4826,13 @@ async function runDoctorJson(opts) {
|
|
|
5281
4826
|
})),
|
|
5282
4827
|
malformed: trialScan.malformed
|
|
5283
4828
|
};
|
|
5284
|
-
const oamStatus = await collectOamRuntimeStatus({
|
|
4829
|
+
const oamStatus = await collectOamRuntimeStatus({
|
|
4830
|
+
env,
|
|
4831
|
+
cwd,
|
|
4832
|
+
home,
|
|
4833
|
+
probeFn: opts.oamProbe ?? probeOam,
|
|
4834
|
+
sidecarLatest: sidecarLatestFetcher(opts)
|
|
4835
|
+
});
|
|
5285
4836
|
config.warnings = [...config.warnings, ...foldBundleWarnings(oamStatus.bundleWarnings, trustProbe)];
|
|
5286
4837
|
const oamRuntime = {
|
|
5287
4838
|
binary: oamStatus.probe.bin,
|
|
@@ -5375,6 +4926,27 @@ function renderEnvSection(opts) {
|
|
|
5375
4926
|
}
|
|
5376
4927
|
print("");
|
|
5377
4928
|
}
|
|
4929
|
+
async function fetchSidecarLatest(pkg) {
|
|
4930
|
+
const ac = new AbortController();
|
|
4931
|
+
const timer = setTimeout(() => ac.abort(), DOCTOR_REGISTRY_TIMEOUT_MS);
|
|
4932
|
+
try {
|
|
4933
|
+
const res = await fetch(`https://registry.npmjs.org/${pkg}/latest`, {
|
|
4934
|
+
signal: ac.signal,
|
|
4935
|
+
headers: { accept: "application/json" }
|
|
4936
|
+
});
|
|
4937
|
+
if (!res.ok) return null;
|
|
4938
|
+
const body = await res.json();
|
|
4939
|
+
return typeof body.version === "string" ? body.version : null;
|
|
4940
|
+
} catch {
|
|
4941
|
+
return null;
|
|
4942
|
+
} finally {
|
|
4943
|
+
clearTimeout(timer);
|
|
4944
|
+
}
|
|
4945
|
+
}
|
|
4946
|
+
function sidecarLatestFetcher(opts) {
|
|
4947
|
+
const skip = (opts.skipRegistryCheck === true || Boolean(process.env.VITEST)) && !opts.sidecarRegistryFetch;
|
|
4948
|
+
return skip ? null : opts.sidecarRegistryFetch ?? fetchSidecarLatest;
|
|
4949
|
+
}
|
|
5378
4950
|
async function collectOamRuntimeStatus(opts) {
|
|
5379
4951
|
const probe = await opts.probeFn();
|
|
5380
4952
|
const bundles = await loadLocalBundles({ cwd: opts.cwd, home: opts.home, env: opts.env }).catch(() => null);
|
|
@@ -5386,9 +4958,20 @@ async function collectOamRuntimeStatus(opts) {
|
|
|
5386
4958
|
}));
|
|
5387
4959
|
const specs = collectSidecarSpecs(bundles?.config?.servers ?? []);
|
|
5388
4960
|
const anyManaged = hasManagedSidecars(opts.home);
|
|
4961
|
+
const packages = await Promise.all(
|
|
4962
|
+
specs.map(async (s) => {
|
|
4963
|
+
const version = anyManaged ? installedVersion(s.pkg, opts.home) : null;
|
|
4964
|
+
const latest = version !== null && opts.sidecarLatest !== null ? await opts.sidecarLatest(s.pkg) : null;
|
|
4965
|
+
const stale = version !== null && latest !== null && compareSemver(version, latest) < 0;
|
|
4966
|
+
return { pkg: s.pkg, version, latest, stale };
|
|
4967
|
+
})
|
|
4968
|
+
);
|
|
4969
|
+
const installedFor = anyManaged ? installedPlatform(opts.home) : null;
|
|
5389
4970
|
const managed = {
|
|
5390
4971
|
root: sidecarsRoot(opts.home),
|
|
5391
|
-
packages
|
|
4972
|
+
packages,
|
|
4973
|
+
installedFor,
|
|
4974
|
+
platformMismatch: installedFor !== null && (installedFor.platform !== process.platform || installedFor.arch !== process.arch)
|
|
5392
4975
|
};
|
|
5393
4976
|
return { probe, dflt, servers, managed, bundleWarnings: bundles?.warnings ?? [] };
|
|
5394
4977
|
}
|
|
@@ -5405,7 +4988,7 @@ function renderOamRuntimeSection(opts) {
|
|
|
5405
4988
|
print(" fix: run `oam --version` by hand; OAM_BIN overrides which binary is probed");
|
|
5406
4989
|
} else if (probe.bin === null) {
|
|
5407
4990
|
print(" binary: not installed \u2014 node/npx spawns are used directly");
|
|
5408
|
-
print(` install: ${
|
|
4991
|
+
print(` install: ${oamInstallAdvice(opts.os)}`);
|
|
5409
4992
|
} else if (probe.version === null) {
|
|
5410
4993
|
print(` binary: ${probe.bin} (version unparseable -- min ${MIN_OAM_VERSION} NOT verified, hosting anyway)`);
|
|
5411
4994
|
} else {
|
|
@@ -5437,7 +5020,15 @@ function renderOamRuntimeSection(opts) {
|
|
|
5437
5020
|
if (anyInstalled) {
|
|
5438
5021
|
const widest = managed.packages.reduce((m, p) => Math.max(m, p.pkg.length), 0);
|
|
5439
5022
|
for (const p of managed.packages) {
|
|
5440
|
-
|
|
5023
|
+
const staleNote = p.stale && p.latest !== null ? ` (latest ${p.latest} -- re-run \`yaw-mcp sidecars install\`)` : "";
|
|
5024
|
+
print(` ${p.pkg.padEnd(widest)} ${p.version ?? "not in the managed tree"}${staleNote}`);
|
|
5025
|
+
}
|
|
5026
|
+
if (managed.platformMismatch && managed.installedFor !== null) {
|
|
5027
|
+
print(
|
|
5028
|
+
` ! installed on ${managed.installedFor.platform}/${managed.installedFor.arch}; this process is ${process.platform}/${process.arch}.`
|
|
5029
|
+
);
|
|
5030
|
+
print(" Native bindings resolve for the installing machine, so these packages can fail");
|
|
5031
|
+
print(" at spawn here -- re-run `yaw-mcp sidecars install` on this machine.");
|
|
5441
5032
|
}
|
|
5442
5033
|
}
|
|
5443
5034
|
}
|
|
@@ -5758,14 +5349,14 @@ function classifyProbeContent(raw, containerPath, exists3 = existsSync6) {
|
|
|
5758
5349
|
if (typeof entry === "object" && entry !== null && !Array.isArray(entry)) {
|
|
5759
5350
|
const command = entry.command;
|
|
5760
5351
|
if (typeof command === "string") {
|
|
5761
|
-
if (
|
|
5352
|
+
if (isAbsolute(command) && !exists3(command)) launchCommandMissing = command;
|
|
5762
5353
|
const entryArgs = entry.args;
|
|
5763
5354
|
const args = Array.isArray(entryArgs) ? entryArgs : [];
|
|
5764
5355
|
launchRuntime = isOamLaunch(command, args) ? "oam" : "node";
|
|
5765
|
-
if (isOamCommand(command) && !
|
|
5356
|
+
if (isOamCommand(command) && !isAbsolute(command)) launchOamNotAbsolute = command;
|
|
5766
5357
|
if (launchRuntime === "oam") {
|
|
5767
5358
|
const entryPath = oamRunEntryPath(command, args);
|
|
5768
|
-
if (entryPath !== null &&
|
|
5359
|
+
if (entryPath !== null && isAbsolute(entryPath) && !exists3(entryPath)) {
|
|
5769
5360
|
launchOamEntryMissing = entryPath;
|
|
5770
5361
|
}
|
|
5771
5362
|
}
|
|
@@ -5835,9 +5426,9 @@ function scanShellHistoryForShadows(opts) {
|
|
|
5835
5426
|
}
|
|
5836
5427
|
function shellHistorySources(opts) {
|
|
5837
5428
|
const sources = [];
|
|
5838
|
-
sources.push({ path:
|
|
5429
|
+
sources.push({ path: join8(opts.home, ".bash_history"), extractCommand: (l) => l.trim() || null });
|
|
5839
5430
|
sources.push({
|
|
5840
|
-
path:
|
|
5431
|
+
path: join8(opts.home, ".zsh_history"),
|
|
5841
5432
|
// Zsh extended-history lines look like `: 1700000000:0;npm audit`.
|
|
5842
5433
|
// Strip the metadata prefix so we get just the command.
|
|
5843
5434
|
extractCommand: (l) => {
|
|
@@ -5853,7 +5444,7 @@ function shellHistorySources(opts) {
|
|
|
5853
5444
|
const appData = opts.env.APPDATA;
|
|
5854
5445
|
if (appData) {
|
|
5855
5446
|
sources.push({
|
|
5856
|
-
path:
|
|
5447
|
+
path: join8(appData, "Microsoft", "Windows", "PowerShell", "PSReadLine", "ConsoleHost_history.txt"),
|
|
5857
5448
|
extractCommand: (l) => l.trim() || null
|
|
5858
5449
|
});
|
|
5859
5450
|
}
|
|
@@ -5914,12 +5505,12 @@ function compareSemver(a, b) {
|
|
|
5914
5505
|
|
|
5915
5506
|
// src/foundry-cmd.ts
|
|
5916
5507
|
import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync } from "fs";
|
|
5917
|
-
import { homedir as
|
|
5508
|
+
import { homedir as homedir11 } from "os";
|
|
5918
5509
|
import path4 from "path";
|
|
5919
5510
|
|
|
5920
5511
|
// src/foundry.ts
|
|
5921
5512
|
import { appendFile, mkdir as mkdir4, stat as stat3 } from "fs/promises";
|
|
5922
|
-
import { homedir as
|
|
5513
|
+
import { homedir as homedir10 } from "os";
|
|
5923
5514
|
import path3 from "path";
|
|
5924
5515
|
|
|
5925
5516
|
// src/relevance.ts
|
|
@@ -6182,7 +5773,7 @@ function redactIntent(intent) {
|
|
|
6182
5773
|
return " ";
|
|
6183
5774
|
});
|
|
6184
5775
|
}
|
|
6185
|
-
const all =
|
|
5776
|
+
const all = tokenizeQuery(scrubbed);
|
|
6186
5777
|
const tokens = [];
|
|
6187
5778
|
for (const token of all) {
|
|
6188
5779
|
if (looksSensitive(token)) {
|
|
@@ -6202,7 +5793,7 @@ function isFoundryEnabled() {
|
|
|
6202
5793
|
}
|
|
6203
5794
|
var MAX_FOUNDRY_BYTES = 5 * 1024 * 1024;
|
|
6204
5795
|
var FOUNDRY_FILENAME = "foundry.jsonl";
|
|
6205
|
-
async function appendFoundryTrace(trace, home =
|
|
5796
|
+
async function appendFoundryTrace(trace, home = homedir10()) {
|
|
6206
5797
|
try {
|
|
6207
5798
|
if (!isFoundryEnabled()) return;
|
|
6208
5799
|
const dir = userConfigDir(home);
|
|
@@ -6386,7 +5977,7 @@ async function runFoundryExport(opts) {
|
|
|
6386
5977
|
writeErr(`${s}
|
|
6387
5978
|
`);
|
|
6388
5979
|
};
|
|
6389
|
-
const home = opts.home ??
|
|
5980
|
+
const home = opts.home ?? homedir11();
|
|
6390
5981
|
const harvestPath = path4.join(userConfigDir(home), FOUNDRY_FILENAME);
|
|
6391
5982
|
const blob = opts.readTraces ? opts.readTraces() : (() => {
|
|
6392
5983
|
try {
|
|
@@ -6442,13 +6033,13 @@ async function runFoundryExport(opts) {
|
|
|
6442
6033
|
|
|
6443
6034
|
// src/local-add-cmd.ts
|
|
6444
6035
|
import { readFile as readFile11 } from "fs/promises";
|
|
6445
|
-
import { homedir as
|
|
6036
|
+
import { homedir as homedir13 } from "os";
|
|
6446
6037
|
import { createInterface as createInterface3 } from "readline/promises";
|
|
6447
6038
|
|
|
6448
6039
|
// src/trust-cmd.ts
|
|
6449
6040
|
import { readFile as readFile10 } from "fs/promises";
|
|
6450
|
-
import { homedir as
|
|
6451
|
-
import { isAbsolute as
|
|
6041
|
+
import { homedir as homedir12 } from "os";
|
|
6042
|
+
import { isAbsolute as isAbsolute2, resolve as resolve6 } from "path";
|
|
6452
6043
|
import { createInterface as createInterface2 } from "readline/promises";
|
|
6453
6044
|
var TRUST_USAGE = `Usage: yaw-mcp trust [--yes]
|
|
6454
6045
|
yaw-mcp trust --list [--json]
|
|
@@ -6548,7 +6139,7 @@ async function runTrustGrant(opts) {
|
|
|
6548
6139
|
`);
|
|
6549
6140
|
const printErr = (s) => err(`${s}
|
|
6550
6141
|
`);
|
|
6551
|
-
const home = opts.home ??
|
|
6142
|
+
const home = opts.home ?? homedir12();
|
|
6552
6143
|
const cwd = opts.cwd ?? process.cwd();
|
|
6553
6144
|
const env = opts.env ?? process.env;
|
|
6554
6145
|
const probe = await probeProjectTrust({ cwd, home, env });
|
|
@@ -6586,6 +6177,11 @@ async function runTrustGrant(opts) {
|
|
|
6586
6177
|
` Status: ${probe.status === "changed" ? "CHANGED since you approved it" : probe.status === "store-unreadable" ? `trust store unreadable (${displaySafe(probe.storePath)})` : "never approved"}`
|
|
6587
6178
|
);
|
|
6588
6179
|
print(` Servers: ${serverCount}`);
|
|
6180
|
+
if (probe.bypassed) {
|
|
6181
|
+
print(
|
|
6182
|
+
` ! ${TRUST_BYPASS_ENV} is set: this file (like every project bundles.json) loads WITHOUT approval right now. This approval takes effect once it is unset.`
|
|
6183
|
+
);
|
|
6184
|
+
}
|
|
6589
6185
|
print("");
|
|
6590
6186
|
if (serverCount === 0) {
|
|
6591
6187
|
print(" This file defines no servers, so approving it spawns nothing. It");
|
|
@@ -6671,7 +6267,13 @@ async function runTrustGrant(opts) {
|
|
|
6671
6267
|
print(" NOT PINNED: the code those commands actually run. Files inside this repo and");
|
|
6672
6268
|
print(" packages fetched at spawn time can change with no edit to bundles.json, and so");
|
|
6673
6269
|
print(" with no new prompt. Approving is trusting the repo, not just this one file.");
|
|
6674
|
-
|
|
6270
|
+
if (probe.bypassed) {
|
|
6271
|
+
print(
|
|
6272
|
+
`NOTE: ${TRUST_BYPASS_ENV} is set, so this file was ALREADY loading without approval. This approval takes effect once the variable is unset.`
|
|
6273
|
+
);
|
|
6274
|
+
} else {
|
|
6275
|
+
print("Restart your MCP client (or yaw-mcp) to load it.");
|
|
6276
|
+
}
|
|
6675
6277
|
return { exitCode: 0 };
|
|
6676
6278
|
}
|
|
6677
6279
|
function renderLaunch(s) {
|
|
@@ -6695,7 +6297,7 @@ function displayArg(s) {
|
|
|
6695
6297
|
var SCRIPT_EXT_RE = /\.(?:js|mjs|cjs|ts|mts|cts|py|rb|sh|bash|zsh|pl|php|lua|jar|bat|cmd|ps1|exe)$/i;
|
|
6696
6298
|
function inRepoTokens(s) {
|
|
6697
6299
|
const hits = [];
|
|
6698
|
-
const isLocalish = (t) => t.length > 0 && !/\s/.test(t) && !
|
|
6300
|
+
const isLocalish = (t) => t.length > 0 && !/\s/.test(t) && !isAbsolute2(t) && !t.includes("://") && !t.startsWith("-");
|
|
6699
6301
|
const command = s.command ?? "";
|
|
6700
6302
|
if (isLocalish(command) && (/^\.{1,2}[\\/]/.test(command) || /[\\/]/.test(command))) hits.push(command);
|
|
6701
6303
|
for (const a of s.args ?? []) {
|
|
@@ -6742,10 +6344,9 @@ function unversionedRegistrySpec(s) {
|
|
|
6742
6344
|
break;
|
|
6743
6345
|
}
|
|
6744
6346
|
if (spec === null || spec.length === 0) return null;
|
|
6745
|
-
if (spec.includes("://") ||
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
if (afterScope.includes("@") || afterScope.includes("==")) return null;
|
|
6347
|
+
if (spec.includes("://") || isAbsolute2(spec) || /^\.{1,2}[\\/]/.test(spec)) return null;
|
|
6348
|
+
if (spec.includes("==")) return null;
|
|
6349
|
+
if (specConstraint(spec).kind === "exact") return null;
|
|
6749
6350
|
return spec;
|
|
6750
6351
|
}
|
|
6751
6352
|
function pinGaps(s) {
|
|
@@ -6760,7 +6361,7 @@ function pinGaps(s) {
|
|
|
6760
6361
|
const spec = unversionedRegistrySpec(s);
|
|
6761
6362
|
if (spec !== null) {
|
|
6762
6363
|
lines.push(
|
|
6763
|
-
`NOT covered by the pin: ${displayArg(spec)}
|
|
6364
|
+
`NOT covered by the pin: ${displayArg(spec)} is not pinned to an exact version -- it resolves to whatever the registry serves at spawn time.`
|
|
6764
6365
|
);
|
|
6765
6366
|
}
|
|
6766
6367
|
return lines;
|
|
@@ -6770,14 +6371,22 @@ async function runTrustList(opts) {
|
|
|
6770
6371
|
const err = opts.err ?? ((s) => process.stderr.write(s));
|
|
6771
6372
|
const print = (s = "") => out(`${s}
|
|
6772
6373
|
`);
|
|
6773
|
-
const home = opts.home ??
|
|
6374
|
+
const home = opts.home ?? homedir12();
|
|
6375
|
+
const env = opts.env ?? process.env;
|
|
6376
|
+
const bypassed = isTrustBypassEnabled(env);
|
|
6377
|
+
if (bypassed && !opts.json) {
|
|
6378
|
+
err(
|
|
6379
|
+
`yaw-mcp trust: warning -- ${TRUST_BYPASS_ENV} is set, so EVERY project bundles.json loads WITHOUT approval right now, regardless of what is listed here. Unset it to restore the approval gate.
|
|
6380
|
+
`
|
|
6381
|
+
);
|
|
6382
|
+
}
|
|
6774
6383
|
const store = await readTrustStore(home);
|
|
6775
6384
|
if (store.malformed) {
|
|
6776
6385
|
const fix = store.malformedKind === "io" ? "fix its permissions (do NOT delete it -- your approvals are still in there)" : store.malformedKind === "schema" ? "you upgrade with `npm i -g @yawlabs/mcp@latest` (do NOT delete it -- your approvals are still in there)" : "it is fixed or deleted";
|
|
6777
6386
|
const msg = `trust store unusable: ${store.malformedReason ?? "unknown"} -- NOTHING is trusted until ${fix}`;
|
|
6778
6387
|
if (opts.json) {
|
|
6779
6388
|
out(
|
|
6780
|
-
`${JSON.stringify({ storePath: trustStorePath(home), malformed: true, error: msg, trusted: [] }, null, 2)}
|
|
6389
|
+
`${JSON.stringify({ storePath: trustStorePath(home), malformed: true, bypassed, error: msg, trusted: [] }, null, 2)}
|
|
6781
6390
|
`
|
|
6782
6391
|
);
|
|
6783
6392
|
} else {
|
|
@@ -6792,7 +6401,7 @@ async function runTrustList(opts) {
|
|
|
6792
6401
|
rows.push({ ...r, status: await classifyRecord(r.path, r.sha256) });
|
|
6793
6402
|
}
|
|
6794
6403
|
if (opts.json) {
|
|
6795
|
-
out(`${JSON.stringify({ storePath: trustStorePath(home), malformed: false, trusted: rows }, null, 2)}
|
|
6404
|
+
out(`${JSON.stringify({ storePath: trustStorePath(home), malformed: false, bypassed, trusted: rows }, null, 2)}
|
|
6796
6405
|
`);
|
|
6797
6406
|
return { exitCode: 0 };
|
|
6798
6407
|
}
|
|
@@ -6839,12 +6448,12 @@ async function runTrustRevoke(opts) {
|
|
|
6839
6448
|
`);
|
|
6840
6449
|
const printErr = (s) => err(`${s}
|
|
6841
6450
|
`);
|
|
6842
|
-
const home = opts.home ??
|
|
6451
|
+
const home = opts.home ?? homedir12();
|
|
6843
6452
|
const cwd = opts.cwd ?? process.cwd();
|
|
6844
6453
|
const env = opts.env ?? process.env;
|
|
6845
6454
|
let target;
|
|
6846
6455
|
if (opts.path) {
|
|
6847
|
-
target =
|
|
6456
|
+
target = resolve6(cwd, opts.path);
|
|
6848
6457
|
} else {
|
|
6849
6458
|
const probe = await probeProjectTrust({ cwd, home, env });
|
|
6850
6459
|
if (probe.path === null) {
|
|
@@ -6987,7 +6596,7 @@ async function runAdd(opts) {
|
|
|
6987
6596
|
return { exitCode: 2, written: [] };
|
|
6988
6597
|
}
|
|
6989
6598
|
const env = opts.env ?? process.env;
|
|
6990
|
-
const home = opts.home ??
|
|
6599
|
+
const home = opts.home ?? homedir13();
|
|
6991
6600
|
const cwd = opts.cwd ?? process.cwd();
|
|
6992
6601
|
let server;
|
|
6993
6602
|
try {
|
|
@@ -7022,6 +6631,7 @@ async function runAdd(opts) {
|
|
|
7022
6631
|
id: `local-${namespace}`,
|
|
7023
6632
|
name: server.name,
|
|
7024
6633
|
namespace,
|
|
6634
|
+
slug: server.slug,
|
|
7025
6635
|
type: "local",
|
|
7026
6636
|
transport: "stdio",
|
|
7027
6637
|
command: server.command,
|
|
@@ -7143,6 +6753,30 @@ async function findRemovalTarget(candidates, home) {
|
|
|
7143
6753
|
}
|
|
7144
6754
|
return null;
|
|
7145
6755
|
}
|
|
6756
|
+
async function namespacesForStoredSlug(target, home) {
|
|
6757
|
+
const path6 = localBundlesPath(userConfigDir(home));
|
|
6758
|
+
let raw;
|
|
6759
|
+
try {
|
|
6760
|
+
raw = await readFile11(path6, "utf8");
|
|
6761
|
+
} catch {
|
|
6762
|
+
return [];
|
|
6763
|
+
}
|
|
6764
|
+
let parsed;
|
|
6765
|
+
try {
|
|
6766
|
+
parsed = parseJsonc(raw);
|
|
6767
|
+
} catch {
|
|
6768
|
+
return [];
|
|
6769
|
+
}
|
|
6770
|
+
if (typeof parsed !== "object" || parsed === null) return [];
|
|
6771
|
+
const servers = parsed.servers;
|
|
6772
|
+
if (!Array.isArray(servers)) return [];
|
|
6773
|
+
const out = [];
|
|
6774
|
+
for (const s of servers) {
|
|
6775
|
+
const e = s;
|
|
6776
|
+
if (e?.slug === target && typeof e?.namespace === "string") out.push(e.namespace);
|
|
6777
|
+
}
|
|
6778
|
+
return out;
|
|
6779
|
+
}
|
|
7146
6780
|
function renderLaunch2(entry) {
|
|
7147
6781
|
const command = typeof entry.command === "string" ? entry.command : "";
|
|
7148
6782
|
const args = Array.isArray(entry.args) ? entry.args.filter((a) => typeof a === "string") : [];
|
|
@@ -7195,10 +6829,10 @@ async function runRemove(opts) {
|
|
|
7195
6829
|
printErr(`yaw-mcp remove: "${opts.target}" isn't a valid slug or namespace.`);
|
|
7196
6830
|
return { exitCode: 2, written: [] };
|
|
7197
6831
|
}
|
|
7198
|
-
const home = opts.home ??
|
|
6832
|
+
const home = opts.home ?? homedir13();
|
|
7199
6833
|
const cwd = opts.cwd ?? process.cwd();
|
|
7200
|
-
const
|
|
7201
|
-
const candidates =
|
|
6834
|
+
const bySlug = await namespacesForStoredSlug(opts.target, home);
|
|
6835
|
+
const candidates = [.../* @__PURE__ */ new Set([opts.target, ...bySlug, deriveNamespace(opts.target)])];
|
|
7202
6836
|
if (!opts.force) {
|
|
7203
6837
|
const doomed = await findRemovalTarget(candidates, home);
|
|
7204
6838
|
if (doomed) {
|
|
@@ -7254,7 +6888,9 @@ var LIST_USAGE = `Usage: yaw-mcp list [--json]
|
|
|
7254
6888
|
|
|
7255
6889
|
List the MCP servers yaw-mcp loads locally from bundles.json (the
|
|
7256
6890
|
project-local file wins over user-global), with the compliance grade
|
|
7257
|
-
\`yaw-mcp audit\` last cached for each. --json for machine output
|
|
6891
|
+
\`yaw-mcp audit\` last cached for each. --json for machine output.
|
|
6892
|
+
Env vars appear as \`envKeys\` -- key NAMES only, never the stored
|
|
6893
|
+
values (same posture as \`add --json\`).`;
|
|
7258
6894
|
function parseListArgs(argv) {
|
|
7259
6895
|
const opts = {};
|
|
7260
6896
|
for (const a of argv) {
|
|
@@ -7275,7 +6911,7 @@ async function runList(opts) {
|
|
|
7275
6911
|
`);
|
|
7276
6912
|
const printErr = (s) => err(`${s}
|
|
7277
6913
|
`);
|
|
7278
|
-
const home = opts.home ??
|
|
6914
|
+
const home = opts.home ?? homedir13();
|
|
7279
6915
|
const cwd = opts.cwd ?? process.cwd();
|
|
7280
6916
|
const loaded = await loadLocalBundles({ home, cwd });
|
|
7281
6917
|
const servers = loaded.config?.servers ?? [];
|
|
@@ -7287,7 +6923,16 @@ async function runList(opts) {
|
|
|
7287
6923
|
return cached ? { ...s, complianceGrade: cached.grade } : s;
|
|
7288
6924
|
});
|
|
7289
6925
|
if (opts.json) {
|
|
7290
|
-
|
|
6926
|
+
const jsonServers = graded.map((s) => {
|
|
6927
|
+
const entry = jsonEntry(s);
|
|
6928
|
+
const cached = grades[s.namespace];
|
|
6929
|
+
if (cached) {
|
|
6930
|
+
entry.complianceGradedAt = cached.gradedAt;
|
|
6931
|
+
if (cached.suiteVersion) entry.complianceSuiteVersion = cached.suiteVersion;
|
|
6932
|
+
}
|
|
6933
|
+
return entry;
|
|
6934
|
+
});
|
|
6935
|
+
print(JSON.stringify({ path: loaded.path, servers: jsonServers, warnings: loaded.warnings }, null, 2));
|
|
7291
6936
|
return { exitCode: 0, written: [] };
|
|
7292
6937
|
}
|
|
7293
6938
|
if (servers.length === 0) {
|
|
@@ -7317,8 +6962,8 @@ ${servers.length} server${servers.length === 1 ? "" : "s"} in ${loaded.path}`);
|
|
|
7317
6962
|
|
|
7318
6963
|
// src/reset-learning-cmd.ts
|
|
7319
6964
|
import { readFile as readFile12, unlink as unlink3 } from "fs/promises";
|
|
7320
|
-
import { homedir as
|
|
7321
|
-
import { join as
|
|
6965
|
+
import { homedir as homedir14 } from "os";
|
|
6966
|
+
import { join as join9 } from "path";
|
|
7322
6967
|
var RESET_LEARNING_USAGE = `Usage: yaw-mcp reset-learning
|
|
7323
6968
|
|
|
7324
6969
|
Delete ~/.yaw-mcp/state.json so cross-session learning starts fresh.
|
|
@@ -7349,7 +6994,7 @@ ${RESET_LEARNING_USAGE}`
|
|
|
7349
6994
|
};
|
|
7350
6995
|
}
|
|
7351
6996
|
async function runResetLearning(opts = {}) {
|
|
7352
|
-
const home = opts.home ??
|
|
6997
|
+
const home = opts.home ?? homedir14();
|
|
7353
6998
|
const env = opts.env ?? process.env;
|
|
7354
6999
|
const write = opts.out ?? ((s) => process.stdout.write(s));
|
|
7355
7000
|
const writeErr = opts.err ?? ((s) => process.stderr.write(s));
|
|
@@ -7364,7 +7009,7 @@ async function runResetLearning(opts = {}) {
|
|
|
7364
7009
|
writeErr(`${s}
|
|
7365
7010
|
`);
|
|
7366
7011
|
};
|
|
7367
|
-
const filePath =
|
|
7012
|
+
const filePath = join9(userConfigDir(home), STATE_FILENAME);
|
|
7368
7013
|
if (isPersistenceDisabled(env)) {
|
|
7369
7014
|
print("yaw-mcp reset-learning: persistence is disabled (YAW_MCP_DISABLE_PERSISTENCE) \u2014 nothing to clear.");
|
|
7370
7015
|
return { exitCode: 0, lines, removed: false, path: filePath };
|
|
@@ -7420,19 +7065,19 @@ function isFileNotFound2(err) {
|
|
|
7420
7065
|
|
|
7421
7066
|
// src/secrets-cmd.ts
|
|
7422
7067
|
import { existsSync as existsSync8 } from "fs";
|
|
7423
|
-
import { homedir as
|
|
7068
|
+
import { homedir as homedir17 } from "os";
|
|
7424
7069
|
|
|
7425
7070
|
// src/secrets-audit.ts
|
|
7426
7071
|
import { existsSync as existsSync7 } from "fs";
|
|
7427
7072
|
import { appendFile as appendFile2, chmod as chmod5, readFile as readFile13, stat as stat4 } from "fs/promises";
|
|
7428
|
-
import { homedir as
|
|
7429
|
-
import { join as
|
|
7073
|
+
import { homedir as homedir15 } from "os";
|
|
7074
|
+
import { join as join10 } from "path";
|
|
7430
7075
|
var SECRETS_AUDIT_FILENAME = "secrets-audit.log";
|
|
7431
7076
|
var AUDIT_TAIL_CAP = 5e3;
|
|
7432
|
-
function auditLogPath(home =
|
|
7433
|
-
return
|
|
7077
|
+
function auditLogPath(home = homedir15()) {
|
|
7078
|
+
return join10(home, CONFIG_DIRNAME, SECRETS_AUDIT_FILENAME);
|
|
7434
7079
|
}
|
|
7435
|
-
async function appendAuditEvent(input, home =
|
|
7080
|
+
async function appendAuditEvent(input, home = homedir15()) {
|
|
7436
7081
|
try {
|
|
7437
7082
|
const event = {
|
|
7438
7083
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -7466,7 +7111,7 @@ async function trimToTailCap(path6) {
|
|
|
7466
7111
|
await atomicWriteFile(path6, `${kept.join("\n")}
|
|
7467
7112
|
`, "utf8", 384);
|
|
7468
7113
|
}
|
|
7469
|
-
async function readAuditLog(filter = {}, home =
|
|
7114
|
+
async function readAuditLog(filter = {}, home = homedir15()) {
|
|
7470
7115
|
const path6 = auditLogPath(home);
|
|
7471
7116
|
if (!existsSync7(path6)) return [];
|
|
7472
7117
|
let raw;
|
|
@@ -7500,8 +7145,8 @@ function isAuditEvent(v) {
|
|
|
7500
7145
|
// src/secrets-vault.ts
|
|
7501
7146
|
import { createHmac, randomBytes as randomBytes2, timingSafeEqual } from "crypto";
|
|
7502
7147
|
import { chmod as chmod6, mkdir as mkdir5, readFile as readFile14 } from "fs/promises";
|
|
7503
|
-
import { homedir as
|
|
7504
|
-
import { dirname as dirname2, join as
|
|
7148
|
+
import { homedir as homedir16 } from "os";
|
|
7149
|
+
import { dirname as dirname2, join as join11 } from "path";
|
|
7505
7150
|
|
|
7506
7151
|
// src/secrets-crypto.ts
|
|
7507
7152
|
import { createCipheriv, createDecipheriv, randomBytes, scrypt as scryptCb } from "crypto";
|
|
@@ -7519,13 +7164,13 @@ async function deriveKey(passphrase, salt) {
|
|
|
7519
7164
|
return scryptCallWithMaxmem(passphrase, salt, KEY_LEN);
|
|
7520
7165
|
}
|
|
7521
7166
|
async function scryptCallWithMaxmem(password, salt, keylen) {
|
|
7522
|
-
return new Promise((
|
|
7167
|
+
return new Promise((resolve7, reject) => {
|
|
7523
7168
|
scryptCb(
|
|
7524
7169
|
password,
|
|
7525
7170
|
salt,
|
|
7526
7171
|
keylen,
|
|
7527
7172
|
{ N: SCRYPT_N, r: SCRYPT_R, p: SCRYPT_P, maxmem: SCRYPT_MAXMEM },
|
|
7528
|
-
(err, key) => err ? reject(err) :
|
|
7173
|
+
(err, key) => err ? reject(err) : resolve7(key)
|
|
7529
7174
|
);
|
|
7530
7175
|
});
|
|
7531
7176
|
}
|
|
@@ -7559,8 +7204,8 @@ var SECRETS_FILENAME = "secrets.json";
|
|
|
7559
7204
|
var SECRETS_SCHEMA_VERSION = 1;
|
|
7560
7205
|
var VAULT_CHECK_PLAINTEXT = "yaw-mcp-vault-v1";
|
|
7561
7206
|
var VAULT_CHECK_CORRUPT_ERROR = 'vault verification token ("check") is corrupt -- the passphrase is correct, but the check marker does not decrypt';
|
|
7562
|
-
function vaultPath(home =
|
|
7563
|
-
return
|
|
7207
|
+
function vaultPath(home = homedir16()) {
|
|
7208
|
+
return join11(home, CONFIG_DIRNAME, SECRETS_FILENAME);
|
|
7564
7209
|
}
|
|
7565
7210
|
function emptyVault() {
|
|
7566
7211
|
return {
|
|
@@ -8034,6 +7679,12 @@ function nonTTYEnds(opts) {
|
|
|
8034
7679
|
if (!ends.stdin && !ends.stdout) return "neither stdin nor stdout is a TTY";
|
|
8035
7680
|
return ends.stdin ? "stdout is not a TTY" : "stdin is not a TTY";
|
|
8036
7681
|
}
|
|
7682
|
+
function promptUnavailableMessage(opts, required, envVar) {
|
|
7683
|
+
if (!isInteractiveTTY(opts) && (process.env.MSYSTEM ?? "") !== "") {
|
|
7684
|
+
return `${required} Node cannot prompt under Git Bash/MSYS -- the terminal is emulated with pipes, not a TTY. Set ${envVar}, run under winpty (winpty yaw-mcp ...), or use PowerShell/cmd.`;
|
|
7685
|
+
}
|
|
7686
|
+
return `${required} Set ${envVar} or run from a TTY so we can prompt.`;
|
|
7687
|
+
}
|
|
8037
7688
|
async function promptYesNo(opts, question) {
|
|
8038
7689
|
const stdin = opts.io?.stdin ?? process.stdin;
|
|
8039
7690
|
const stdout = opts.io?.stdout ?? process.stdout;
|
|
@@ -8128,7 +7779,7 @@ var CTRL_D = "";
|
|
|
8128
7779
|
var DEL = "\x7F";
|
|
8129
7780
|
function readLineFromTTY(stdin, stdout, prompt = "Vault passphrase: ", echo = false) {
|
|
8130
7781
|
stdout.write(prompt);
|
|
8131
|
-
return new Promise((
|
|
7782
|
+
return new Promise((resolve7) => {
|
|
8132
7783
|
const chunks = [];
|
|
8133
7784
|
const wasRaw = stdin.isRaw === true;
|
|
8134
7785
|
try {
|
|
@@ -8145,20 +7796,28 @@ function readLineFromTTY(stdin, stdout, prompt = "Vault passphrase: ", echo = fa
|
|
|
8145
7796
|
} catch {
|
|
8146
7797
|
}
|
|
8147
7798
|
stdin.pause();
|
|
8148
|
-
|
|
7799
|
+
resolve7(value);
|
|
8149
7800
|
};
|
|
8150
7801
|
function onData(chunk) {
|
|
7802
|
+
let consumed = 0;
|
|
7803
|
+
const finishAndRebuffer = (value) => {
|
|
7804
|
+
finish(value);
|
|
7805
|
+
const rest = chunk.slice(consumed);
|
|
7806
|
+
if (rest.length > 0) stdin.unshift?.(rest);
|
|
7807
|
+
};
|
|
8151
7808
|
for (const ch of chunk) {
|
|
7809
|
+
consumed += ch.length;
|
|
8152
7810
|
if (ch === "\n" || ch === "\r") {
|
|
8153
|
-
|
|
7811
|
+
if (ch === "\r" && chunk[consumed] === "\n") consumed += 1;
|
|
7812
|
+
finishAndRebuffer(chunks.join(""));
|
|
8154
7813
|
return;
|
|
8155
7814
|
}
|
|
8156
7815
|
if (ch === CTRL_D) {
|
|
8157
|
-
|
|
7816
|
+
finishAndRebuffer("");
|
|
8158
7817
|
return;
|
|
8159
7818
|
}
|
|
8160
7819
|
if (ch === CTRL_C) {
|
|
8161
|
-
|
|
7820
|
+
finishAndRebuffer(CANCELLED);
|
|
8162
7821
|
return;
|
|
8163
7822
|
}
|
|
8164
7823
|
if (ch === "\b" || ch === DEL) {
|
|
@@ -8192,7 +7851,7 @@ async function runSecrets(opts, io = {
|
|
|
8192
7851
|
out: (s) => process.stdout.write(s),
|
|
8193
7852
|
err: (s) => process.stderr.write(s)
|
|
8194
7853
|
}) {
|
|
8195
|
-
const home = opts.home ??
|
|
7854
|
+
const home = opts.home ?? homedir17();
|
|
8196
7855
|
const path6 = vaultPath(home);
|
|
8197
7856
|
if (opts.action === "lock") {
|
|
8198
7857
|
lock();
|
|
@@ -8270,7 +7929,7 @@ async function runSecrets(opts, io = {
|
|
|
8270
7929
|
const passphrase = await resolvePassphrase(opts, creatingVault);
|
|
8271
7930
|
if (passphrase === CANCELLED) return cancelledResult(io, opts.json);
|
|
8272
7931
|
if (passphrase === null) {
|
|
8273
|
-
const msg = "Passphrase required.
|
|
7932
|
+
const msg = promptUnavailableMessage(opts, "Passphrase required.", "YAW_MCP_VAULT_PASSPHRASE");
|
|
8274
7933
|
if (opts.json) io.err(`${JSON.stringify({ ok: false, error: msg })}
|
|
8275
7934
|
`);
|
|
8276
7935
|
else io.err(`yaw-mcp secrets: ${msg}
|
|
@@ -8367,7 +8026,7 @@ async function runSecrets(opts, io = {
|
|
|
8367
8026
|
return { exitCode: 2 };
|
|
8368
8027
|
}
|
|
8369
8028
|
async function runSecretsRotate(opts, io) {
|
|
8370
|
-
const home = opts.home ??
|
|
8029
|
+
const home = opts.home ?? homedir17();
|
|
8371
8030
|
const path6 = vaultPath(home);
|
|
8372
8031
|
const loaded = await safeLoadVault(path6, io, opts.json, "rotate");
|
|
8373
8032
|
if (!loaded.ok) return loaded.result;
|
|
@@ -8383,7 +8042,7 @@ async function runSecretsRotate(opts, io) {
|
|
|
8383
8042
|
const currentPassphrase = await resolvePassphrase(opts);
|
|
8384
8043
|
if (currentPassphrase === CANCELLED) return cancelledResult(io, opts.json);
|
|
8385
8044
|
if (currentPassphrase === null) {
|
|
8386
|
-
const msg = "Current passphrase required.
|
|
8045
|
+
const msg = promptUnavailableMessage(opts, "Current passphrase required.", "YAW_MCP_VAULT_PASSPHRASE");
|
|
8387
8046
|
if (opts.json) io.err(`${JSON.stringify({ ok: false, error: msg })}
|
|
8388
8047
|
`);
|
|
8389
8048
|
else io.err(`yaw-mcp secrets rotate: ${msg}
|
|
@@ -8404,7 +8063,11 @@ async function runSecretsRotate(opts, io) {
|
|
|
8404
8063
|
const newPassphrase = await resolveNewPassphrase(opts);
|
|
8405
8064
|
if (newPassphrase === CANCELLED) return cancelledResult(io, opts.json);
|
|
8406
8065
|
if (newPassphrase === null) {
|
|
8407
|
-
const msg =
|
|
8066
|
+
const msg = promptUnavailableMessage(
|
|
8067
|
+
opts,
|
|
8068
|
+
"New passphrase required (and must be confirmed).",
|
|
8069
|
+
"YAW_MCP_VAULT_PASSPHRASE_NEW"
|
|
8070
|
+
);
|
|
8408
8071
|
if (opts.json) io.err(`${JSON.stringify({ ok: false, error: msg })}
|
|
8409
8072
|
`);
|
|
8410
8073
|
else io.err(`yaw-mcp secrets rotate: ${msg}
|
|
@@ -8439,7 +8102,7 @@ async function runSecretsRotate(opts, io) {
|
|
|
8439
8102
|
return { exitCode: 0 };
|
|
8440
8103
|
}
|
|
8441
8104
|
async function runSecretsAudit(opts, io) {
|
|
8442
|
-
const home = opts.home ??
|
|
8105
|
+
const home = opts.home ?? homedir17();
|
|
8443
8106
|
let events;
|
|
8444
8107
|
try {
|
|
8445
8108
|
events = await readAuditLog(
|
|
@@ -8474,7 +8137,7 @@ async function runSecretsAudit(opts, io) {
|
|
|
8474
8137
|
}
|
|
8475
8138
|
|
|
8476
8139
|
// src/server.ts
|
|
8477
|
-
import { homedir as
|
|
8140
|
+
import { homedir as homedir18 } from "os";
|
|
8478
8141
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
8479
8142
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
8480
8143
|
import {
|
|
@@ -8482,162 +8145,11 @@ import {
|
|
|
8482
8145
|
GetPromptRequestSchema,
|
|
8483
8146
|
ListPromptsRequestSchema,
|
|
8484
8147
|
ListResourcesRequestSchema,
|
|
8148
|
+
ListResourceTemplatesRequestSchema,
|
|
8485
8149
|
ListToolsRequestSchema,
|
|
8486
8150
|
ReadResourceRequestSchema
|
|
8487
8151
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
8488
8152
|
|
|
8489
|
-
// src/auto-upgrade.ts
|
|
8490
|
-
import { spawn as spawn4 } from "child_process";
|
|
8491
|
-
import { realpathSync as realpathSync2 } from "fs";
|
|
8492
|
-
import { dirname as dirname3, sep } from "path";
|
|
8493
|
-
function quoteShellArgIfNeeded(arg, platform = process.platform) {
|
|
8494
|
-
if (platform !== "win32") return arg;
|
|
8495
|
-
if (/[\r\n\0"%]/.test(arg)) return null;
|
|
8496
|
-
if (!/[\s&|<>^]/.test(arg)) return arg;
|
|
8497
|
-
return `"${arg}"`;
|
|
8498
|
-
}
|
|
8499
|
-
function detectRunningInstallPrefix(argvPath) {
|
|
8500
|
-
if (!argvPath) return null;
|
|
8501
|
-
let resolved;
|
|
8502
|
-
try {
|
|
8503
|
-
resolved = realpathSync2(argvPath);
|
|
8504
|
-
} catch {
|
|
8505
|
-
return null;
|
|
8506
|
-
}
|
|
8507
|
-
let dir = dirname3(resolved);
|
|
8508
|
-
let prev = "";
|
|
8509
|
-
let safety = 24;
|
|
8510
|
-
while (dir !== prev && safety-- > 0) {
|
|
8511
|
-
const idx = dir.lastIndexOf(`${sep}node_modules${sep}`);
|
|
8512
|
-
if (idx !== -1) {
|
|
8513
|
-
const candidate = dir.slice(0, idx);
|
|
8514
|
-
if (candidate.endsWith(`${sep}lib`)) return candidate.slice(0, -`${sep}lib`.length);
|
|
8515
|
-
return candidate;
|
|
8516
|
-
}
|
|
8517
|
-
prev = dir;
|
|
8518
|
-
dir = dirname3(dir);
|
|
8519
|
-
}
|
|
8520
|
-
return null;
|
|
8521
|
-
}
|
|
8522
|
-
function comparablePrefix(p) {
|
|
8523
|
-
const trimmed = p.trim();
|
|
8524
|
-
return process.platform === "win32" ? trimmed.toLowerCase() : trimmed;
|
|
8525
|
-
}
|
|
8526
|
-
async function compareWithNpmPrefix(detected, probe = npmGlobalPrefix) {
|
|
8527
|
-
const npmPrefix = await probe();
|
|
8528
|
-
if (!npmPrefix?.trim()) return;
|
|
8529
|
-
if (comparablePrefix(npmPrefix) === comparablePrefix(detected)) return;
|
|
8530
|
-
process.stderr.write(
|
|
8531
|
-
`yaw-mcp self-upgrade: detected running prefix differs from \`npm prefix -g\`:
|
|
8532
|
-
running: ${detected}
|
|
8533
|
-
npm -g: ${npmPrefix}
|
|
8534
|
-
Installing into the running prefix so the upgrade lands in the same tree the client spawned from.
|
|
8535
|
-
`
|
|
8536
|
-
);
|
|
8537
|
-
}
|
|
8538
|
-
function defaultSpawn2(cmd, args) {
|
|
8539
|
-
let errorFired = false;
|
|
8540
|
-
const correctiveCmd = cmd === "npm" ? "npm install -g @yawlabs/mcp@latest" : cmd === "pnpm" ? "pnpm add -g @yawlabs/mcp@latest" : "bun add -g @yawlabs/mcp@latest";
|
|
8541
|
-
const child = spawn4(cmd, args, {
|
|
8542
|
-
stdio: "ignore",
|
|
8543
|
-
// Not detached, so the install shares yaw-mcp's process group and an MCP
|
|
8544
|
-
// client that tears down the whole tree takes it with it. Two things this
|
|
8545
|
-
// does NOT buy (the file header lists both as known gaps): on POSIX a
|
|
8546
|
-
// plain parent exit does not kill it, and if it IS killed mid-install the
|
|
8547
|
-
// result is not guaranteed intact -- npm reify removes the existing
|
|
8548
|
-
// package dir before moving the new one in, and nothing here repairs a
|
|
8549
|
-
// partial install on the next startup.
|
|
8550
|
-
detached: false,
|
|
8551
|
-
shell: process.platform === "win32"
|
|
8552
|
-
});
|
|
8553
|
-
child.on("close", (code) => {
|
|
8554
|
-
if (errorFired) return;
|
|
8555
|
-
if (code === 0) {
|
|
8556
|
-
log("info", "yaw-mcp self-upgrade complete; the next client restart will run the new version");
|
|
8557
|
-
} else {
|
|
8558
|
-
const hint = cmd === "npm" ? " (often EACCES on a sudo-installed global -- run with the right permissions)" : "";
|
|
8559
|
-
log(
|
|
8560
|
-
"warn",
|
|
8561
|
-
`yaw-mcp self-upgrade: ${cmd} exited non-zero${hint}. Run \`${correctiveCmd}\` manually, or set YAW_MCP_AUTO_UPGRADE=0 to silence this.`,
|
|
8562
|
-
{ code }
|
|
8563
|
-
);
|
|
8564
|
-
}
|
|
8565
|
-
});
|
|
8566
|
-
child.on("error", (err) => {
|
|
8567
|
-
errorFired = true;
|
|
8568
|
-
log("warn", `yaw-mcp self-upgrade: ${cmd} spawn failed`, { error: err?.message });
|
|
8569
|
-
});
|
|
8570
|
-
}
|
|
8571
|
-
async function maybeAutoUpgrade(deps = {}) {
|
|
8572
|
-
const optOut = process.env.YAW_MCP_AUTO_UPGRADE;
|
|
8573
|
-
if (optOut === "0" || optOut?.toLowerCase() === "false") return;
|
|
8574
|
-
const current = deps.currentVersion ?? (true ? "0.75.2" : "dev");
|
|
8575
|
-
if (current === "dev") return;
|
|
8576
|
-
const method = (deps.isSeaImpl ? await deps.isSeaImpl() : await detectSea()) ? "binary" : detectInstallMethod(deps.argvPath ?? process.argv[1]);
|
|
8577
|
-
const latest = await (deps.fetchLatestImpl ?? fetchLatestVersion)();
|
|
8578
|
-
if (latest === null) return;
|
|
8579
|
-
const plan = buildUpgradePlan({ current, latest, method });
|
|
8580
|
-
if (!plan.stale) return;
|
|
8581
|
-
const rawPrefix = method === "global-npm" ? detectRunningInstallPrefix(deps.argvPath ?? process.argv[1]) : null;
|
|
8582
|
-
const quotedPrefix = rawPrefix === null ? null : quoteShellArgIfNeeded(rawPrefix);
|
|
8583
|
-
const globalSpec = method === "global-npm" ? {
|
|
8584
|
-
cmd: "npm",
|
|
8585
|
-
args: quotedPrefix ? ["install", "-g", "--prefix", quotedPrefix, "@yawlabs/mcp@latest"] : ["install", "-g", "@yawlabs/mcp@latest"]
|
|
8586
|
-
} : method === "pnpm-global" ? { cmd: "pnpm", args: ["add", "-g", "@yawlabs/mcp@latest"] } : method === "bun-global" ? { cmd: "bun", args: ["add", "-g", "@yawlabs/mcp@latest"] } : null;
|
|
8587
|
-
if (globalSpec) {
|
|
8588
|
-
log("info", "yaw-mcp is out of date; upgrading the global install in the background", {
|
|
8589
|
-
current,
|
|
8590
|
-
latest,
|
|
8591
|
-
tool: globalSpec.cmd,
|
|
8592
|
-
// The RAW prefix, not the shell-quoted argv form -- a log field is read
|
|
8593
|
-
// by a human, and stray quotes read as part of the path. Omitted when
|
|
8594
|
-
// quoting failed, because then no `--prefix` was passed at all and npm
|
|
8595
|
-
// resolves its own prefix.
|
|
8596
|
-
prefix: quotedPrefix === null ? void 0 : rawPrefix ?? void 0
|
|
8597
|
-
});
|
|
8598
|
-
if (method === "global-npm" && rawPrefix !== null && quotedPrefix !== null) {
|
|
8599
|
-
void compareWithNpmPrefix(rawPrefix, deps.npmPrefixImpl);
|
|
8600
|
-
}
|
|
8601
|
-
(deps.spawnImpl ?? defaultSpawn2)(globalSpec.cmd, globalSpec.args);
|
|
8602
|
-
return;
|
|
8603
|
-
}
|
|
8604
|
-
if (method === "bundled-app") {
|
|
8605
|
-
log("info", "yaw-mcp (bundled with Yaw Terminal) is behind npm; it updates with the app", { current, latest });
|
|
8606
|
-
return;
|
|
8607
|
-
}
|
|
8608
|
-
if (method === "binary") {
|
|
8609
|
-
log("info", "yaw-mcp (standalone binary) is behind npm; download the latest build to update", { current, latest });
|
|
8610
|
-
return;
|
|
8611
|
-
}
|
|
8612
|
-
if (method === "npx") {
|
|
8613
|
-
log("info", "yaw-mcp is out of date; restart your MCP client to pick up the latest version", {
|
|
8614
|
-
current,
|
|
8615
|
-
latest,
|
|
8616
|
-
method
|
|
8617
|
-
});
|
|
8618
|
-
} else if (method === "local-node-modules") {
|
|
8619
|
-
log(
|
|
8620
|
-
"info",
|
|
8621
|
-
"yaw-mcp is out of date; run `yaw-mcp upgrade --run` to update this install (a restart re-runs the version pinned in your project's node_modules)",
|
|
8622
|
-
{
|
|
8623
|
-
current,
|
|
8624
|
-
latest,
|
|
8625
|
-
method
|
|
8626
|
-
}
|
|
8627
|
-
);
|
|
8628
|
-
} else {
|
|
8629
|
-
log(
|
|
8630
|
-
"info",
|
|
8631
|
-
"yaw-mcp is out of date; run `yaw-mcp upgrade` for the command that updates this install (`--run` can't automate this install method)",
|
|
8632
|
-
{
|
|
8633
|
-
current,
|
|
8634
|
-
latest,
|
|
8635
|
-
method
|
|
8636
|
-
}
|
|
8637
|
-
);
|
|
8638
|
-
}
|
|
8639
|
-
}
|
|
8640
|
-
|
|
8641
8153
|
// src/compliance.ts
|
|
8642
8154
|
var GRADE_ORDER = {
|
|
8643
8155
|
A: 4,
|
|
@@ -8999,6 +8511,9 @@ function validateExecRequest(req) {
|
|
|
8999
8511
|
if (typeof s.id !== "string" || s.id.length === 0) {
|
|
9000
8512
|
return { ok: false, message: `step ${i}: \`id\` must be a non-empty string` };
|
|
9001
8513
|
}
|
|
8514
|
+
if (s.id === "__proto__") {
|
|
8515
|
+
return { ok: false, message: `step ${i}: \`id\` "__proto__" is reserved; use a different id` };
|
|
8516
|
+
}
|
|
9002
8517
|
if (seenIds.has(s.id)) {
|
|
9003
8518
|
return { ok: false, message: `step ${i}: duplicate id "${s.id}"` };
|
|
9004
8519
|
}
|
|
@@ -9175,12 +8690,12 @@ function pushToolCall(history, record, limit = HISTORY_LIMIT) {
|
|
|
9175
8690
|
|
|
9176
8691
|
// src/install-nudge.ts
|
|
9177
8692
|
import { existsSync as existsSync9, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "fs";
|
|
9178
|
-
import { dirname as
|
|
8693
|
+
import { dirname as dirname3, join as join12 } from "path";
|
|
9179
8694
|
var INSTALL_NUDGE_MIN_COUNT = 5;
|
|
9180
8695
|
var INSTALL_NUDGE_COOLDOWN_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
9181
8696
|
var INSTALL_NUDGE_STATE_FILENAME = "install-nudge-state.json";
|
|
9182
8697
|
function installNudgeStatePath(home) {
|
|
9183
|
-
return
|
|
8698
|
+
return join12(home, CONFIG_DIRNAME, INSTALL_NUDGE_STATE_FILENAME);
|
|
9184
8699
|
}
|
|
9185
8700
|
function installNudgeEnabled(env, config) {
|
|
9186
8701
|
if (env.YAW_MCP_INSTALL_NUDGE === "1") return true;
|
|
@@ -9219,7 +8734,7 @@ function recordNudge(cli, home, now = Date.now) {
|
|
|
9219
8734
|
const kept = state.nudges.filter((n) => n.cli !== cli && at - n.nudgedAt < INSTALL_NUDGE_COOLDOWN_MS);
|
|
9220
8735
|
kept.push({ cli, nudgedAt: at });
|
|
9221
8736
|
const path6 = installNudgeStatePath(home);
|
|
9222
|
-
mkdirSync3(
|
|
8737
|
+
mkdirSync3(dirname3(path6), { recursive: true });
|
|
9223
8738
|
writeFileSync2(path6, `${JSON.stringify({ nudges: kept }, null, 2)}
|
|
9224
8739
|
`, "utf8");
|
|
9225
8740
|
} catch (err) {
|
|
@@ -9336,6 +8851,11 @@ var META_TOOLS = {
|
|
|
9336
8851
|
type: "number",
|
|
9337
8852
|
default: 1,
|
|
9338
8853
|
description: "How many top-ranked servers to load into the session. Defaults to 1. Cap is 10. Raise only when one task genuinely spans multiple servers."
|
|
8854
|
+
},
|
|
8855
|
+
routeEffort: {
|
|
8856
|
+
type: "string",
|
|
8857
|
+
enum: ["off", "auto", "aggressive"],
|
|
8858
|
+
description: 'Per-call override of the routing-effort dial. "off" never asks the client LLM to break ranking ties; "auto" (the default) asks once only on genuine ambiguity; "aggressive" samples best-of-3 on milder ambiguity. Falls back to the YAW_MCP_ROUTE_EFFORT env var when omitted. Only meaningful at budget 1.'
|
|
9339
8859
|
}
|
|
9340
8860
|
},
|
|
9341
8861
|
required: ["intent"]
|
|
@@ -9506,6 +9026,7 @@ var DEFAULT_MAX_GAP_MS = 12e4;
|
|
|
9506
9026
|
var MIN_NAMESPACES = 2;
|
|
9507
9027
|
var MAX_NAMESPACES = 3;
|
|
9508
9028
|
var MIN_RECURRENCES = 2;
|
|
9029
|
+
var BURST_SPAN_FACTOR = 5;
|
|
9509
9030
|
function packIdFromNamespaces(namespaces) {
|
|
9510
9031
|
return Array.from(new Set(namespaces)).sort().join("|");
|
|
9511
9032
|
}
|
|
@@ -9525,8 +9046,8 @@ var PackDetector = class {
|
|
|
9525
9046
|
this.history = this.history.slice(overflow);
|
|
9526
9047
|
}
|
|
9527
9048
|
}
|
|
9528
|
-
// Walk the history, segmenting it into "bursts"
|
|
9529
|
-
//
|
|
9049
|
+
// Walk the history, segmenting it into "bursts" (see segmentBursts for
|
|
9050
|
+
// the three boundaries). Each burst with ≥2 distinct namespaces is a
|
|
9530
9051
|
// candidate pack. A pack is returned when the same namespace set
|
|
9531
9052
|
// appears in ≥MIN_RECURRENCES bursts.
|
|
9532
9053
|
detectChains() {
|
|
@@ -9561,18 +9082,33 @@ var PackDetector = class {
|
|
|
9561
9082
|
}
|
|
9562
9083
|
return packs;
|
|
9563
9084
|
}
|
|
9564
|
-
// Segment the call history into bursts. A new burst starts whenever
|
|
9565
|
-
// the gap to the previous call exceeds maxGapMs
|
|
9566
|
-
//
|
|
9567
|
-
//
|
|
9568
|
-
//
|
|
9085
|
+
// Segment the call history into bursts. A new burst starts whenever:
|
|
9086
|
+
// 1. the gap to the previous call exceeds maxGapMs (idle boundary);
|
|
9087
|
+
// 2. the burst has already spanned maxGapMs * BURST_SPAN_FACTOR
|
|
9088
|
+
// (span boundary -- see the constant for why a continuous session
|
|
9089
|
+
// must be sliced for recurrence to be countable); or
|
|
9090
|
+
// 3. the call would add a namespace past MAX_NAMESPACES (overflow
|
|
9091
|
+
// boundary). detectChains drops an over-wide burst entirely, so
|
|
9092
|
+
// without this cut a single visit to a 4th namespace poisoned the
|
|
9093
|
+
// whole burst and the recurring trio inside it was never counted.
|
|
9094
|
+
// Cutting at the overflow keeps each burst representable as a
|
|
9095
|
+
// pack; a wider rotation surfaces as its recurring 3-subsets, the
|
|
9096
|
+
// best answer the MAX_NAMESPACES pack-size cap can express.
|
|
9097
|
+
// Within a burst, each namespace is recorded only once
|
|
9098
|
+
// (order-of-first-appearance); the "last seen" timestamp tracks the
|
|
9099
|
+
// most recent call in the burst so recency ranking is truthful even
|
|
9100
|
+
// when the burst has many calls.
|
|
9569
9101
|
segmentBursts() {
|
|
9570
9102
|
const bursts = [];
|
|
9103
|
+
const maxBurstSpanMs = this.maxGapMs * BURST_SPAN_FACTOR;
|
|
9571
9104
|
let current = null;
|
|
9572
9105
|
let prevAt = 0;
|
|
9573
9106
|
for (const call of this.history) {
|
|
9574
|
-
|
|
9575
|
-
|
|
9107
|
+
const gapExceeded = call.at - prevAt > this.maxGapMs;
|
|
9108
|
+
const spanExceeded = current !== null && call.at - current.startAt > maxBurstSpanMs;
|
|
9109
|
+
const wouldOverflow = current !== null && current.namespaces.length >= MAX_NAMESPACES && !current.namespaces.includes(call.namespace);
|
|
9110
|
+
if (!current || gapExceeded || spanExceeded || wouldOverflow) {
|
|
9111
|
+
current = { namespaces: [call.namespace], startAt: call.at, lastAt: call.at };
|
|
9576
9112
|
bursts.push(current);
|
|
9577
9113
|
} else {
|
|
9578
9114
|
if (!current.namespaces.includes(call.namespace)) {
|
|
@@ -9630,18 +9166,24 @@ function createProgressReporter(extra) {
|
|
|
9630
9166
|
return () => {
|
|
9631
9167
|
};
|
|
9632
9168
|
}
|
|
9633
|
-
|
|
9634
|
-
let lastEmitted = -
|
|
9169
|
+
const EPSILON = 1e-3;
|
|
9170
|
+
let lastEmitted = -EPSILON;
|
|
9635
9171
|
return (message, progress, total) => {
|
|
9636
|
-
|
|
9637
|
-
|
|
9638
|
-
|
|
9172
|
+
let emitted;
|
|
9173
|
+
let emittedTotal;
|
|
9174
|
+
if (progress !== void 0) {
|
|
9175
|
+
emitted = progress > lastEmitted ? progress : lastEmitted + EPSILON;
|
|
9176
|
+
emittedTotal = total !== void 0 && emitted <= total ? total : void 0;
|
|
9177
|
+
} else {
|
|
9178
|
+
emitted = lastEmitted + EPSILON;
|
|
9179
|
+
emittedTotal = void 0;
|
|
9180
|
+
}
|
|
9639
9181
|
const params = {
|
|
9640
9182
|
progressToken: token,
|
|
9641
9183
|
progress: emitted,
|
|
9642
9184
|
message
|
|
9643
9185
|
};
|
|
9644
|
-
if (
|
|
9186
|
+
if (emittedTotal !== void 0) params.total = emittedTotal;
|
|
9645
9187
|
lastEmitted = emitted;
|
|
9646
9188
|
send({ method: "notifications/progress", params }).catch((err) => {
|
|
9647
9189
|
log("warn", "Progress notification send failed", {
|
|
@@ -9684,9 +9226,12 @@ function buildToolList(activeConnections, inactiveWithCache = [], toolFilters, e
|
|
|
9684
9226
|
if (seen.has(tool.namespacedName)) continue;
|
|
9685
9227
|
tools.push({
|
|
9686
9228
|
name: tool.namespacedName,
|
|
9229
|
+
title: tool.title,
|
|
9687
9230
|
description: tool.description,
|
|
9688
9231
|
inputSchema: tool.inputSchema,
|
|
9689
|
-
|
|
9232
|
+
outputSchema: tool.outputSchema,
|
|
9233
|
+
annotations: tool.annotations,
|
|
9234
|
+
_meta: tool._meta
|
|
9690
9235
|
});
|
|
9691
9236
|
seen.add(tool.namespacedName);
|
|
9692
9237
|
}
|
|
@@ -9966,7 +9511,7 @@ function numberLiteralIsFaithful(literal) {
|
|
|
9966
9511
|
return digits.replace(/0+$/, "").length <= MAX_FAITHFUL_MANTISSA_DIGITS;
|
|
9967
9512
|
}
|
|
9968
9513
|
function pruneWhitespace(text) {
|
|
9969
|
-
return text.split("\n").map((line) => line.replace(/[ \t]
|
|
9514
|
+
return text.split("\n").map((line) => line.replace(/[ \t]+(?=\r?$)/, "")).join("\n").replace(/(?:\r?\n){3,}/g, (run2) => run2.includes("\r") ? "\r\n\r\n" : "\n\n");
|
|
9970
9515
|
}
|
|
9971
9516
|
function pruneJson(value) {
|
|
9972
9517
|
if (value === null || value === void 0) return void 0;
|
|
@@ -10137,9 +9682,11 @@ function firstTextBlock(result) {
|
|
|
10137
9682
|
return void 0;
|
|
10138
9683
|
}
|
|
10139
9684
|
function isEmptyBody(result) {
|
|
9685
|
+
if (result.structuredContent !== void 0) return false;
|
|
10140
9686
|
const content = result.content;
|
|
10141
9687
|
if (!content || content.length === 0) return true;
|
|
10142
9688
|
for (const block of content) {
|
|
9689
|
+
if (block.type !== "text") return false;
|
|
10143
9690
|
if (typeof block.text === "string" && block.text.trim().length > 0) {
|
|
10144
9691
|
return false;
|
|
10145
9692
|
}
|
|
@@ -10224,11 +9771,19 @@ async function gradeOutcomeViaSampling(server, ctx) {
|
|
|
10224
9771
|
const prompt = buildGraderPrompt(ctx);
|
|
10225
9772
|
try {
|
|
10226
9773
|
const result = await withTimeout(
|
|
10227
|
-
server.createMessage(
|
|
10228
|
-
|
|
10229
|
-
|
|
10230
|
-
|
|
10231
|
-
|
|
9774
|
+
server.createMessage(
|
|
9775
|
+
{
|
|
9776
|
+
messages: [{ role: "user", content: { type: "text", text: prompt } }],
|
|
9777
|
+
maxTokens: GRADER_MAX_TOKENS,
|
|
9778
|
+
includeContext: "none"
|
|
9779
|
+
},
|
|
9780
|
+
// Cancel the REQUEST at the deadline, not just our wait for it: the
|
|
9781
|
+
// SDK's request timeout sends notifications/cancelled to the client
|
|
9782
|
+
// and rejects here. Without it, abandoning the promise left the
|
|
9783
|
+
// sampling request (and the client's generation / token spend)
|
|
9784
|
+
// running until the SDK's 60s DEFAULT_REQUEST_TIMEOUT_MSEC.
|
|
9785
|
+
{ timeout: GRADER_TIMEOUT_MS }
|
|
9786
|
+
),
|
|
10232
9787
|
GRADER_TIMEOUT_MS
|
|
10233
9788
|
);
|
|
10234
9789
|
if (!result || typeof result !== "object" || !("content" in result) || !result.content) return null;
|
|
@@ -10241,17 +9796,17 @@ async function gradeOutcomeViaSampling(server, ctx) {
|
|
|
10241
9796
|
}
|
|
10242
9797
|
}
|
|
10243
9798
|
function withTimeout(p, ms) {
|
|
10244
|
-
return new Promise((
|
|
10245
|
-
const timer = setTimeout(() =>
|
|
9799
|
+
return new Promise((resolve7) => {
|
|
9800
|
+
const timer = setTimeout(() => resolve7(null), ms);
|
|
10246
9801
|
if (typeof timer === "object" && timer && "unref" in timer) timer.unref();
|
|
10247
9802
|
p.then(
|
|
10248
9803
|
(v) => {
|
|
10249
9804
|
clearTimeout(timer);
|
|
10250
|
-
|
|
9805
|
+
resolve7(v);
|
|
10251
9806
|
},
|
|
10252
9807
|
() => {
|
|
10253
9808
|
clearTimeout(timer);
|
|
10254
|
-
|
|
9809
|
+
resolve7(null);
|
|
10255
9810
|
}
|
|
10256
9811
|
);
|
|
10257
9812
|
});
|
|
@@ -10445,8 +10000,8 @@ async function bestOfNViaSampling(server, intent, candidates, n) {
|
|
|
10445
10000
|
return winner;
|
|
10446
10001
|
})();
|
|
10447
10002
|
let timer;
|
|
10448
|
-
const timeout = new Promise((
|
|
10449
|
-
timer = setTimeout(() =>
|
|
10003
|
+
const timeout = new Promise((resolve7) => {
|
|
10004
|
+
timer = setTimeout(() => resolve7(null), SAMPLING_TIMEOUT_MS);
|
|
10450
10005
|
});
|
|
10451
10006
|
try {
|
|
10452
10007
|
return await Promise.race([aggregate, timeout]);
|
|
@@ -10460,8 +10015,10 @@ var DEFAULT_SERVER_CAP = 6;
|
|
|
10460
10015
|
function resolveServerCap(env = process.env) {
|
|
10461
10016
|
const raw = env.YAW_MCP_SERVER_CAP;
|
|
10462
10017
|
if (raw === void 0 || raw === "") return DEFAULT_SERVER_CAP;
|
|
10463
|
-
const
|
|
10464
|
-
if (
|
|
10018
|
+
const trimmed = raw.trim();
|
|
10019
|
+
if (!/^\d+$/.test(trimmed)) return DEFAULT_SERVER_CAP;
|
|
10020
|
+
const n = Number.parseInt(trimmed, 10);
|
|
10021
|
+
if (!Number.isFinite(n)) return DEFAULT_SERVER_CAP;
|
|
10465
10022
|
return n;
|
|
10466
10023
|
}
|
|
10467
10024
|
function evaluateServerCap(namespace, loaded, cap) {
|
|
@@ -10485,23 +10042,35 @@ import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
|
10485
10042
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
10486
10043
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
10487
10044
|
import {
|
|
10045
|
+
CreateMessageRequestSchema,
|
|
10046
|
+
ElicitRequestSchema,
|
|
10047
|
+
ListRootsRequestSchema,
|
|
10488
10048
|
PromptListChangedNotificationSchema,
|
|
10489
10049
|
ResourceListChangedNotificationSchema,
|
|
10490
10050
|
ToolListChangedNotificationSchema
|
|
10491
10051
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
10492
10052
|
|
|
10493
10053
|
// src/uv-bootstrap.ts
|
|
10494
|
-
import { spawn as
|
|
10054
|
+
import { spawn as spawn3 } from "child_process";
|
|
10495
10055
|
import { createHash as createHash3 } from "crypto";
|
|
10496
10056
|
import { createWriteStream } from "fs";
|
|
10497
10057
|
import fs from "fs/promises";
|
|
10498
10058
|
import path5 from "path";
|
|
10499
10059
|
import { pipeline } from "stream/promises";
|
|
10500
10060
|
import { request } from "undici";
|
|
10501
|
-
var UV_VERSION = "0.
|
|
10061
|
+
var UV_VERSION = "0.12.5";
|
|
10502
10062
|
var RELEASE_BASE = `https://github.com/astral-sh/uv/releases/download/${UV_VERSION}`;
|
|
10503
|
-
function
|
|
10504
|
-
|
|
10063
|
+
function isMuslLibc() {
|
|
10064
|
+
try {
|
|
10065
|
+
const raw = process.report?.getReport();
|
|
10066
|
+
const report = typeof raw === "string" ? JSON.parse(raw) : raw;
|
|
10067
|
+
const header = report?.header;
|
|
10068
|
+
return typeof header?.glibcVersionRuntime !== "string";
|
|
10069
|
+
} catch {
|
|
10070
|
+
return false;
|
|
10071
|
+
}
|
|
10072
|
+
}
|
|
10073
|
+
function uvTarget(platform = process.platform, arch = process.arch, musl = platform === "linux" && isMuslLibc()) {
|
|
10505
10074
|
if (platform === "win32") {
|
|
10506
10075
|
if (arch === "x64") return "x86_64-pc-windows-msvc";
|
|
10507
10076
|
if (arch === "arm64") return "aarch64-pc-windows-msvc";
|
|
@@ -10514,8 +10083,9 @@ function uvTarget() {
|
|
|
10514
10083
|
return null;
|
|
10515
10084
|
}
|
|
10516
10085
|
if (platform === "linux") {
|
|
10517
|
-
|
|
10518
|
-
if (arch === "
|
|
10086
|
+
const libc = musl ? "musl" : "gnu";
|
|
10087
|
+
if (arch === "x64") return `x86_64-unknown-linux-${libc}`;
|
|
10088
|
+
if (arch === "arm64") return `aarch64-unknown-linux-${libc}`;
|
|
10519
10089
|
return null;
|
|
10520
10090
|
}
|
|
10521
10091
|
return null;
|
|
@@ -10535,16 +10105,16 @@ async function exists2(p) {
|
|
|
10535
10105
|
}
|
|
10536
10106
|
}
|
|
10537
10107
|
async function onPath(cmd) {
|
|
10538
|
-
return new Promise((
|
|
10108
|
+
return new Promise((resolve7) => {
|
|
10539
10109
|
let settled = false;
|
|
10540
10110
|
const settle = (v) => {
|
|
10541
10111
|
if (settled) return;
|
|
10542
10112
|
settled = true;
|
|
10543
|
-
|
|
10113
|
+
resolve7(v);
|
|
10544
10114
|
};
|
|
10545
10115
|
let child;
|
|
10546
10116
|
try {
|
|
10547
|
-
child =
|
|
10117
|
+
child = spawn3(cmd, ["--version"], {
|
|
10548
10118
|
stdio: "ignore",
|
|
10549
10119
|
// Windows needs a shell for PATHEXT shim resolution (.cmd/.exe)
|
|
10550
10120
|
// so `uv --version` finds uv.cmd without an ENOENT false-negative.
|
|
@@ -10558,7 +10128,11 @@ async function onPath(cmd) {
|
|
|
10558
10128
|
}
|
|
10559
10129
|
const timer = setTimeout(() => {
|
|
10560
10130
|
try {
|
|
10561
|
-
child.kill();
|
|
10131
|
+
child.kill("SIGKILL");
|
|
10132
|
+
} catch {
|
|
10133
|
+
}
|
|
10134
|
+
try {
|
|
10135
|
+
child.unref();
|
|
10562
10136
|
} catch {
|
|
10563
10137
|
}
|
|
10564
10138
|
settle(false);
|
|
@@ -10641,7 +10215,7 @@ async function extractArchive(archivePath, destDir) {
|
|
|
10641
10215
|
var UV_EXTRACT_TIMEOUT_MS = 12e4;
|
|
10642
10216
|
var RUN_COMMAND_MAX_STDERR = 8 * 1024;
|
|
10643
10217
|
function runCommand(cmd, args, timeoutMs = UV_EXTRACT_TIMEOUT_MS) {
|
|
10644
|
-
return new Promise((
|
|
10218
|
+
return new Promise((resolve7, reject) => {
|
|
10645
10219
|
let settled = false;
|
|
10646
10220
|
let timer;
|
|
10647
10221
|
const settle = (fn) => {
|
|
@@ -10652,7 +10226,7 @@ function runCommand(cmd, args, timeoutMs = UV_EXTRACT_TIMEOUT_MS) {
|
|
|
10652
10226
|
};
|
|
10653
10227
|
let child;
|
|
10654
10228
|
try {
|
|
10655
|
-
child =
|
|
10229
|
+
child = spawn3(cmd, args, {
|
|
10656
10230
|
stdio: ["ignore", "ignore", "pipe"],
|
|
10657
10231
|
shell: false,
|
|
10658
10232
|
windowsHide: process.platform === "win32"
|
|
@@ -10672,7 +10246,7 @@ function runCommand(cmd, args, timeoutMs = UV_EXTRACT_TIMEOUT_MS) {
|
|
|
10672
10246
|
child.on(
|
|
10673
10247
|
"close",
|
|
10674
10248
|
(code, signal) => settle(() => {
|
|
10675
|
-
if (code === 0)
|
|
10249
|
+
if (code === 0) resolve7();
|
|
10676
10250
|
else reject(new Error(`${cmd} exited ${code ?? signal}: ${stderr.trim()}`));
|
|
10677
10251
|
})
|
|
10678
10252
|
);
|
|
@@ -10723,7 +10297,7 @@ async function resolveUv() {
|
|
|
10723
10297
|
`No prebuilt uv binary for ${process.platform}/${process.arch}. Install uv manually: https://docs.astral.sh/uv/`
|
|
10724
10298
|
);
|
|
10725
10299
|
}
|
|
10726
|
-
const installDir = path5.join(cacheDir(), "uv", UV_VERSION);
|
|
10300
|
+
const installDir = path5.join(cacheDir(), "uv", UV_VERSION, target);
|
|
10727
10301
|
const finalBin = path5.join(installDir, binName());
|
|
10728
10302
|
if (await exists2(finalBin)) return finalBin;
|
|
10729
10303
|
await fs.mkdir(installDir, { recursive: true });
|
|
@@ -10768,10 +10342,19 @@ async function resolveUv() {
|
|
|
10768
10342
|
log("info", "uv bootstrap complete", { bin: finalBin });
|
|
10769
10343
|
return finalBin;
|
|
10770
10344
|
}
|
|
10345
|
+
var UV_WIN_EXE_EXT = /\.(?:exe|cmd|bat)$/i;
|
|
10346
|
+
function uvLaunchKind(command) {
|
|
10347
|
+
if (/[\\/]/.test(command)) return null;
|
|
10348
|
+
const base = command.replace(UV_WIN_EXE_EXT, "").toLowerCase();
|
|
10349
|
+
if (base === "uv") return "uv";
|
|
10350
|
+
if (base === "uvx") return "uvx";
|
|
10351
|
+
return null;
|
|
10352
|
+
}
|
|
10771
10353
|
async function resolveUvSpawn(command, args) {
|
|
10772
|
-
|
|
10354
|
+
const kind = uvLaunchKind(command);
|
|
10355
|
+
if (kind === null) return { command, args };
|
|
10773
10356
|
const uvBin = await ensureUv();
|
|
10774
|
-
if (
|
|
10357
|
+
if (kind === "uvx") {
|
|
10775
10358
|
return { command: uvBin, args: ["tool", "run", ...args] };
|
|
10776
10359
|
}
|
|
10777
10360
|
return { command: uvBin, args };
|
|
@@ -10883,10 +10466,10 @@ function categorizeSpawnError(err) {
|
|
|
10883
10466
|
return "unknown";
|
|
10884
10467
|
}
|
|
10885
10468
|
var oamDowngradedNamespaces = /* @__PURE__ */ new Set();
|
|
10886
|
-
async function connectToUpstream(config, onDisconnect, onListChanged) {
|
|
10469
|
+
async function connectToUpstream(config, onDisconnect, onListChanged, bridge) {
|
|
10887
10470
|
const attempt = { oamRewriteApplied: false, oamVersion: null };
|
|
10888
10471
|
try {
|
|
10889
|
-
return await connectToUpstreamOnce(config, onDisconnect, onListChanged, attempt, false);
|
|
10472
|
+
return await connectToUpstreamOnce(config, onDisconnect, onListChanged, bridge, attempt, false);
|
|
10890
10473
|
} catch (err) {
|
|
10891
10474
|
if (!attempt.oamRewriteApplied || !(err instanceof ActivationError)) throw err;
|
|
10892
10475
|
log("warn", "oam-hosted server failed to boot; downgrading to node for this session", {
|
|
@@ -10896,7 +10479,7 @@ async function connectToUpstream(config, onDisconnect, onListChanged) {
|
|
|
10896
10479
|
error: err.message
|
|
10897
10480
|
});
|
|
10898
10481
|
try {
|
|
10899
|
-
const connection = await connectToUpstreamOnce(config, onDisconnect, onListChanged, attempt, true);
|
|
10482
|
+
const connection = await connectToUpstreamOnce(config, onDisconnect, onListChanged, bridge, attempt, true);
|
|
10900
10483
|
oamDowngradedNamespaces.add(config.namespace);
|
|
10901
10484
|
return connection;
|
|
10902
10485
|
} catch (nodeErr) {
|
|
@@ -10913,11 +10496,43 @@ async function connectToUpstream(config, onDisconnect, onListChanged) {
|
|
|
10913
10496
|
}
|
|
10914
10497
|
}
|
|
10915
10498
|
}
|
|
10916
|
-
|
|
10499
|
+
var INTERNAL_SECRET_ENV_KEYS = /* @__PURE__ */ new Set(["YAW_MCP_TOKEN", "YAW_MCP_VAULT_PASSPHRASE", "YAW_MCP_VAULT_PASSPHRASE_NEW"]);
|
|
10500
|
+
function stripInternalSecretsFromEnv(env) {
|
|
10501
|
+
const out = {};
|
|
10502
|
+
for (const [key, value] of Object.entries(env)) {
|
|
10503
|
+
if (INTERNAL_SECRET_ENV_KEYS.has(key.toUpperCase())) continue;
|
|
10504
|
+
out[key] = value;
|
|
10505
|
+
}
|
|
10506
|
+
return out;
|
|
10507
|
+
}
|
|
10508
|
+
async function connectToUpstreamOnce(config, onDisconnect, onListChanged, bridge, attempt, disableOamRewrite) {
|
|
10509
|
+
const downstreamCaps = bridge?.getClientCapabilities();
|
|
10510
|
+
const capabilities = {};
|
|
10511
|
+
if (downstreamCaps?.elicitation) capabilities.elicitation = downstreamCaps.elicitation;
|
|
10512
|
+
if (downstreamCaps?.sampling) capabilities.sampling = downstreamCaps.sampling;
|
|
10513
|
+
if (downstreamCaps?.roots) capabilities.roots = {};
|
|
10917
10514
|
const client = new Client(
|
|
10918
|
-
{ name: "yaw-mcp", version: true ? "0.
|
|
10919
|
-
{ capabilities
|
|
10515
|
+
{ name: "yaw-mcp", version: true ? "0.76.0" : "dev" },
|
|
10516
|
+
{ capabilities }
|
|
10920
10517
|
);
|
|
10518
|
+
if (bridge && capabilities.elicitation) {
|
|
10519
|
+
client.setRequestHandler(
|
|
10520
|
+
ElicitRequestSchema,
|
|
10521
|
+
(request2, extra) => bridge.elicitInput(request2.params, { signal: extra.signal })
|
|
10522
|
+
);
|
|
10523
|
+
}
|
|
10524
|
+
if (bridge && capabilities.sampling) {
|
|
10525
|
+
client.setRequestHandler(
|
|
10526
|
+
CreateMessageRequestSchema,
|
|
10527
|
+
(request2, extra) => bridge.createMessage(request2.params, { signal: extra.signal })
|
|
10528
|
+
);
|
|
10529
|
+
}
|
|
10530
|
+
if (bridge && capabilities.roots) {
|
|
10531
|
+
client.setRequestHandler(
|
|
10532
|
+
ListRootsRequestSchema,
|
|
10533
|
+
(request2, extra) => bridge.listRoots(request2.params, { signal: extra.signal })
|
|
10534
|
+
);
|
|
10535
|
+
}
|
|
10921
10536
|
let transport;
|
|
10922
10537
|
let stderrRing = "";
|
|
10923
10538
|
let resolvedServerEnv = {};
|
|
@@ -10925,11 +10540,7 @@ async function connectToUpstreamOnce(config, onDisconnect, onListChanged, attemp
|
|
|
10925
10540
|
if (!config.command) {
|
|
10926
10541
|
throw new Error("command is required for local servers");
|
|
10927
10542
|
}
|
|
10928
|
-
const
|
|
10929
|
-
YAW_MCP_TOKEN: _excludedToken,
|
|
10930
|
-
YAW_MCP_VAULT_PASSPHRASE: _excludedVaultPassphrase,
|
|
10931
|
-
...parentEnv
|
|
10932
|
-
} = process.env;
|
|
10543
|
+
const parentEnv = stripInternalSecretsFromEnv(process.env);
|
|
10933
10544
|
let resolved;
|
|
10934
10545
|
try {
|
|
10935
10546
|
resolved = await resolveUvSpawn(config.command, config.args ?? []);
|
|
@@ -11010,7 +10621,8 @@ async function connectToUpstreamOnce(config, onDisconnect, onListChanged, attemp
|
|
|
11010
10621
|
} else if (trimmedStderr.length > 0) {
|
|
11011
10622
|
category = "install_failure";
|
|
11012
10623
|
const safe = redactSecretsInOutput(trimmedStderr, resolvedServerEnv);
|
|
11013
|
-
|
|
10624
|
+
const oomHint = oamHeapOomHint(trimmedStderr);
|
|
10625
|
+
message = oomHint ? `Server "${config.namespace}" ran out of memory. ${oomHint} stderr: ${safe.slice(-500)}` : `Server "${config.namespace}" failed to start. stderr: ${safe.slice(-500)}`;
|
|
11014
10626
|
} else {
|
|
11015
10627
|
category = categorizeSpawnError(err);
|
|
11016
10628
|
if (category === "spawn_failure") {
|
|
@@ -11124,10 +10736,23 @@ async function disconnectFromUpstream(connection) {
|
|
|
11124
10736
|
}
|
|
11125
10737
|
log("info", "Disconnected from upstream", { namespace: connection.config.namespace });
|
|
11126
10738
|
}
|
|
10739
|
+
async function fetchAllPages(fetchPage, cap) {
|
|
10740
|
+
const all = [];
|
|
10741
|
+
let cursor;
|
|
10742
|
+
for (let page = 0; page < cap; page++) {
|
|
10743
|
+
const { items, nextCursor } = await fetchPage(cursor);
|
|
10744
|
+
all.push(...items);
|
|
10745
|
+
if (nextCursor === void 0 || all.length > cap) break;
|
|
10746
|
+
cursor = nextCursor;
|
|
10747
|
+
}
|
|
10748
|
+
return all;
|
|
10749
|
+
}
|
|
11127
10750
|
async function fetchResourcesFromUpstream(client, namespace, opts = {}) {
|
|
11128
10751
|
try {
|
|
11129
|
-
const
|
|
11130
|
-
|
|
10752
|
+
const raw = await fetchAllPages(async (cursor) => {
|
|
10753
|
+
const result = await client.listResources(cursor === void 0 ? {} : { cursor }, { timeout: LIST_TIMEOUT });
|
|
10754
|
+
return { items: result.resources ?? [], nextCursor: result.nextCursor };
|
|
10755
|
+
}, MAX_RESOURCES_PER_SERVER);
|
|
11131
10756
|
if (raw.length > MAX_RESOURCES_PER_SERVER) {
|
|
11132
10757
|
log("warn", "Upstream returned more resources than cap; truncating", {
|
|
11133
10758
|
namespace,
|
|
@@ -11150,8 +10775,10 @@ async function fetchResourcesFromUpstream(client, namespace, opts = {}) {
|
|
|
11150
10775
|
}
|
|
11151
10776
|
async function fetchPromptsFromUpstream(client, namespace, opts = {}) {
|
|
11152
10777
|
try {
|
|
11153
|
-
const
|
|
11154
|
-
|
|
10778
|
+
const raw = await fetchAllPages(async (cursor) => {
|
|
10779
|
+
const result = await client.listPrompts(cursor === void 0 ? {} : { cursor }, { timeout: LIST_TIMEOUT });
|
|
10780
|
+
return { items: result.prompts ?? [], nextCursor: result.nextCursor };
|
|
10781
|
+
}, MAX_PROMPTS_PER_SERVER);
|
|
11155
10782
|
if (raw.length > MAX_PROMPTS_PER_SERVER) {
|
|
11156
10783
|
log("warn", "Upstream returned more prompts than cap; truncating", {
|
|
11157
10784
|
namespace,
|
|
@@ -11172,9 +10799,12 @@ async function fetchPromptsFromUpstream(client, namespace, opts = {}) {
|
|
|
11172
10799
|
}
|
|
11173
10800
|
}
|
|
11174
10801
|
async function fetchToolsFromUpstream(client, namespace) {
|
|
11175
|
-
let
|
|
10802
|
+
let all;
|
|
11176
10803
|
try {
|
|
11177
|
-
|
|
10804
|
+
all = await fetchAllPages(async (cursor) => {
|
|
10805
|
+
const result = await client.listTools(cursor === void 0 ? {} : { cursor }, { timeout: LIST_TIMEOUT });
|
|
10806
|
+
return { items: result.tools ?? [], nextCursor: result.nextCursor };
|
|
10807
|
+
}, MAX_TOOLS_PER_SERVER);
|
|
11178
10808
|
} catch (err) {
|
|
11179
10809
|
const message = err instanceof Error ? err.message : String(err);
|
|
11180
10810
|
throw new ActivationError(
|
|
@@ -11184,7 +10814,13 @@ async function fetchToolsFromUpstream(client, namespace) {
|
|
|
11184
10814
|
err
|
|
11185
10815
|
);
|
|
11186
10816
|
}
|
|
11187
|
-
const raw =
|
|
10817
|
+
const raw = all.filter((tool) => tool.execution?.taskSupport !== "required");
|
|
10818
|
+
if (raw.length < all.length) {
|
|
10819
|
+
log("warn", "Withholding tools that require task-based execution (unsupported through the proxy)", {
|
|
10820
|
+
namespace,
|
|
10821
|
+
tools: all.filter((tool) => tool.execution?.taskSupport === "required").map((tool) => tool.name)
|
|
10822
|
+
});
|
|
10823
|
+
}
|
|
11188
10824
|
if (raw.length > MAX_TOOLS_PER_SERVER) {
|
|
11189
10825
|
log("warn", "Upstream returned more tools than cap; truncating", {
|
|
11190
10826
|
namespace,
|
|
@@ -11195,9 +10831,15 @@ async function fetchToolsFromUpstream(client, namespace) {
|
|
|
11195
10831
|
return raw.slice(0, MAX_TOOLS_PER_SERVER).map((tool) => ({
|
|
11196
10832
|
name: tool.name,
|
|
11197
10833
|
namespacedName: `${namespace}_${tool.name}`,
|
|
10834
|
+
title: tool.title,
|
|
11198
10835
|
description: tool.description,
|
|
11199
10836
|
inputSchema: tool.inputSchema,
|
|
11200
|
-
|
|
10837
|
+
outputSchema: tool.outputSchema,
|
|
10838
|
+
annotations: tool.annotations,
|
|
10839
|
+
// `execution` is deliberately NOT carried: the proxy always calls
|
|
10840
|
+
// upstream in plain (non-task) mode, so advertising task support
|
|
10841
|
+
// downstream would be a false claim.
|
|
10842
|
+
_meta: tool._meta
|
|
11201
10843
|
}));
|
|
11202
10844
|
}
|
|
11203
10845
|
|
|
@@ -11213,7 +10855,7 @@ function complianceRefusalReason(grade, min) {
|
|
|
11213
10855
|
return `compliance grade ${grade ?? "unknown"} is below YAW_MCP_MIN_COMPLIANCE=${min}`;
|
|
11214
10856
|
}
|
|
11215
10857
|
function isAutoLoadEnabled() {
|
|
11216
|
-
const raw = process.env.YAW_MCP_AUTO_LOAD;
|
|
10858
|
+
const raw = process.env.YAW_MCP_AUTO_LOAD?.trim();
|
|
11217
10859
|
if (raw === void 0 || raw === "") return false;
|
|
11218
10860
|
return raw === "1" || raw.toLowerCase() === "true";
|
|
11219
10861
|
}
|
|
@@ -11233,7 +10875,7 @@ function resolveIdleThreshold() {
|
|
|
11233
10875
|
return Number.isFinite(n) && n >= 1 ? n : DEFAULT_IDLE_CALL_THRESHOLD;
|
|
11234
10876
|
}
|
|
11235
10877
|
function isAutoActivateEnabled() {
|
|
11236
|
-
const raw = process.env.YAW_MCP_AUTO_ACTIVATE;
|
|
10878
|
+
const raw = process.env.YAW_MCP_AUTO_ACTIVATE?.trim();
|
|
11237
10879
|
if (raw === void 0 || raw === "") return true;
|
|
11238
10880
|
return raw === "1" || raw.toLowerCase() === "true";
|
|
11239
10881
|
}
|
|
@@ -11275,12 +10917,12 @@ function argsEqual(a, b) {
|
|
|
11275
10917
|
return a.every((v, i) => v === b[i]);
|
|
11276
10918
|
}
|
|
11277
10919
|
function settledWithin(p, ms) {
|
|
11278
|
-
return new Promise((
|
|
11279
|
-
const timer = setTimeout(() =>
|
|
10920
|
+
return new Promise((resolve7) => {
|
|
10921
|
+
const timer = setTimeout(() => resolve7(false), ms);
|
|
11280
10922
|
if (typeof timer.unref === "function") timer.unref();
|
|
11281
10923
|
const done = () => {
|
|
11282
10924
|
clearTimeout(timer);
|
|
11283
|
-
|
|
10925
|
+
resolve7(true);
|
|
11284
10926
|
};
|
|
11285
10927
|
p.then(done, done);
|
|
11286
10928
|
});
|
|
@@ -11317,6 +10959,7 @@ function computeToolOverlaps(connections) {
|
|
|
11317
10959
|
}
|
|
11318
10960
|
var ConnectServer = class _ConnectServer {
|
|
11319
10961
|
server;
|
|
10962
|
+
clientBridge;
|
|
11320
10963
|
connections = /* @__PURE__ */ new Map();
|
|
11321
10964
|
config = null;
|
|
11322
10965
|
configVersion = null;
|
|
@@ -11370,7 +11013,7 @@ var ConnectServer = class _ConnectServer {
|
|
|
11370
11013
|
// real process values; overridable so tests can point the scan at a
|
|
11371
11014
|
// synthetic home + stubbed env without touching the developer's real
|
|
11372
11015
|
// shell history or ~/.yaw-mcp/ state file.
|
|
11373
|
-
nudgeHome =
|
|
11016
|
+
nudgeHome = homedir18();
|
|
11374
11017
|
nudgeEnv = process.env;
|
|
11375
11018
|
// Loaded YAW-MCP.md guides (user-global + project-local). Null until
|
|
11376
11019
|
// start() has run the loader; fail-open if either file is missing,
|
|
@@ -11484,7 +11127,7 @@ var ConnectServer = class _ConnectServer {
|
|
|
11484
11127
|
static SHUTDOWN_DRAIN_MS = 2e3;
|
|
11485
11128
|
constructor() {
|
|
11486
11129
|
this.server = new Server(
|
|
11487
|
-
{ name: "yaw-mcp", version: true ? "0.
|
|
11130
|
+
{ name: "yaw-mcp", version: true ? "0.76.0" : "dev" },
|
|
11488
11131
|
{
|
|
11489
11132
|
capabilities: {
|
|
11490
11133
|
tools: { listChanged: true },
|
|
@@ -11493,6 +11136,12 @@ var ConnectServer = class _ConnectServer {
|
|
|
11493
11136
|
}
|
|
11494
11137
|
}
|
|
11495
11138
|
);
|
|
11139
|
+
this.clientBridge = {
|
|
11140
|
+
getClientCapabilities: () => this.server.getClientCapabilities(),
|
|
11141
|
+
elicitInput: (params, options) => this.server.elicitInput(params, options),
|
|
11142
|
+
createMessage: (params, options) => this.server.createMessage(params, options),
|
|
11143
|
+
listRoots: (params, options) => this.server.listRoots(params, options)
|
|
11144
|
+
};
|
|
11496
11145
|
this.setupHandlers();
|
|
11497
11146
|
}
|
|
11498
11147
|
// Builtin resources served directly by yaw-mcp (not proxied from an
|
|
@@ -11544,6 +11193,9 @@ var ConnectServer = class _ConnectServer {
|
|
|
11544
11193
|
this.sessionActivated
|
|
11545
11194
|
)
|
|
11546
11195
|
}));
|
|
11196
|
+
this.server.setRequestHandler(ListResourceTemplatesRequestSchema, async () => ({
|
|
11197
|
+
resourceTemplates: []
|
|
11198
|
+
}));
|
|
11547
11199
|
this.server.setRequestHandler(ReadResourceRequestSchema, async (request2) => {
|
|
11548
11200
|
return routeResourceRead(request2.params.uri, this.resourceRoutes, this.connections, this.getBuiltinResourceMap());
|
|
11549
11201
|
});
|
|
@@ -11591,10 +11243,17 @@ var ConnectServer = class _ConnectServer {
|
|
|
11591
11243
|
// Active servers, narrowed by the project profile if one is loaded.
|
|
11592
11244
|
// Centralizing this here means discover/dispatch/auto-warm all see the
|
|
11593
11245
|
// same set — no accidental bypass of the profile via a second code path.
|
|
11246
|
+
// The merge in mergeToolCache feeds the in-memory toolCache (hydrated
|
|
11247
|
+
// from state.json at startup, updated as servers activate) into each
|
|
11248
|
+
// server so callers like formatShadowLine can see learned tools.
|
|
11249
|
+
// bundles.json doesn't carry toolCache (validateEntry's fixed whitelist
|
|
11250
|
+
// drops it), and without this merge the tool-prefix heuristic in
|
|
11251
|
+
// resolveShadowedClis is inert on a real run — see the KNOWN_CLI_PREFIXES
|
|
11252
|
+
// comment in cli-shadows.ts.
|
|
11594
11253
|
getProfiledActiveServers() {
|
|
11595
11254
|
const all = (this.config?.servers ?? []).filter((s) => s.isActive);
|
|
11596
|
-
|
|
11597
|
-
return
|
|
11255
|
+
const profiled = this.profile ? all.filter((s) => profileAllows(this.profile, s.namespace)) : all;
|
|
11256
|
+
return profiled.map((server) => this.mergeToolCache(server));
|
|
11598
11257
|
}
|
|
11599
11258
|
// Configured-but-not-currently-connected servers that have a persisted
|
|
11600
11259
|
// toolCache. Fed into buildToolList/buildToolRoutes so the LLM can see
|
|
@@ -11607,13 +11266,34 @@ var ConnectServer = class _ConnectServer {
|
|
|
11607
11266
|
const out = [];
|
|
11608
11267
|
for (const server of this.getProfiledActiveServers()) {
|
|
11609
11268
|
if (this.connections.has(server.namespace)) continue;
|
|
11610
|
-
|
|
11611
|
-
|
|
11612
|
-
if (!cache || cache.length === 0) continue;
|
|
11613
|
-
out.push(cache === server.toolCache ? server : { ...server, toolCache: cache });
|
|
11269
|
+
if (!server.toolCache || server.toolCache.length === 0) continue;
|
|
11270
|
+
out.push(server);
|
|
11614
11271
|
}
|
|
11615
11272
|
return out;
|
|
11616
11273
|
}
|
|
11274
|
+
// Return `server` with its in-memory toolCache applied. The in-memory
|
|
11275
|
+
// entry (this.toolCache) wins over server.toolCache when both exist —
|
|
11276
|
+
// the persisted copy can be stale relative to a fresh activation, and
|
|
11277
|
+
// the in-memory map is what tools/list and formatShadowLine should
|
|
11278
|
+
// actually see.
|
|
11279
|
+
//
|
|
11280
|
+
// Identity preservation: when both sides resolve to the same array
|
|
11281
|
+
// reference — which in practice means BOTH are undefined (server.ts
|
|
11282
|
+
// has no toolCache and this.toolCache has no entry for this namespace)
|
|
11283
|
+
// — we return `server` unchanged. The `===` guard pins that, so
|
|
11284
|
+
// downstream consumers keyed on reference equality (the identity-
|
|
11285
|
+
// preservation tests in server.test.ts) keep working. In production,
|
|
11286
|
+
// server.toolCache is almost always undefined: bundles.json validation
|
|
11287
|
+
// drops the field (local-bundles.ts), and hydrateToolCache (below)
|
|
11288
|
+
// writes the persisted array into this.toolCache rather than back into
|
|
11289
|
+
// server.toolCache. So the commonly-fired path is the
|
|
11290
|
+
// "spread a clone" branch — the identity guard mostly catches the
|
|
11291
|
+
// dormant-namespace case.
|
|
11292
|
+
mergeToolCache(server) {
|
|
11293
|
+
const sessionCache = this.toolCache.get(server.namespace);
|
|
11294
|
+
const cache = sessionCache && sessionCache.length > 0 ? sessionCache : server.toolCache;
|
|
11295
|
+
return cache === server.toolCache ? server : { ...server, toolCache: cache };
|
|
11296
|
+
}
|
|
11617
11297
|
// Does this server's tool list already exist somewhere we trust — the
|
|
11618
11298
|
// toolCache shipped in bundles.json, or the one we learned in a previous
|
|
11619
11299
|
// session and hydrated from state.json? Gates pre-warm: a `false` here
|
|
@@ -11623,6 +11303,30 @@ var ConnectServer = class _ConnectServer {
|
|
|
11623
11303
|
const cached = this.toolCache.get(server.namespace);
|
|
11624
11304
|
return cached !== void 0 && cached.length > 0;
|
|
11625
11305
|
}
|
|
11306
|
+
// How long a LEARNED tool list stays trusted before the next pre-warm
|
|
11307
|
+
// re-spawns the server to refresh it. Installs resolve at @latest, so an
|
|
11308
|
+
// upstream that renames or removes a tool would otherwise keep discover's
|
|
11309
|
+
// "known tools:" line, the BM25 corpus, and the deferred routes pointing
|
|
11310
|
+
// at dead names for the full persistence TTL (TOOLCACHE_TTL_MS, 30 days)
|
|
11311
|
+
// -- the only recovery being the "no longer available after loading"
|
|
11312
|
+
// error on a live call. A weekly re-learn bounds that drift at one extra
|
|
11313
|
+
// spawn per server per week.
|
|
11314
|
+
static TOOLCACHE_REFRESH_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
11315
|
+
// 7 days
|
|
11316
|
+
// True when the list hasKnownTools trusts came from a PREVIOUS session's
|
|
11317
|
+
// learning and is old enough to re-verify. Scoped to learned entries on
|
|
11318
|
+
// purpose: a toolCache shipped in bundles.json is curated, carries no
|
|
11319
|
+
// learnedAt, and is never refreshed here -- refreshing it every session
|
|
11320
|
+
// is exactly the per-session `npx -y <pkg>@latest` resolve pre-warm
|
|
11321
|
+
// exists to avoid. runActivateOne stamps a fresh learnedAt on every
|
|
11322
|
+
// activation, so a server in actual use never looks stale.
|
|
11323
|
+
isLearnedCacheStale(namespace) {
|
|
11324
|
+
const cached = this.toolCache.get(namespace);
|
|
11325
|
+
if (cached === void 0 || cached.length === 0) return false;
|
|
11326
|
+
const learnedAt = this.toolCacheLearnedAt.get(namespace);
|
|
11327
|
+
if (learnedAt === void 0) return false;
|
|
11328
|
+
return Date.now() - learnedAt > _ConnectServer.TOOLCACHE_REFRESH_MS;
|
|
11329
|
+
}
|
|
11626
11330
|
// Seed the in-memory tool cache from the persisted snapshot. Runs before
|
|
11627
11331
|
// reconcileConfig so the first tools/list of the session can already
|
|
11628
11332
|
// include deferred servers' tools. Entries for namespaces no longer in
|
|
@@ -11661,7 +11365,7 @@ var ConnectServer = class _ConnectServer {
|
|
|
11661
11365
|
//
|
|
11662
11366
|
// `home` is a parameter rather than a field so tests can point it at a
|
|
11663
11367
|
// synthetic ~/.yaw-mcp without running the whole of start().
|
|
11664
|
-
async hydrateComplianceGrades(home =
|
|
11368
|
+
async hydrateComplianceGrades(home = homedir18()) {
|
|
11665
11369
|
if (!this.config) return;
|
|
11666
11370
|
const grades = await readGradesCache(home).catch(() => ({}));
|
|
11667
11371
|
if (Object.keys(grades).length === 0) return;
|
|
@@ -11812,9 +11516,13 @@ var ConnectServer = class _ConnectServer {
|
|
|
11812
11516
|
// the one hydrated from state.json — so this is a one-time cost per
|
|
11813
11517
|
// server rather than a per-session `npx -y <pkg>@latest` resolve for
|
|
11814
11518
|
// every active server (which is what it degenerated into while the
|
|
11815
|
-
// learned cache had nowhere to persist).
|
|
11519
|
+
// learned cache had nowhere to persist). A learned list past
|
|
11520
|
+
// TOOLCACHE_REFRESH_MS counts as dormant again so @latest drift gets
|
|
11521
|
+
// re-learned weekly instead of only at the 30-day persistence expiry.
|
|
11816
11522
|
async prewarmDormantServers() {
|
|
11817
|
-
const dormant = this.getProfiledActiveServers().filter(
|
|
11523
|
+
const dormant = this.getProfiledActiveServers().filter(
|
|
11524
|
+
(s) => !this.hasKnownTools(s) || this.isLearnedCacheStale(s.namespace)
|
|
11525
|
+
);
|
|
11818
11526
|
if (dormant.length === 0) return;
|
|
11819
11527
|
log("info", "Pre-warming dormant servers", {
|
|
11820
11528
|
count: dormant.length,
|
|
@@ -11877,17 +11585,8 @@ var ConnectServer = class _ConnectServer {
|
|
|
11877
11585
|
if (!this.guides.user && !this.guides.project) return result;
|
|
11878
11586
|
this.guideNudgeFired = true;
|
|
11879
11587
|
const sources = [this.guides.user?.path, this.guides.project?.path].filter(Boolean).join(", ");
|
|
11880
|
-
const text = `
|
|
11881
|
-
|
|
11882
|
-
[yaw-mcp] Tip: read the \`yaw-mcp://guide\` resource for project-specific routing & credential guidance (from ${sources}). This hint appears once per session.`;
|
|
11883
|
-
const content = [...result.content];
|
|
11884
|
-
const last = content[content.length - 1];
|
|
11885
|
-
if (last && last.type === "text") {
|
|
11886
|
-
content[content.length - 1] = { ...last, text: `${last.text}${text}` };
|
|
11887
|
-
} else {
|
|
11888
|
-
content.push({ type: "text", text: text.trimStart() });
|
|
11889
|
-
}
|
|
11890
|
-
return { ...result, content };
|
|
11588
|
+
const text = `[yaw-mcp] Tip: read the \`yaw-mcp://guide\` resource for project-specific routing & credential guidance (from ${sources}). This hint appears once per session.`;
|
|
11589
|
+
return { ...result, content: [...result.content, { type: "text", text }] };
|
|
11891
11590
|
}
|
|
11892
11591
|
async handleToolCall(name, args, extra, opts) {
|
|
11893
11592
|
const progress = createProgressReporter(extra);
|
|
@@ -11986,7 +11685,8 @@ var ConnectServer = class _ConnectServer {
|
|
|
11986
11685
|
const newConn = await connectToUpstream(
|
|
11987
11686
|
reconnectConfig,
|
|
11988
11687
|
this.onUpstreamDisconnect,
|
|
11989
|
-
this.onUpstreamListChanged
|
|
11688
|
+
this.onUpstreamListChanged,
|
|
11689
|
+
this.clientBridge
|
|
11990
11690
|
);
|
|
11991
11691
|
this.connections.set(ns, newConn);
|
|
11992
11692
|
await this.refreshRoutesAndNotify();
|
|
@@ -12180,6 +11880,7 @@ var ConnectServer = class _ConnectServer {
|
|
|
12180
11880
|
progress?.(`Auto-warming top candidate "${top.namespace}"`);
|
|
12181
11881
|
const result = await this.activateOne(top.namespace, progress);
|
|
12182
11882
|
if (result.ok) {
|
|
11883
|
+
this.sessionActivated.add(top.namespace);
|
|
12183
11884
|
await this.refreshRoutesAndNotify();
|
|
12184
11885
|
log("info", "Auto-warmed top-ranked server on discover", { namespace: top.namespace, score: top.score });
|
|
12185
11886
|
}
|
|
@@ -12552,7 +12253,8 @@ ${activeCount} loaded in this session, ${totalTools} tools in context${tokenSumm
|
|
|
12552
12253
|
const connection = await connectToUpstream(
|
|
12553
12254
|
effectiveConfig,
|
|
12554
12255
|
this.onUpstreamDisconnect,
|
|
12555
|
-
this.onUpstreamListChanged
|
|
12256
|
+
this.onUpstreamListChanged,
|
|
12257
|
+
this.clientBridge
|
|
12556
12258
|
);
|
|
12557
12259
|
progress?.(`"${namespace}" loaded ${connection.tools.length} tools`);
|
|
12558
12260
|
this.connections.set(namespace, connection);
|
|
@@ -12850,6 +12552,7 @@ ${activeCount} loaded in this session, ${totalTools} tools in context${tokenSumm
|
|
|
12850
12552
|
const r = await this.activateOne(winner.namespace, progress);
|
|
12851
12553
|
results.push(`${winner.namespace} (score ${winner.score.toFixed(2)}): ${r.message}`);
|
|
12852
12554
|
if (r.isChanged) anyChanged = true;
|
|
12555
|
+
if (r.ok) this.sessionActivated.add(winner.namespace);
|
|
12853
12556
|
if (!r.ok) {
|
|
12854
12557
|
if (r.capped) anyCapped = true;
|
|
12855
12558
|
else anyError = true;
|
|
@@ -13063,7 +12766,7 @@ ${activeCount} loaded in this session, ${totalTools} tools in context${tokenSumm
|
|
|
13063
12766
|
try {
|
|
13064
12767
|
const elicitedForTransient = this.elicitedEnv.get(serverArg);
|
|
13065
12768
|
const transientConfig = elicitedForTransient ? { ...serverConfig, env: { ...serverConfig.env, ...elicitedForTransient } } : serverConfig;
|
|
13066
|
-
transient = await connectToUpstream(transientConfig);
|
|
12769
|
+
transient = await connectToUpstream(transientConfig, void 0, void 0, this.clientBridge);
|
|
13067
12770
|
} catch (err) {
|
|
13068
12771
|
const message = err instanceof ActivationError ? err.message : err instanceof Error ? err.message : String(err);
|
|
13069
12772
|
return {
|
|
@@ -13821,6 +13524,22 @@ if (subcommand === "compliance") {
|
|
|
13821
13524
|
stale global installs are upgraded in the
|
|
13822
13525
|
background -- npm, pnpm, and bun globals alike).
|
|
13823
13526
|
YAW_MCP_PRUNE_RESPONSES Set to \`0\` to disable response pruning.
|
|
13527
|
+
YAW_MCP_TOOL_EXPOSURE How much of the catalog tools/list advertises.
|
|
13528
|
+
\`gateway\` (default) exposes the meta-tools
|
|
13529
|
+
plus loaded servers only; \`full\` restores the
|
|
13530
|
+
pre-gateway behavior and inlines the whole
|
|
13531
|
+
catalog. Re-read per call -- a change lands on
|
|
13532
|
+
the next tools/list without a restart.
|
|
13533
|
+
YAW_MCP_ROUTE_EFFORT How hard dispatch tries to break ranking ties
|
|
13534
|
+
with the client LLM: \`off\` | \`auto\` |
|
|
13535
|
+
\`aggressive\` (default auto). The dispatch
|
|
13536
|
+
tool's \`routeEffort\` argument overrides this
|
|
13537
|
+
per call.
|
|
13538
|
+
YAW_MCP_REWARD_GRADER Set to \`1\` to OPT IN to the LLM reward
|
|
13539
|
+
grader: uncertain dispatch outcomes get a
|
|
13540
|
+
second opinion via client sampling. It spends
|
|
13541
|
+
the client's LLM budget and adds a round-trip,
|
|
13542
|
+
so it is off by default.
|
|
13824
13543
|
YAW_MCP_IDLE_THRESHOLD Non-matching tool calls a loaded server
|
|
13825
13544
|
tolerates before it is unloaded (default 10).
|
|
13826
13545
|
Bursty servers earn more patience on top of
|
|
@@ -13869,6 +13588,9 @@ if (subcommand === "compliance") {
|
|
|
13869
13588
|
only -- a server's own \`connectTimeoutMs\` in
|
|
13870
13589
|
bundles.json always wins, so one slow server does
|
|
13871
13590
|
not need the global ceiling raised.
|
|
13591
|
+
MCP_LIST_TIMEOUT Milliseconds to wait for a server's tool/
|
|
13592
|
+
resource/prompt inventory calls after the
|
|
13593
|
+
handshake (default 15000).
|
|
13872
13594
|
|
|
13873
13595
|
Config resolution (highest precedence first) -- for the \`servers\` allow-list
|
|
13874
13596
|
and \`blocked\` deny-list:
|
|
@@ -13890,7 +13612,7 @@ if (subcommand === "compliance") {
|
|
|
13890
13612
|
`);
|
|
13891
13613
|
process.exitCode = 0;
|
|
13892
13614
|
} else if (subcommand === "--version" || subcommand === "-V") {
|
|
13893
|
-
process.stdout.write(`yaw-mcp ${true ? "0.
|
|
13615
|
+
process.stdout.write(`yaw-mcp ${true ? "0.76.0" : "dev"}
|
|
13894
13616
|
`);
|
|
13895
13617
|
process.exitCode = 0;
|
|
13896
13618
|
} else if (subcommand && !subcommand.startsWith("-")) {
|