@yawlabs/mcp 0.73.0 → 0.73.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +147 -413
- package/dist/index.js +218 -107
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -523,7 +523,7 @@ async function doUpsertUserBundle(entry, opts) {
|
|
|
523
523
|
else file.servers.push(entry);
|
|
524
524
|
file.version = file.version ?? CURRENT_BUNDLES_SCHEMA_VERSION;
|
|
525
525
|
await atomicWriteFile(path7, `${JSON.stringify(file, null, 2)}
|
|
526
|
-
`, "utf8", 384);
|
|
526
|
+
`, "utf8", 384, 448);
|
|
527
527
|
if (process.platform !== "win32") {
|
|
528
528
|
try {
|
|
529
529
|
await chmod2(path7, 384);
|
|
@@ -550,7 +550,7 @@ async function doRemoveUserBundle(namespace, opts) {
|
|
|
550
550
|
if (file.servers.length === before) return { path: path7, removed: false };
|
|
551
551
|
file.version = file.version ?? CURRENT_BUNDLES_SCHEMA_VERSION;
|
|
552
552
|
await atomicWriteFile(path7, `${JSON.stringify(file, null, 2)}
|
|
553
|
-
`, "utf8", 384);
|
|
553
|
+
`, "utf8", 384, 448);
|
|
554
554
|
if (process.platform !== "win32") {
|
|
555
555
|
try {
|
|
556
556
|
await chmod2(path7, 384);
|
|
@@ -940,6 +940,18 @@ var CONFIG_FILENAME = "config.json";
|
|
|
940
940
|
var LOCAL_CONFIG_FILENAME = "config.local.json";
|
|
941
941
|
var CURRENT_SCHEMA_VERSION = 1;
|
|
942
942
|
var DEFAULT_API_BASE = "https://yaw.sh/mcp";
|
|
943
|
+
function filterStringArray(raw, field, path7, warnings) {
|
|
944
|
+
if (!Array.isArray(raw)) return void 0;
|
|
945
|
+
const strings = raw.filter((v) => typeof v === "string");
|
|
946
|
+
const dropped = raw.length - strings.length;
|
|
947
|
+
if (dropped > 0) {
|
|
948
|
+
warnings.push(
|
|
949
|
+
`${path7}: '${field}' dropped ${dropped} non-string ${dropped === 1 ? "entry" : "entries"} -- only string namespaces are honored.`
|
|
950
|
+
);
|
|
951
|
+
}
|
|
952
|
+
if (strings.length === 0 && raw.length > 0) return void 0;
|
|
953
|
+
return strings;
|
|
954
|
+
}
|
|
943
955
|
async function readConfigAt(path7, scope, warnings) {
|
|
944
956
|
let raw;
|
|
945
957
|
try {
|
|
@@ -979,16 +991,17 @@ async function readConfigAt(path7, scope, warnings) {
|
|
|
979
991
|
apiBase = void 0;
|
|
980
992
|
}
|
|
981
993
|
}
|
|
982
|
-
const servers =
|
|
983
|
-
const blocked =
|
|
994
|
+
const servers = filterStringArray(obj.servers, "servers", path7, warnings);
|
|
995
|
+
const blocked = filterStringArray(obj.blocked, "blocked", path7, warnings);
|
|
984
996
|
const installNudge = typeof obj.installNudge === "boolean" ? obj.installNudge : void 0;
|
|
985
997
|
if (token5) {
|
|
986
998
|
if (scope === "project") {
|
|
987
999
|
warnings.push(
|
|
988
1000
|
`${path7}: 'token' found in a project-shared config file is IGNORED -- yaw-mcp never reads a token from this scope to avoid committing credentials. Move it to ${CONFIG_DIRNAME}/${LOCAL_CONFIG_FILENAME} (machine-local, gitignore by convention) or ~/${CONFIG_DIRNAME}/${CONFIG_FILENAME} (user-global).`
|
|
989
1001
|
);
|
|
1002
|
+
} else {
|
|
1003
|
+
await checkPermissions(path7, warnings);
|
|
990
1004
|
}
|
|
991
|
-
await checkPermissions(path7, warnings);
|
|
992
1005
|
}
|
|
993
1006
|
return { path: path7, scope, version, token: token5, apiBase, servers, blocked, installNudge };
|
|
994
1007
|
}
|
|
@@ -1527,7 +1540,12 @@ var SUBCOMMAND_SPEC = [
|
|
|
1527
1540
|
flags: ["--value", "--stdin", "--force", "--secret", "--server", "--json", "--help"]
|
|
1528
1541
|
},
|
|
1529
1542
|
// Other.
|
|
1530
|
-
{
|
|
1543
|
+
{
|
|
1544
|
+
name: "audit",
|
|
1545
|
+
description: "Grade a stdio server against the compliance suite",
|
|
1546
|
+
positional: [["<namespace>"]],
|
|
1547
|
+
flags: ["--json", "--help"]
|
|
1548
|
+
},
|
|
1531
1549
|
{ name: "compliance", description: "Run the compliance suite against a server", flags: ["--publish", "--help"] },
|
|
1532
1550
|
{
|
|
1533
1551
|
name: "foundry",
|
|
@@ -2248,6 +2266,7 @@ async function shutdownAnalytics() {
|
|
|
2248
2266
|
for (let i = 0; i < 3 && dispatchBuffer.length > 0; i++) {
|
|
2249
2267
|
await flushDispatch();
|
|
2250
2268
|
}
|
|
2269
|
+
droppedEvents += buffer.length + dispatchBuffer.length;
|
|
2251
2270
|
buffer.length = 0;
|
|
2252
2271
|
dispatchBuffer.length = 0;
|
|
2253
2272
|
}
|
|
@@ -2478,6 +2497,7 @@ function rewriteForOam(command, args, deps) {
|
|
|
2478
2497
|
if (command === "node") {
|
|
2479
2498
|
const [entry, ...rest] = args;
|
|
2480
2499
|
if (!entry) return { command, args };
|
|
2500
|
+
if (entry.startsWith("-")) return { command, args };
|
|
2481
2501
|
return toOam(entry, rest);
|
|
2482
2502
|
}
|
|
2483
2503
|
if (command === "npx") {
|
|
@@ -3216,20 +3236,22 @@ ${USAGE}`);
|
|
|
3216
3236
|
const writeYawMcpConfig = !opts.skipYawMcpConfig && token5 !== null;
|
|
3217
3237
|
const home = opts.home ?? homedir7();
|
|
3218
3238
|
const yawMcpConfigPath = join8(home, CONFIG_DIRNAME, CONFIG_FILENAME);
|
|
3219
|
-
const yawMcpConfigComposed = writeYawMcpConfig ? await composeYawMcpConfig(yawMcpConfigPath, token5) : { json: "" };
|
|
3239
|
+
const yawMcpConfigComposed = writeYawMcpConfig ? await composeYawMcpConfig(yawMcpConfigPath, token5, opts.dryRun ?? false) : { json: "" };
|
|
3220
3240
|
if ("backupPath" in yawMcpConfigComposed && yawMcpConfigComposed.backupPath) {
|
|
3221
3241
|
const reason = yawMcpConfigComposed.backupReason;
|
|
3242
|
+
const backedUp = opts.dryRun ? "would be backed up" : "backed up";
|
|
3243
|
+
const preserved = opts.dryRun ? "would be preserved" : "preserved";
|
|
3222
3244
|
if (reason === "malformed") {
|
|
3223
3245
|
log2(
|
|
3224
|
-
`yaw-mcp install: existing ${yawMcpConfigPath} was malformed;
|
|
3246
|
+
`yaw-mcp install: existing ${yawMcpConfigPath} was malformed; ${backedUp} to ${yawMcpConfigComposed.backupPath} before overwriting (original bytes ${preserved} for recovery).`
|
|
3225
3247
|
);
|
|
3226
3248
|
} else if (reason === "token-rotation") {
|
|
3227
3249
|
log2(
|
|
3228
|
-
`yaw-mcp install: existing ${yawMcpConfigPath}
|
|
3250
|
+
`yaw-mcp install: existing ${yawMcpConfigPath} ${backedUp} before token rotation to ${yawMcpConfigComposed.backupPath} (previous token ${preserved} for recovery).`
|
|
3229
3251
|
);
|
|
3230
3252
|
} else {
|
|
3231
3253
|
log2(
|
|
3232
|
-
`yaw-mcp install: existing ${yawMcpConfigPath} was not a JSON object;
|
|
3254
|
+
`yaw-mcp install: existing ${yawMcpConfigPath} was not a JSON object; ${backedUp} to ${yawMcpConfigComposed.backupPath} before overwriting (original bytes ${preserved} for recovery).`
|
|
3233
3255
|
);
|
|
3234
3256
|
}
|
|
3235
3257
|
}
|
|
@@ -3241,6 +3263,11 @@ ${USAGE}`);
|
|
|
3241
3263
|
os,
|
|
3242
3264
|
claudeConfigDir: opts.claudeConfigDir
|
|
3243
3265
|
}) : null;
|
|
3266
|
+
if (settingsPatch?.malformed) {
|
|
3267
|
+
err(
|
|
3268
|
+
`yaw-mcp install: warning \u2014 could not patch ${settingsPatch.path} (${settingsPatch.malformedReason}); left unchanged. Add "${CLAUDE_CODE_ALLOW_PATTERN}" to permissions.allow by hand, or you may be re-prompted for each yaw-mcp tool call.`
|
|
3269
|
+
);
|
|
3270
|
+
}
|
|
3244
3271
|
if (opts.dryRun) {
|
|
3245
3272
|
log2("\n--- dry run: would write the following ---");
|
|
3246
3273
|
if (writeYawMcpConfig) log2(`# ${yawMcpConfigPath}
|
|
@@ -3324,11 +3351,11 @@ async function prepareClaudeCodeSettingsPatch(opts) {
|
|
|
3324
3351
|
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
3325
3352
|
existing = parsed;
|
|
3326
3353
|
} else {
|
|
3327
|
-
return { path: path7, nextJson: "", changed: false };
|
|
3354
|
+
return { path: path7, nextJson: "", changed: false, malformed: true, malformedReason: "not a JSON object" };
|
|
3328
3355
|
}
|
|
3329
3356
|
}
|
|
3330
|
-
} catch {
|
|
3331
|
-
return { path: path7, nextJson: "", changed: false };
|
|
3357
|
+
} catch (e) {
|
|
3358
|
+
return { path: path7, nextJson: "", changed: false, malformed: true, malformedReason: e.message };
|
|
3332
3359
|
}
|
|
3333
3360
|
}
|
|
3334
3361
|
const merged = mergePermissionsAllow(existing, [CLAUDE_CODE_ALLOW_PATTERN]);
|
|
@@ -3396,8 +3423,9 @@ function mergeClientConfig(existing, containerPath, entry, entryName = ENTRY_NAM
|
|
|
3396
3423
|
parent[leafKey] = container;
|
|
3397
3424
|
return out;
|
|
3398
3425
|
}
|
|
3399
|
-
async function writeBackup(path7, raw) {
|
|
3426
|
+
async function writeBackup(path7, raw, dryRun = false) {
|
|
3400
3427
|
const candidate = `${path7}.bak-${Date.now()}`;
|
|
3428
|
+
if (dryRun) return candidate;
|
|
3401
3429
|
try {
|
|
3402
3430
|
await atomicWriteFile(candidate, raw, "utf8", 384);
|
|
3403
3431
|
if (process.platform !== "win32") {
|
|
@@ -3411,7 +3439,7 @@ async function writeBackup(path7, raw) {
|
|
|
3411
3439
|
return void 0;
|
|
3412
3440
|
}
|
|
3413
3441
|
}
|
|
3414
|
-
async function composeYawMcpConfig(path7, token5) {
|
|
3442
|
+
async function composeYawMcpConfig(path7, token5, dryRun = false) {
|
|
3415
3443
|
let existing = {};
|
|
3416
3444
|
let backupPath;
|
|
3417
3445
|
let backupReason;
|
|
@@ -3429,15 +3457,15 @@ async function composeYawMcpConfig(path7, token5) {
|
|
|
3429
3457
|
existing = parsed;
|
|
3430
3458
|
const existingToken = existing.token;
|
|
3431
3459
|
if (typeof existingToken === "string" && existingToken.length > 0 && existingToken !== token5) {
|
|
3432
|
-
backupPath = await writeBackup(path7, raw);
|
|
3460
|
+
backupPath = await writeBackup(path7, raw, dryRun);
|
|
3433
3461
|
if (backupPath) backupReason = "token-rotation";
|
|
3434
3462
|
}
|
|
3435
3463
|
} else {
|
|
3436
|
-
backupPath = await writeBackup(path7, raw);
|
|
3464
|
+
backupPath = await writeBackup(path7, raw, dryRun);
|
|
3437
3465
|
if (backupPath) backupReason = "non-object";
|
|
3438
3466
|
}
|
|
3439
3467
|
} catch {
|
|
3440
|
-
backupPath = await writeBackup(path7, raw);
|
|
3468
|
+
backupPath = await writeBackup(path7, raw, dryRun);
|
|
3441
3469
|
if (backupPath) backupReason = "malformed";
|
|
3442
3470
|
}
|
|
3443
3471
|
}
|
|
@@ -3475,13 +3503,13 @@ function parseInstallArgs(argv) {
|
|
|
3475
3503
|
}
|
|
3476
3504
|
case "--token": {
|
|
3477
3505
|
const v = next();
|
|
3478
|
-
if (!v) return { ok: false, error: "--token requires a value" };
|
|
3506
|
+
if (!v || v.startsWith("--")) return { ok: false, error: "--token requires a value" };
|
|
3479
3507
|
opts.token = v;
|
|
3480
3508
|
break;
|
|
3481
3509
|
}
|
|
3482
3510
|
case "--project-dir": {
|
|
3483
3511
|
const v = next();
|
|
3484
|
-
if (!v) return { ok: false, error: "--project-dir requires a value" };
|
|
3512
|
+
if (!v || v.startsWith("--")) return { ok: false, error: "--project-dir requires a value" };
|
|
3485
3513
|
opts.projectDir = v;
|
|
3486
3514
|
break;
|
|
3487
3515
|
}
|
|
@@ -3729,8 +3757,11 @@ function parseTryArgs(argv) {
|
|
|
3729
3757
|
switch (a) {
|
|
3730
3758
|
case "--client": {
|
|
3731
3759
|
const v = next();
|
|
3732
|
-
if (!v || !
|
|
3733
|
-
return {
|
|
3760
|
+
if (!v || !INSTALL_TARGETS.some((t) => t.clientId === v)) {
|
|
3761
|
+
return {
|
|
3762
|
+
ok: false,
|
|
3763
|
+
error: `--client requires ${INSTALL_TARGETS.map((t) => t.clientId).join("|")}`
|
|
3764
|
+
};
|
|
3734
3765
|
}
|
|
3735
3766
|
opts.clientId = v;
|
|
3736
3767
|
break;
|
|
@@ -3902,7 +3933,7 @@ async function autoDetectClient(opts) {
|
|
|
3902
3933
|
for (const p of probes) {
|
|
3903
3934
|
if (!p.unavailable) return p.clientId;
|
|
3904
3935
|
}
|
|
3905
|
-
|
|
3936
|
+
throw new Error("autoDetectClient: no available install client for this OS");
|
|
3906
3937
|
}
|
|
3907
3938
|
async function runTry(opts) {
|
|
3908
3939
|
const out = opts.out ?? ((s) => process.stdout.write(s));
|
|
@@ -4055,10 +4086,12 @@ async function runTry(opts) {
|
|
|
4055
4086
|
printErr(`yaw-mcp try: failed to write trial marker: ${e.message}`);
|
|
4056
4087
|
return { exitCode: 1, written: [] };
|
|
4057
4088
|
}
|
|
4089
|
+
const entryHasSecrets = entry.env !== void 0 && Object.keys(entry.env).length > 0;
|
|
4090
|
+
const tightenPerms = entryHasSecrets && process.platform !== "win32";
|
|
4058
4091
|
try {
|
|
4059
|
-
await atomicWriteFile(resolved.absolute, clientJson);
|
|
4092
|
+
await atomicWriteFile(resolved.absolute, clientJson, "utf8", tightenPerms ? 384 : void 0);
|
|
4060
4093
|
written.push(resolved.absolute);
|
|
4061
|
-
if (
|
|
4094
|
+
if (tightenPerms) {
|
|
4062
4095
|
try {
|
|
4063
4096
|
await chmod4(resolved.absolute, 384);
|
|
4064
4097
|
} catch {
|
|
@@ -4199,7 +4232,7 @@ async function gcExpiredTrials(opts) {
|
|
|
4199
4232
|
const env = opts.env ?? process.env;
|
|
4200
4233
|
const baseUrl = opts.baseUrl ?? env.YAW_MCP_BASE_URL ?? DEFAULT_BASE_URL;
|
|
4201
4234
|
const postEvent = opts.postEvent ?? defaultPostEvent;
|
|
4202
|
-
const scan = await scanTrials({ home, now: opts.now });
|
|
4235
|
+
const scan = opts.scan ?? await scanTrials({ home, now: opts.now });
|
|
4203
4236
|
if (scan.expired.length === 0) return { cleared: 0, failed: 0 };
|
|
4204
4237
|
const anonId = await loadOrCreateAnonId(home);
|
|
4205
4238
|
let cleared = 0;
|
|
@@ -4550,7 +4583,7 @@ async function runUpgrade(opts = {}) {
|
|
|
4550
4583
|
return { exitCode: 3, lines };
|
|
4551
4584
|
}
|
|
4552
4585
|
function readCurrentVersion() {
|
|
4553
|
-
return true ? "0.73.
|
|
4586
|
+
return true ? "0.73.1" : "dev";
|
|
4554
4587
|
}
|
|
4555
4588
|
|
|
4556
4589
|
// src/learning.ts
|
|
@@ -4577,7 +4610,7 @@ var LearningStore = class {
|
|
|
4577
4610
|
recordSuccess(namespace) {
|
|
4578
4611
|
const prev = this.usage.get(namespace);
|
|
4579
4612
|
this.usage.set(namespace, {
|
|
4580
|
-
dispatched: prev?.dispatched ??
|
|
4613
|
+
dispatched: prev?.dispatched ?? 0,
|
|
4581
4614
|
succeeded: (prev?.succeeded ?? 0) + 1,
|
|
4582
4615
|
lastUsedAt: Date.now()
|
|
4583
4616
|
});
|
|
@@ -4752,7 +4785,7 @@ function selectFlakyNamespaces(entries, limit) {
|
|
|
4752
4785
|
}
|
|
4753
4786
|
|
|
4754
4787
|
// src/doctor-cmd.ts
|
|
4755
|
-
var VERSION = true ? "0.73.
|
|
4788
|
+
var VERSION = true ? "0.73.1" : "dev";
|
|
4756
4789
|
function isPersistenceDisabled(env) {
|
|
4757
4790
|
const raw = env.YAW_MCP_DISABLE_PERSISTENCE;
|
|
4758
4791
|
return raw !== void 0 && raw !== "" && (raw === "1" || raw.toLowerCase() === "true");
|
|
@@ -4971,11 +5004,14 @@ async function runDoctorJson(opts) {
|
|
|
4971
5004
|
}
|
|
4972
5005
|
}
|
|
4973
5006
|
const shellShadows = scanShellHistoryForShadows({ home, env });
|
|
4974
|
-
const trialGc = await gcExpiredTrials({ home, env, postEvent: opts.postTryEvent, now: opts.now }).catch(() => ({
|
|
4975
|
-
cleared: 0,
|
|
4976
|
-
failed: 0
|
|
4977
|
-
}));
|
|
4978
5007
|
const trialScan = await scanTrials({ home, now: opts.now });
|
|
5008
|
+
const trialGc = await gcExpiredTrials({
|
|
5009
|
+
home,
|
|
5010
|
+
env,
|
|
5011
|
+
postEvent: opts.postTryEvent,
|
|
5012
|
+
now: opts.now,
|
|
5013
|
+
scan: trialScan
|
|
5014
|
+
}).catch(() => ({ cleared: 0, failed: 0 }));
|
|
4979
5015
|
const trials = {
|
|
4980
5016
|
cleared: trialGc.cleared,
|
|
4981
5017
|
live: trialScan.live.map(({ marker, msUntilExpiry }) => ({
|
|
@@ -5196,8 +5232,8 @@ function renderReliabilitySection(opts) {
|
|
|
5196
5232
|
}
|
|
5197
5233
|
async function renderTrialsSection(opts) {
|
|
5198
5234
|
const { home, env, print, postEvent, now } = opts;
|
|
5199
|
-
const gc = await gcExpiredTrials({ home, env, postEvent, now }).catch(() => ({ cleared: 0, failed: 0 }));
|
|
5200
5235
|
const scan = await scanTrials({ home, now });
|
|
5236
|
+
const gc = await gcExpiredTrials({ home, env, postEvent, now, scan }).catch(() => ({ cleared: 0, failed: 0 }));
|
|
5201
5237
|
if (scan.live.length === 0 && gc.cleared === 0 && scan.malformed.length === 0) return;
|
|
5202
5238
|
print("TRIALS (yaw-mcp try)");
|
|
5203
5239
|
if (gc.cleared > 0) {
|
|
@@ -6298,7 +6334,7 @@ import { homedir as homedir16 } from "os";
|
|
|
6298
6334
|
|
|
6299
6335
|
// src/secrets-audit.ts
|
|
6300
6336
|
import { existsSync as existsSync7 } from "fs";
|
|
6301
|
-
import { appendFile as appendFile2, chmod as chmod5, readFile as readFile9, stat as stat5
|
|
6337
|
+
import { appendFile as appendFile2, chmod as chmod5, readFile as readFile9, stat as stat5 } from "fs/promises";
|
|
6302
6338
|
import { homedir as homedir14 } from "os";
|
|
6303
6339
|
import { join as join12 } from "path";
|
|
6304
6340
|
var SECRETS_AUDIT_FILENAME = "secrets-audit.log";
|
|
@@ -6318,7 +6354,7 @@ async function appendAuditEvent(input, home = homedir14()) {
|
|
|
6318
6354
|
const line = `${JSON.stringify(event)}
|
|
6319
6355
|
`;
|
|
6320
6356
|
if (!existsSync7(path7)) {
|
|
6321
|
-
await atomicWriteFile(path7, line);
|
|
6357
|
+
await atomicWriteFile(path7, line, "utf8", 384, 448);
|
|
6322
6358
|
} else {
|
|
6323
6359
|
await appendFile2(path7, line, "utf8");
|
|
6324
6360
|
}
|
|
@@ -6337,8 +6373,8 @@ async function trimToTailCap(path7) {
|
|
|
6337
6373
|
const lines = raw.split("\n").filter((l) => l.length > 0);
|
|
6338
6374
|
if (lines.length <= AUDIT_TAIL_CAP) return;
|
|
6339
6375
|
const kept = lines.slice(lines.length - AUDIT_TAIL_CAP);
|
|
6340
|
-
await
|
|
6341
|
-
`, "utf8");
|
|
6376
|
+
await atomicWriteFile(path7, `${kept.join("\n")}
|
|
6377
|
+
`, "utf8", 384);
|
|
6342
6378
|
}
|
|
6343
6379
|
async function readAuditLog(filter = {}, home = homedir14()) {
|
|
6344
6380
|
const path7 = auditLogPath(home);
|
|
@@ -6466,6 +6502,14 @@ async function loadVault(path7) {
|
|
|
6466
6502
|
if (typeof obj.salt !== "string" || !obj.entries || typeof obj.entries !== "object") {
|
|
6467
6503
|
throw new Error(`vault at ${path7} is corrupt: missing or invalid salt/entries`);
|
|
6468
6504
|
}
|
|
6505
|
+
if (Buffer.from(obj.salt, "base64").length !== SALT_LEN) {
|
|
6506
|
+
throw new Error(`vault at ${path7} is corrupt: salt (expected ${SALT_LEN} bytes)`);
|
|
6507
|
+
}
|
|
6508
|
+
if (typeof obj.version === "number" && obj.version > SECRETS_SCHEMA_VERSION) {
|
|
6509
|
+
throw new Error(
|
|
6510
|
+
`vault at ${path7} was written by a newer yaw-mcp (schema version ${obj.version} > ${SECRETS_SCHEMA_VERSION}); upgrade yaw-mcp to read it`
|
|
6511
|
+
);
|
|
6512
|
+
}
|
|
6469
6513
|
const entries = obj.entries;
|
|
6470
6514
|
for (const [name, entry] of Object.entries(entries)) {
|
|
6471
6515
|
if (!isEncryptedEntry(entry)) {
|
|
@@ -6858,7 +6902,7 @@ async function promptYesNo(opts, question) {
|
|
|
6858
6902
|
const a = answer.trim().toLowerCase();
|
|
6859
6903
|
return a === "y" || a === "yes";
|
|
6860
6904
|
}
|
|
6861
|
-
async function resolvePassphrase(opts) {
|
|
6905
|
+
async function resolvePassphrase(opts, confirm = false) {
|
|
6862
6906
|
if (opts.passphrase !== void 0) return opts.passphrase.length > 0 ? opts.passphrase : null;
|
|
6863
6907
|
const fromEnv = process.env.YAW_MCP_VAULT_PASSPHRASE;
|
|
6864
6908
|
if (typeof fromEnv === "string" && fromEnv.length > 0) {
|
|
@@ -6874,6 +6918,21 @@ async function resolvePassphrase(opts) {
|
|
|
6874
6918
|
const stdin = opts.io?.stdin ?? process.stdin;
|
|
6875
6919
|
const stdout = opts.io?.stdout ?? process.stdout;
|
|
6876
6920
|
if (!isInteractiveTTY(opts)) return null;
|
|
6921
|
+
if (confirm) {
|
|
6922
|
+
for (let attempt = 0; attempt < MAX_PASSPHRASE_PROMPTS; attempt++) {
|
|
6923
|
+
const first = await readLineFromTTY(stdin, stdout, "Vault passphrase: ");
|
|
6924
|
+
if (first === CANCELLED) return CANCELLED;
|
|
6925
|
+
if (first.length === 0) {
|
|
6926
|
+
stdout.write("Passphrase cannot be empty.\n");
|
|
6927
|
+
continue;
|
|
6928
|
+
}
|
|
6929
|
+
const second = await readLineFromTTY(stdin, stdout, "Confirm passphrase: ");
|
|
6930
|
+
if (second === CANCELLED) return CANCELLED;
|
|
6931
|
+
if (first === second) return first;
|
|
6932
|
+
stdout.write("Passphrases did not match. Try again.\n");
|
|
6933
|
+
}
|
|
6934
|
+
return null;
|
|
6935
|
+
}
|
|
6877
6936
|
for (let attempt = 0; attempt < MAX_PASSPHRASE_PROMPTS; attempt++) {
|
|
6878
6937
|
const entered = await readLineFromTTY(stdin, stdout);
|
|
6879
6938
|
if (entered === CANCELLED) return CANCELLED;
|
|
@@ -7057,7 +7116,8 @@ async function runSecrets(opts, io = {
|
|
|
7057
7116
|
}
|
|
7058
7117
|
let vault = loaded.vault ?? newVault();
|
|
7059
7118
|
const isFresh = !existsSync8(path7);
|
|
7060
|
-
const
|
|
7119
|
+
const creatingVault = opts.action === "set" && !vault.check && Object.keys(vault.entries).length === 0;
|
|
7120
|
+
const passphrase = await resolvePassphrase(opts, creatingVault);
|
|
7061
7121
|
if (passphrase === CANCELLED) return cancelledResult(io, opts.json);
|
|
7062
7122
|
if (passphrase === null) {
|
|
7063
7123
|
const msg = "Passphrase required. Set YAW_MCP_VAULT_PASSPHRASE or run from a TTY so we can prompt.";
|
|
@@ -7397,7 +7457,7 @@ function defaultSpawn2(cmd, args) {
|
|
|
7397
7457
|
async function maybeAutoUpgrade(deps = {}) {
|
|
7398
7458
|
const optOut = process.env.YAW_MCP_AUTO_UPGRADE;
|
|
7399
7459
|
if (optOut === "0" || optOut?.toLowerCase() === "false") return;
|
|
7400
|
-
const current = deps.currentVersion ?? (true ? "0.73.
|
|
7460
|
+
const current = deps.currentVersion ?? (true ? "0.73.1" : "dev");
|
|
7401
7461
|
if (current === "dev") return;
|
|
7402
7462
|
const method = (deps.isSeaImpl ? await deps.isSeaImpl() : await detectSea()) ? "binary" : detectInstallMethod(deps.argvPath ?? process.argv[1]);
|
|
7403
7463
|
const latest = await (deps.fetchLatestImpl ?? fetchLatestVersion2)();
|
|
@@ -7627,7 +7687,7 @@ function classifyError(text) {
|
|
|
7627
7687
|
if (RX_HTTP_429.test(t) || t.includes("rate limit") || t.includes("too many requests")) {
|
|
7628
7688
|
return "rate_limited";
|
|
7629
7689
|
}
|
|
7630
|
-
if (RX_HTTP_401.test(t) || RX_HTTP_403.test(t) || t.includes("unauthorized") || t.includes("forbidden") || t.includes("permission denied") || RX_NO_TOKEN.test(
|
|
7690
|
+
if (RX_HTTP_401.test(t) || RX_HTTP_403.test(t) || t.includes("unauthorized") || t.includes("forbidden") || t.includes("permission denied") || RX_NO_TOKEN.test(t)) {
|
|
7631
7691
|
return "unauthorized";
|
|
7632
7692
|
}
|
|
7633
7693
|
if (RX_HTTP_404.test(t) || t.includes("not found")) {
|
|
@@ -7985,6 +8045,7 @@ function renderActiveServersSection(activeServers) {
|
|
|
7985
8045
|
var ACTIVATION_FAILURE_TTL_MS = 5 * 60 * 1e3;
|
|
7986
8046
|
var OBSERVATION_FLOOR = 3;
|
|
7987
8047
|
var MIN_FACTOR = 0.5;
|
|
8048
|
+
var WARN_RATE_FLOOR = 0.1;
|
|
7988
8049
|
function errorRateFactor(health) {
|
|
7989
8050
|
if (!health) return 1;
|
|
7990
8051
|
if (health.totalCalls < OBSERVATION_FLOOR) return 1;
|
|
@@ -8008,7 +8069,7 @@ function formatHealthWarning(health, activationFailure, now = Date.now()) {
|
|
|
8008
8069
|
}
|
|
8009
8070
|
if (health && health.totalCalls >= OBSERVATION_FLOOR) {
|
|
8010
8071
|
const rate = health.errorCount / health.totalCalls;
|
|
8011
|
-
if (rate >=
|
|
8072
|
+
if (rate >= WARN_RATE_FLOOR) {
|
|
8012
8073
|
const lastErr = health.lastErrorMessage ? `: ${truncateForWarning(health.lastErrorMessage)}` : "";
|
|
8013
8074
|
return `warn: ${health.errorCount} of last ${health.totalCalls} calls failed${lastErr}`;
|
|
8014
8075
|
}
|
|
@@ -9908,8 +9969,10 @@ async function extractArchive(archivePath, destDir) {
|
|
|
9908
9969
|
["archivePath", archivePath],
|
|
9909
9970
|
["destDir", destDir]
|
|
9910
9971
|
]) {
|
|
9911
|
-
if (/[
|
|
9912
|
-
throw new Error(
|
|
9972
|
+
if (/[\r\n‘’‚‛]/.test(p)) {
|
|
9973
|
+
throw new Error(
|
|
9974
|
+
`Refusing to extract uv archive: ${label} contains a newline or smart quote (${JSON.stringify(p)})`
|
|
9975
|
+
);
|
|
9913
9976
|
}
|
|
9914
9977
|
}
|
|
9915
9978
|
await runCommand("powershell.exe", [
|
|
@@ -10107,7 +10170,10 @@ var ActivationError = class extends Error {
|
|
|
10107
10170
|
};
|
|
10108
10171
|
function redactSecretsInOutput(text, env) {
|
|
10109
10172
|
let out = text;
|
|
10110
|
-
|
|
10173
|
+
const entries = Object.entries(env).sort(
|
|
10174
|
+
([, a], [, b]) => (typeof b === "string" ? b.length : 0) - (typeof a === "string" ? a.length : 0)
|
|
10175
|
+
);
|
|
10176
|
+
for (const [k, v] of entries) {
|
|
10111
10177
|
if (typeof v !== "string" || v.length < 8) continue;
|
|
10112
10178
|
if (v.startsWith("${secret:") && v.endsWith("}")) continue;
|
|
10113
10179
|
const escaped = v.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -10141,7 +10207,7 @@ async function connectToUpstream(config, onDisconnect, onListChanged) {
|
|
|
10141
10207
|
}
|
|
10142
10208
|
async function connectToUpstreamOnce(config, onDisconnect, onListChanged, attempt, disableOamRewrite) {
|
|
10143
10209
|
const client = new Client(
|
|
10144
|
-
{ name: "yaw-mcp", version: true ? "0.73.
|
|
10210
|
+
{ name: "yaw-mcp", version: true ? "0.73.1" : "dev" },
|
|
10145
10211
|
{ capabilities: {} }
|
|
10146
10212
|
);
|
|
10147
10213
|
let transport;
|
|
@@ -10246,17 +10312,23 @@ async function connectToUpstreamOnce(config, onDisconnect, onListChanged, attemp
|
|
|
10246
10312
|
});
|
|
10247
10313
|
try {
|
|
10248
10314
|
const connection = { status: "disconnected" };
|
|
10315
|
+
let closedBeforeReady = false;
|
|
10249
10316
|
client.onclose = () => {
|
|
10250
10317
|
if (connection.status === "connected") {
|
|
10251
10318
|
connection.status = "error";
|
|
10252
10319
|
connection.error = "Upstream disconnected unexpectedly";
|
|
10253
10320
|
log("warn", "Upstream disconnected unexpectedly", { namespace: config.namespace });
|
|
10254
10321
|
if (onDisconnect) onDisconnect(config.namespace);
|
|
10322
|
+
} else {
|
|
10323
|
+
closedBeforeReady = true;
|
|
10255
10324
|
}
|
|
10256
10325
|
};
|
|
10257
10326
|
const tools = await fetchToolsFromUpstream(client, config.namespace);
|
|
10258
10327
|
const resources = await fetchResourcesFromUpstream(client, config.namespace);
|
|
10259
10328
|
const prompts = await fetchPromptsFromUpstream(client, config.namespace);
|
|
10329
|
+
if (closedBeforeReady) {
|
|
10330
|
+
throw new ActivationError(`Server "${config.namespace}" disconnected during initialization`, "protocol_error");
|
|
10331
|
+
}
|
|
10260
10332
|
Object.assign(connection, {
|
|
10261
10333
|
config,
|
|
10262
10334
|
client,
|
|
@@ -10425,6 +10497,13 @@ function isPersistenceDisabled2() {
|
|
|
10425
10497
|
function resolveMinCompliance() {
|
|
10426
10498
|
return parseMinCompliance(process.env.YAW_MCP_MIN_COMPLIANCE);
|
|
10427
10499
|
}
|
|
10500
|
+
function complianceRefusalReason(grade, min) {
|
|
10501
|
+
const c = classifyGrade(grade);
|
|
10502
|
+
if (c.kind === "unrecognized") {
|
|
10503
|
+
return `unrecognized compliance grade "${c.raw}" (not A-F); failing closed under YAW_MCP_MIN_COMPLIANCE=${min}`;
|
|
10504
|
+
}
|
|
10505
|
+
return `compliance grade ${grade ?? "unknown"} is below YAW_MCP_MIN_COMPLIANCE=${min}`;
|
|
10506
|
+
}
|
|
10428
10507
|
function isAutoLoadEnabled() {
|
|
10429
10508
|
const raw = process.env.YAW_MCP_AUTO_LOAD;
|
|
10430
10509
|
if (raw === void 0 || raw === "") return false;
|
|
@@ -10449,8 +10528,9 @@ function isRoutingFaultText(text) {
|
|
|
10449
10528
|
return ROUTING_FAULT_MARKERS.some((marker) => text.includes(marker));
|
|
10450
10529
|
}
|
|
10451
10530
|
function resolveNamespaces(args) {
|
|
10452
|
-
if (Array.isArray(args.servers)
|
|
10453
|
-
|
|
10531
|
+
if (Array.isArray(args.servers)) {
|
|
10532
|
+
const filtered = args.servers.filter((s) => typeof s === "string" && s.length > 0);
|
|
10533
|
+
if (filtered.length > 0) return filtered;
|
|
10454
10534
|
}
|
|
10455
10535
|
if (typeof args.server === "string" && args.server) {
|
|
10456
10536
|
return [args.server];
|
|
@@ -10509,7 +10589,7 @@ var ConnectServer = class _ConnectServer {
|
|
|
10509
10589
|
this.apiUrl = apiUrl5;
|
|
10510
10590
|
this.token = token5;
|
|
10511
10591
|
this.server = new Server(
|
|
10512
|
-
{ name: "yaw-mcp", version: true ? "0.73.
|
|
10592
|
+
{ name: "yaw-mcp", version: true ? "0.73.1" : "dev" },
|
|
10513
10593
|
{
|
|
10514
10594
|
capabilities: {
|
|
10515
10595
|
tools: { listChanged: true },
|
|
@@ -10608,6 +10688,15 @@ var ConnectServer = class _ConnectServer {
|
|
|
10608
10688
|
// With this set: prewarm only disconnects when the namespace was NOT
|
|
10609
10689
|
// claimed by an explicit activate while P1 was in flight.
|
|
10610
10690
|
prewarmNamespaces = /* @__PURE__ */ new Set();
|
|
10691
|
+
// Slot reservations for the concurrent-server cap. A namespace is added
|
|
10692
|
+
// here synchronously (before the first `await connectToUpstream`) once it
|
|
10693
|
+
// clears the cap check, and removed when its activation settles. Counting
|
|
10694
|
+
// these pending reservations alongside connected servers closes a TOCTOU
|
|
10695
|
+
// gap: two DISTINCT namespaces activating concurrently would otherwise
|
|
10696
|
+
// both pass the cap check against the same connected set and overshoot
|
|
10697
|
+
// YAW_MCP_SERVER_CAP. Distinct from activationInflight (which dedupes
|
|
10698
|
+
// repeat activations of the SAME namespace) — this bounds the TOTAL count.
|
|
10699
|
+
pendingActivations = /* @__PURE__ */ new Set();
|
|
10611
10700
|
// Usage learning — nudges dispatch toward namespaces that have been
|
|
10612
10701
|
// genuinely useful. Counts persist across yaw-mcp restarts via state.json
|
|
10613
10702
|
// (see persistence.ts). YAW_MCP_DISABLE_PERSISTENCE=1 makes it session
|
|
@@ -11124,14 +11213,15 @@ var ConnectServer = class _ConnectServer {
|
|
|
11124
11213
|
let routes = this.toolRoutes;
|
|
11125
11214
|
let route = routes.get(name);
|
|
11126
11215
|
if (route?.deferred) {
|
|
11127
|
-
|
|
11128
|
-
|
|
11216
|
+
const deferredNs = route.namespace;
|
|
11217
|
+
progress?.(`Loading "${deferredNs}" on first tools/call\u2026`);
|
|
11218
|
+
const activation = await this.activateOne(deferredNs, progress);
|
|
11129
11219
|
if (!activation.ok) {
|
|
11130
11220
|
return {
|
|
11131
11221
|
content: [
|
|
11132
11222
|
{
|
|
11133
11223
|
type: "text",
|
|
11134
|
-
text: `Server "${
|
|
11224
|
+
text: `Server "${deferredNs}" could not be loaded on first call: ${activation.message}`
|
|
11135
11225
|
}
|
|
11136
11226
|
],
|
|
11137
11227
|
isError: true
|
|
@@ -11148,7 +11238,7 @@ var ConnectServer = class _ConnectServer {
|
|
|
11148
11238
|
content: [
|
|
11149
11239
|
{
|
|
11150
11240
|
type: "text",
|
|
11151
|
-
text: `Tool "${name}" is ${ROUTING_FAULT_TOOL_GONE} after loading "${
|
|
11241
|
+
text: `Tool "${name}" is ${ROUTING_FAULT_TOOL_GONE} after loading "${deferredNs}" \u2014 the upstream's tool set changed. Call mcp_connect_discover to list the current tools for that namespace.`
|
|
11152
11242
|
}
|
|
11153
11243
|
],
|
|
11154
11244
|
isError: true
|
|
@@ -11549,7 +11639,8 @@ var ConnectServer = class _ConnectServer {
|
|
|
11549
11639
|
let complianceLabel = "";
|
|
11550
11640
|
if (server.complianceGrade) {
|
|
11551
11641
|
if (minCompliance !== null && !passesMinCompliance(server.complianceGrade, minCompliance)) {
|
|
11552
|
-
|
|
11642
|
+
const label = classifyGrade(server.complianceGrade).kind === "unrecognized" ? `unrecognized, won't auto-activate` : `below YAW_MCP_MIN_COMPLIANCE=${minCompliance}, won't auto-activate`;
|
|
11643
|
+
complianceLabel = ` (grade ${server.complianceGrade} \u2014 ${label})`;
|
|
11553
11644
|
} else {
|
|
11554
11645
|
complianceLabel = ` [${server.complianceGrade}]`;
|
|
11555
11646
|
}
|
|
@@ -11738,10 +11829,26 @@ ${activeCount} loaded in this session, ${totalTools} tools in context${tokenSumm
|
|
|
11738
11829
|
message: `"${namespace}" is not allowed by the project profile at ${this.profile?.path}.`
|
|
11739
11830
|
};
|
|
11740
11831
|
}
|
|
11832
|
+
const minCompliance = resolveMinCompliance();
|
|
11833
|
+
if (minCompliance !== null && !passesMinCompliance(serverConfig.complianceGrade, minCompliance)) {
|
|
11834
|
+
return {
|
|
11835
|
+
ok: false,
|
|
11836
|
+
isChanged: false,
|
|
11837
|
+
message: `Refused to load "${namespace}": ${complianceRefusalReason(serverConfig.complianceGrade, minCompliance)}. Unset YAW_MCP_MIN_COMPLIANCE (or lower it) to override.`
|
|
11838
|
+
};
|
|
11839
|
+
}
|
|
11741
11840
|
const loadedSlots = [];
|
|
11841
|
+
const counted = /* @__PURE__ */ new Set();
|
|
11742
11842
|
for (const [ns, conn] of this.connections) {
|
|
11743
11843
|
if (conn.status === "connected") {
|
|
11744
11844
|
loadedSlots.push({ namespace: ns, idleCount: this.idleCallCounts.get(ns) ?? 0 });
|
|
11845
|
+
counted.add(ns);
|
|
11846
|
+
}
|
|
11847
|
+
}
|
|
11848
|
+
for (const ns of this.pendingActivations) {
|
|
11849
|
+
if (ns !== namespace && !counted.has(ns)) {
|
|
11850
|
+
loadedSlots.push({ namespace: ns, idleCount: this.idleCallCounts.get(ns) ?? 0 });
|
|
11851
|
+
counted.add(ns);
|
|
11745
11852
|
}
|
|
11746
11853
|
}
|
|
11747
11854
|
const capDecision = evaluateServerCap(namespace, loadedSlots, this.serverCap);
|
|
@@ -11753,58 +11860,63 @@ ${activeCount} loaded in this session, ${totalTools} tools in context${tokenSumm
|
|
|
11753
11860
|
message: capDecision.message ?? "Concurrent server cap reached."
|
|
11754
11861
|
};
|
|
11755
11862
|
}
|
|
11756
|
-
|
|
11757
|
-
|
|
11758
|
-
|
|
11759
|
-
|
|
11760
|
-
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
11764
|
-
|
|
11765
|
-
effectiveConfig,
|
|
11766
|
-
this.onUpstreamDisconnect,
|
|
11767
|
-
this.onUpstreamListChanged
|
|
11768
|
-
);
|
|
11769
|
-
progress?.(`"${namespace}" loaded ${connection.tools.length} tools`);
|
|
11770
|
-
this.connections.set(namespace, connection);
|
|
11771
|
-
this.idleCallCounts.set(namespace, 0);
|
|
11772
|
-
const toolMeta = connection.tools.map((t) => ({ name: t.name, description: t.description }));
|
|
11773
|
-
this.toolCache.set(namespace, toolMeta);
|
|
11774
|
-
if (toolMeta.length > 0) {
|
|
11775
|
-
reportTools(serverConfig.id, toolMeta).catch(
|
|
11776
|
-
(err) => log("warn", "reportTools failed", { namespace, error: err?.message })
|
|
11863
|
+
this.pendingActivations.add(namespace);
|
|
11864
|
+
try {
|
|
11865
|
+
const elicited = this.elicitedEnv.get(namespace);
|
|
11866
|
+
const effectiveConfig = elicited ? { ...serverConfig, env: { ...serverConfig.env, ...elicited } } : serverConfig;
|
|
11867
|
+
let lastError = null;
|
|
11868
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
11869
|
+
try {
|
|
11870
|
+
progress?.(
|
|
11871
|
+
attempt === 0 ? `Spawning "${namespace}" upstream\u2026` : `Retrying "${namespace}" (attempt ${attempt + 1})\u2026`
|
|
11777
11872
|
);
|
|
11778
|
-
|
|
11779
|
-
|
|
11780
|
-
|
|
11781
|
-
|
|
11782
|
-
|
|
11783
|
-
|
|
11784
|
-
|
|
11785
|
-
|
|
11786
|
-
|
|
11787
|
-
|
|
11788
|
-
|
|
11789
|
-
|
|
11790
|
-
|
|
11791
|
-
|
|
11792
|
-
|
|
11873
|
+
const connection = await connectToUpstream(
|
|
11874
|
+
effectiveConfig,
|
|
11875
|
+
this.onUpstreamDisconnect,
|
|
11876
|
+
this.onUpstreamListChanged
|
|
11877
|
+
);
|
|
11878
|
+
progress?.(`"${namespace}" loaded ${connection.tools.length} tools`);
|
|
11879
|
+
this.connections.set(namespace, connection);
|
|
11880
|
+
this.idleCallCounts.set(namespace, 0);
|
|
11881
|
+
const toolMeta = connection.tools.map((t) => ({ name: t.name, description: t.description }));
|
|
11882
|
+
this.toolCache.set(namespace, toolMeta);
|
|
11883
|
+
if (toolMeta.length > 0) {
|
|
11884
|
+
reportTools(serverConfig.id, toolMeta).catch(
|
|
11885
|
+
(err) => log("warn", "reportTools failed", { namespace, error: err?.message })
|
|
11886
|
+
);
|
|
11887
|
+
}
|
|
11888
|
+
const toolNames = connection.tools.map((t) => t.namespacedName).join(", ");
|
|
11889
|
+
this.activationFailures.delete(namespace);
|
|
11890
|
+
return {
|
|
11891
|
+
ok: true,
|
|
11892
|
+
isChanged: true,
|
|
11893
|
+
serverId: serverConfig.id,
|
|
11894
|
+
message: `Loaded "${namespace}" \u2014 ${connection.tools.length} tools: ${toolNames}`
|
|
11895
|
+
};
|
|
11896
|
+
} catch (err) {
|
|
11897
|
+
lastError = err;
|
|
11898
|
+
if (attempt === 0) {
|
|
11899
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
11900
|
+
log("warn", "Activation attempt failed, retrying", { namespace, error: msg });
|
|
11901
|
+
await new Promise((r) => setTimeout(r, 1e3 * 2 ** attempt));
|
|
11902
|
+
}
|
|
11793
11903
|
}
|
|
11794
11904
|
}
|
|
11905
|
+
const elicitedRetry = await this.maybeElicitAndRetry(namespace, lastError, progress);
|
|
11906
|
+
if (elicitedRetry) return elicitedRetry;
|
|
11907
|
+
log("error", "Failed to activate upstream", {
|
|
11908
|
+
namespace,
|
|
11909
|
+
error: lastError instanceof Error ? lastError.message : String(lastError)
|
|
11910
|
+
});
|
|
11911
|
+
this.activationFailures.set(namespace, {
|
|
11912
|
+
at: Date.now(),
|
|
11913
|
+
message: lastError instanceof Error ? lastError.message : String(lastError)
|
|
11914
|
+
});
|
|
11915
|
+
const message = lastError instanceof ActivationError ? `Failed to load "${namespace}": ${lastError.message}` : `Failed to load "${namespace}": ${lastError instanceof Error ? lastError.message : String(lastError)}`;
|
|
11916
|
+
return { ok: false, isChanged: false, message };
|
|
11917
|
+
} finally {
|
|
11918
|
+
this.pendingActivations.delete(namespace);
|
|
11795
11919
|
}
|
|
11796
|
-
const elicitedRetry = await this.maybeElicitAndRetry(namespace, lastError, progress);
|
|
11797
|
-
if (elicitedRetry) return elicitedRetry;
|
|
11798
|
-
log("error", "Failed to activate upstream", {
|
|
11799
|
-
namespace,
|
|
11800
|
-
error: lastError instanceof Error ? lastError.message : String(lastError)
|
|
11801
|
-
});
|
|
11802
|
-
this.activationFailures.set(namespace, {
|
|
11803
|
-
at: Date.now(),
|
|
11804
|
-
message: lastError instanceof Error ? lastError.message : String(lastError)
|
|
11805
|
-
});
|
|
11806
|
-
const message = lastError instanceof ActivationError ? `Failed to load "${namespace}": ${lastError.message}` : `Failed to load "${namespace}": ${lastError instanceof Error ? lastError.message : String(lastError)}`;
|
|
11807
|
-
return { ok: false, isChanged: false, message };
|
|
11808
11920
|
}
|
|
11809
11921
|
// If the activation error names a missing credential (e.g. "GITHUB_TOKEN
|
|
11810
11922
|
// is required") AND the client supports elicitation, ask the user for
|
|
@@ -11910,8 +12022,7 @@ ${activeCount} loaded in this session, ${totalTools} tools in context${tokenSumm
|
|
|
11910
12022
|
if (minCompliance !== null) {
|
|
11911
12023
|
const cfg = this.config?.servers.find((s) => s.namespace === namespace);
|
|
11912
12024
|
if (cfg && !passesMinCompliance(cfg.complianceGrade, minCompliance)) {
|
|
11913
|
-
const
|
|
11914
|
-
const message = `Refused to load "${namespace}": compliance grade ${grade} is below YAW_MCP_MIN_COMPLIANCE=${minCompliance}. Unset YAW_MCP_MIN_COMPLIANCE (or lower it) to override.`;
|
|
12025
|
+
const message = `Refused to load "${namespace}": ${complianceRefusalReason(cfg.complianceGrade, minCompliance)}. Unset YAW_MCP_MIN_COMPLIANCE (or lower it) to override.`;
|
|
11915
12026
|
results.push(message);
|
|
11916
12027
|
anyError = true;
|
|
11917
12028
|
continue;
|
|
@@ -12899,7 +13010,7 @@ To load the top pack in one step, call \`mcp_connect_activate\` with namespaces=
|
|
|
12899
13010
|
this.learning.recordOutcome(stepNs, 0.5);
|
|
12900
13011
|
for (const dep of deps) {
|
|
12901
13012
|
const depNs = stepNamespaces.get(dep);
|
|
12902
|
-
if (depNs) this.learning.
|
|
13013
|
+
if (depNs) this.learning.adjustSucceeded(depNs, -0.5);
|
|
12903
13014
|
}
|
|
12904
13015
|
} else {
|
|
12905
13016
|
this.learning.recordOutcome(stepNs, 0);
|
|
@@ -13526,7 +13637,7 @@ if (subcommand === "compliance") {
|
|
|
13526
13637
|
`);
|
|
13527
13638
|
process.exitCode = 0;
|
|
13528
13639
|
} else if (subcommand === "--version" || subcommand === "-V") {
|
|
13529
|
-
process.stdout.write(`yaw-mcp ${true ? "0.73.
|
|
13640
|
+
process.stdout.write(`yaw-mcp ${true ? "0.73.1" : "dev"}
|
|
13530
13641
|
`);
|
|
13531
13642
|
process.exitCode = 0;
|
|
13532
13643
|
} else if (subcommand && !subcommand.startsWith("-")) {
|