@yawlabs/mcp 0.73.2 → 0.74.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 +6 -0
- package/README.md +1 -1
- package/dist/index.js +260 -82
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -23,6 +23,12 @@ Only two hosted surfaces survive, and neither needs an account: the public serve
|
|
|
23
23
|
|
|
24
24
|
This breaks scripted use, and it breaks intermittently: a script removing an already-absent server still exits 0, so the cleanup path that worked yesterday fails the one time there was something to clean. Add `--force`. The gate exists because removal is less reversible than it looks -- env values stored on the entry go with it and `add` will not bring them back.
|
|
25
25
|
|
|
26
|
+
**Breaking -- Node 20 is the floor**
|
|
27
|
+
|
|
28
|
+
`engines` moves from `>=18.17` to `>=20`, and the build target moves from `node18` to `node20` to match. This is a correction, not a new requirement: `@yawlabs/mcp-compliance` is a direct production dependency and already required `node>=20`, so the package could not actually run on Node 18 while still advertising that it could. Node 18 is also past end of life.
|
|
29
|
+
|
|
30
|
+
The practical change is where it fails. `npm install` on Node 18 now refuses with `EBADENGINE` instead of installing a tree that breaks at runtime. `npx -y @yawlabs/mcp` is unaffected -- it pulls a recent Node on its own.
|
|
31
|
+
|
|
26
32
|
**Deprecated for one release -- still accepted, now warns**
|
|
27
33
|
|
|
28
34
|
- `--token` and `--no-yaw-mcp-config` on `yaw-mcp install`. Both are still fully parsed, so `install --all --token mcp_pat_...` keeps working and keeps exiting 0; the values are ignored.
|
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -54,6 +54,15 @@ async function mkdirpWithMode(dir, dirMode) {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
// src/json-key.ts
|
|
58
|
+
function setJsonKey(target, key, value) {
|
|
59
|
+
if (key === "__proto__") {
|
|
60
|
+
Object.defineProperty(target, key, { value, writable: true, enumerable: true, configurable: true });
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
target[key] = value;
|
|
64
|
+
}
|
|
65
|
+
|
|
57
66
|
// src/jsonc.ts
|
|
58
67
|
import { applyEdits, modify } from "jsonc-parser";
|
|
59
68
|
function stripJsoncComments(src) {
|
|
@@ -277,7 +286,7 @@ async function readGradesCache(home = homedir2()) {
|
|
|
277
286
|
const out = {};
|
|
278
287
|
for (const [ns, entry] of Object.entries(parsed)) {
|
|
279
288
|
const validated = validateEntry(entry);
|
|
280
|
-
if (validated) out
|
|
289
|
+
if (validated) setJsonKey(out, ns, validated);
|
|
281
290
|
}
|
|
282
291
|
return out;
|
|
283
292
|
}
|
|
@@ -396,11 +405,11 @@ async function readTrustStore(home = homedir3()) {
|
|
|
396
405
|
log("warn", "Dropping trust entry with a missing or malformed sha256", { path: path7, key });
|
|
397
406
|
continue;
|
|
398
407
|
}
|
|
399
|
-
entries
|
|
408
|
+
setJsonKey(entries, key, {
|
|
400
409
|
path: typeof v.path === "string" && v.path.length > 0 ? v.path : key,
|
|
401
410
|
sha256: v.sha256,
|
|
402
411
|
grantedAt: typeof v.grantedAt === "string" ? v.grantedAt : ""
|
|
403
|
-
};
|
|
412
|
+
});
|
|
404
413
|
}
|
|
405
414
|
return { version, entries, malformed: false, malformedReason: null, malformedKind: null, errorCode: null };
|
|
406
415
|
}
|
|
@@ -2173,7 +2182,7 @@ function formatShadowLine(server) {
|
|
|
2173
2182
|
}
|
|
2174
2183
|
|
|
2175
2184
|
// src/oam-spawn.ts
|
|
2176
|
-
import {
|
|
2185
|
+
import { spawn as spawn2 } from "child_process";
|
|
2177
2186
|
import { existsSync as existsSync3, readdirSync, readFileSync } from "fs";
|
|
2178
2187
|
import { isAbsolute as isAbsolute2, join as join6, sep } from "path";
|
|
2179
2188
|
import { fileURLToPath } from "url";
|
|
@@ -2204,27 +2213,128 @@ function compareVersions(a, b) {
|
|
|
2204
2213
|
function winNormalize(p, platform = process.platform) {
|
|
2205
2214
|
return platform === "win32" ? p.replace(/\//g, "\\") : p;
|
|
2206
2215
|
}
|
|
2207
|
-
|
|
2216
|
+
var OAM_PROBE_TIMEOUT_MS = 3e3;
|
|
2217
|
+
var OAM_PROBE_KILL_SIGNAL = "SIGKILL";
|
|
2218
|
+
var OAM_PROBE_MAX_OUTPUT = 8 * 1024;
|
|
2219
|
+
var VERSION_CARRY = 32;
|
|
2220
|
+
function createProbeCollector(max = OAM_PROBE_MAX_OUTPUT) {
|
|
2221
|
+
let head = "";
|
|
2222
|
+
let carry = "";
|
|
2223
|
+
let found = null;
|
|
2224
|
+
return {
|
|
2225
|
+
push(chunk) {
|
|
2226
|
+
if (found !== null) return;
|
|
2227
|
+
found = parseOamVersion(carry + chunk);
|
|
2228
|
+
carry = (carry + chunk).slice(-VERSION_CARRY);
|
|
2229
|
+
if (head.length >= max) return;
|
|
2230
|
+
head += chunk.slice(0, max - head.length);
|
|
2231
|
+
},
|
|
2232
|
+
/** The version if one appeared anywhere, else the capped head (which
|
|
2233
|
+
* parses to null either way, so the caller's contract is unchanged). */
|
|
2234
|
+
result() {
|
|
2235
|
+
return found ?? head;
|
|
2236
|
+
},
|
|
2237
|
+
/** Test hook: bytes actually retained. */
|
|
2238
|
+
retainedLength() {
|
|
2239
|
+
return head.length;
|
|
2240
|
+
}
|
|
2241
|
+
};
|
|
2242
|
+
}
|
|
2243
|
+
function spawnVersionProbe(bin) {
|
|
2244
|
+
return new Promise((resolve8, reject) => {
|
|
2245
|
+
let settled = false;
|
|
2246
|
+
let timer;
|
|
2247
|
+
const settle = (fn) => {
|
|
2248
|
+
if (settled) return;
|
|
2249
|
+
settled = true;
|
|
2250
|
+
if (timer) clearTimeout(timer);
|
|
2251
|
+
fn();
|
|
2252
|
+
};
|
|
2253
|
+
let child;
|
|
2254
|
+
try {
|
|
2255
|
+
child = spawn2(bin, ["--version"], {
|
|
2256
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
2257
|
+
windowsHide: process.platform === "win32"
|
|
2258
|
+
});
|
|
2259
|
+
} catch (err) {
|
|
2260
|
+
reject(err);
|
|
2261
|
+
return;
|
|
2262
|
+
}
|
|
2263
|
+
const collector = createProbeCollector();
|
|
2264
|
+
child.stdout?.setEncoding("utf8");
|
|
2265
|
+
child.stdout?.on("error", () => {
|
|
2266
|
+
});
|
|
2267
|
+
child.stdout?.on("data", (chunk) => collector.push(chunk));
|
|
2268
|
+
child.on("error", (err) => settle(() => reject(err)));
|
|
2269
|
+
child.on(
|
|
2270
|
+
"close",
|
|
2271
|
+
(code, signal) => settle(() => code === 0 ? resolve8(collector.result()) : reject(new Error(`oam exited ${code ?? signal}`)))
|
|
2272
|
+
);
|
|
2273
|
+
timer = setTimeout(() => {
|
|
2274
|
+
settle(() => {
|
|
2275
|
+
try {
|
|
2276
|
+
child.kill(OAM_PROBE_KILL_SIGNAL);
|
|
2277
|
+
} catch {
|
|
2278
|
+
}
|
|
2279
|
+
try {
|
|
2280
|
+
child.stdout?.destroy();
|
|
2281
|
+
child.unref();
|
|
2282
|
+
} catch {
|
|
2283
|
+
}
|
|
2284
|
+
const err = new Error(`oam --version exceeded ${OAM_PROBE_TIMEOUT_MS}ms`);
|
|
2285
|
+
err.code = "ETIMEDOUT";
|
|
2286
|
+
reject(err);
|
|
2287
|
+
});
|
|
2288
|
+
}, OAM_PROBE_TIMEOUT_MS);
|
|
2289
|
+
timer.unref?.();
|
|
2290
|
+
});
|
|
2291
|
+
}
|
|
2292
|
+
var oamProbeInFlight;
|
|
2293
|
+
var oamProbeGeneration = 0;
|
|
2294
|
+
async function probeOam(run = spawnVersionProbe) {
|
|
2295
|
+
if (oamProbeCache !== void 0) return oamProbeCache;
|
|
2296
|
+
if (oamProbeInFlight !== void 0) return oamProbeInFlight;
|
|
2297
|
+
const generation = oamProbeGeneration;
|
|
2298
|
+
oamProbeInFlight = probeOamUncached(run, generation).finally(() => {
|
|
2299
|
+
if (generation === oamProbeGeneration) oamProbeInFlight = void 0;
|
|
2300
|
+
});
|
|
2301
|
+
return oamProbeInFlight;
|
|
2302
|
+
}
|
|
2303
|
+
async function probeOamUncached(run, generation) {
|
|
2208
2304
|
if (oamProbeCache !== void 0) return oamProbeCache;
|
|
2209
2305
|
const bin = winNormalize(process.env.OAM_BIN || (process.platform === "win32" ? "oam.exe" : "oam"));
|
|
2306
|
+
const publish = (probe) => {
|
|
2307
|
+
if (generation === oamProbeGeneration) oamProbeCache = probe;
|
|
2308
|
+
return probe;
|
|
2309
|
+
};
|
|
2210
2310
|
try {
|
|
2211
|
-
const version = parseOamVersion(run(bin));
|
|
2311
|
+
const version = parseOamVersion(await run(bin));
|
|
2212
2312
|
if (version !== null && compareVersions(version, MIN_OAM_VERSION) < 0) {
|
|
2213
2313
|
log("warn", "oam is installed but below the minimum supported version; falling back to node", {
|
|
2214
2314
|
oamVersion: version,
|
|
2215
2315
|
minVersion: MIN_OAM_VERSION
|
|
2216
2316
|
});
|
|
2217
|
-
|
|
2218
|
-
} else {
|
|
2219
|
-
oamProbeCache = { bin, version, belowMin: false };
|
|
2317
|
+
return publish({ bin: null, version, belowMin: true });
|
|
2220
2318
|
}
|
|
2221
|
-
|
|
2222
|
-
|
|
2319
|
+
return publish({ bin, version, belowMin: false });
|
|
2320
|
+
} catch (err) {
|
|
2321
|
+
const code = err?.code;
|
|
2322
|
+
if (code === "ETIMEDOUT") {
|
|
2323
|
+
log("warn", "oam did not respond to --version in time; falling back to node for this process", {
|
|
2324
|
+
timeoutMs: OAM_PROBE_TIMEOUT_MS,
|
|
2325
|
+
bin
|
|
2326
|
+
});
|
|
2327
|
+
} else if (code !== "ENOENT") {
|
|
2328
|
+
log("warn", "oam --version failed; falling back to node for this process", {
|
|
2329
|
+
bin,
|
|
2330
|
+
error: err instanceof Error ? err.message : String(err)
|
|
2331
|
+
});
|
|
2332
|
+
}
|
|
2333
|
+
return publish({ bin: null, version: null, belowMin: false });
|
|
2223
2334
|
}
|
|
2224
|
-
return oamProbeCache;
|
|
2225
2335
|
}
|
|
2226
|
-
function oamBin() {
|
|
2227
|
-
return probeOam().bin;
|
|
2336
|
+
async function oamBin() {
|
|
2337
|
+
return (await probeOam()).bin;
|
|
2228
2338
|
}
|
|
2229
2339
|
function rewriteForOam(command, args, deps) {
|
|
2230
2340
|
const bin = deps.oamBin;
|
|
@@ -2317,9 +2427,9 @@ function resolveNpmEntry(pkg, fromUrl = import.meta.url) {
|
|
|
2317
2427
|
}
|
|
2318
2428
|
return null;
|
|
2319
2429
|
}
|
|
2320
|
-
function resolveOamSpawn(command, args) {
|
|
2430
|
+
async function resolveOamSpawn(command, args) {
|
|
2321
2431
|
return rewriteForOam(command, args, {
|
|
2322
|
-
oamBin: oamBin(),
|
|
2432
|
+
oamBin: await oamBin(),
|
|
2323
2433
|
resolveEntry: (pkg) => resolveNpmEntry(pkg)
|
|
2324
2434
|
});
|
|
2325
2435
|
}
|
|
@@ -2749,7 +2859,7 @@ function sanitizeLearning(input) {
|
|
|
2749
2859
|
if (typeof u.succeeded !== "number" || !Number.isFinite(u.succeeded) || u.succeeded < 0) continue;
|
|
2750
2860
|
if (typeof u.lastUsedAt !== "number" || !Number.isFinite(u.lastUsedAt) || u.lastUsedAt < 0) continue;
|
|
2751
2861
|
const succeeded = Math.min(u.succeeded, u.dispatched);
|
|
2752
|
-
out
|
|
2862
|
+
setJsonKey(out, k, { dispatched: u.dispatched, succeeded, lastUsedAt: u.lastUsedAt });
|
|
2753
2863
|
}
|
|
2754
2864
|
return out;
|
|
2755
2865
|
}
|
|
@@ -3947,7 +4057,7 @@ async function gcExpiredTrials(opts) {
|
|
|
3947
4057
|
}
|
|
3948
4058
|
|
|
3949
4059
|
// src/upgrade-cmd.ts
|
|
3950
|
-
import { spawn as
|
|
4060
|
+
import { spawn as spawn3 } from "child_process";
|
|
3951
4061
|
import { realpathSync } from "fs";
|
|
3952
4062
|
var BINARY_DOWNLOAD_URL = "https://github.com/YawLabs/mcp/releases/latest";
|
|
3953
4063
|
var UPGRADE_USAGE = `Usage: yaw-mcp upgrade [--run] [--json]
|
|
@@ -3996,7 +4106,7 @@ function localInstallRoot(argvPath) {
|
|
|
3996
4106
|
async function defaultNpmPrefix() {
|
|
3997
4107
|
if (process.env.VITEST) return null;
|
|
3998
4108
|
return new Promise((resolve8) => {
|
|
3999
|
-
const child =
|
|
4109
|
+
const child = spawn3("npm", ["prefix", "-g"], {
|
|
4000
4110
|
shell: process.platform === "win32",
|
|
4001
4111
|
stdio: ["ignore", "pipe", "ignore"]
|
|
4002
4112
|
});
|
|
@@ -4134,7 +4244,7 @@ async function defaultFetchLatest() {
|
|
|
4134
4244
|
}
|
|
4135
4245
|
async function defaultSpawn(cmd, args, cwd) {
|
|
4136
4246
|
return new Promise((resolve8) => {
|
|
4137
|
-
const child =
|
|
4247
|
+
const child = spawn3(cmd, args, { stdio: "inherit", shell: process.platform === "win32", cwd });
|
|
4138
4248
|
child.on("close", (code) => resolve8(typeof code === "number" ? code : 1));
|
|
4139
4249
|
child.on("error", () => resolve8(1));
|
|
4140
4250
|
});
|
|
@@ -4265,7 +4375,7 @@ async function runUpgrade(opts = {}) {
|
|
|
4265
4375
|
return { exitCode: 3, lines };
|
|
4266
4376
|
}
|
|
4267
4377
|
function readCurrentVersion() {
|
|
4268
|
-
return true ? "0.
|
|
4378
|
+
return true ? "0.74.0" : "dev";
|
|
4269
4379
|
}
|
|
4270
4380
|
|
|
4271
4381
|
// src/learning.ts
|
|
@@ -4482,7 +4592,7 @@ async function projectTrustWarning(opts) {
|
|
|
4482
4592
|
}
|
|
4483
4593
|
return untrustedProjectWarning(probe, { detail: true });
|
|
4484
4594
|
}
|
|
4485
|
-
var VERSION = true ? "0.
|
|
4595
|
+
var VERSION = true ? "0.74.0" : "dev";
|
|
4486
4596
|
function isPersistenceDisabled(env) {
|
|
4487
4597
|
const raw = env.YAW_MCP_DISABLE_PERSISTENCE;
|
|
4488
4598
|
return raw !== void 0 && raw !== "" && (raw === "1" || raw.toLowerCase() === "true");
|
|
@@ -4800,7 +4910,7 @@ function renderEnvSection(opts) {
|
|
|
4800
4910
|
print("");
|
|
4801
4911
|
}
|
|
4802
4912
|
async function collectOamRuntimeStatus(opts) {
|
|
4803
|
-
const probe = opts.probeFn();
|
|
4913
|
+
const probe = await opts.probeFn();
|
|
4804
4914
|
const dflt = await describeDefaultRuntime({ env: opts.env, cwd: opts.cwd, home: opts.home });
|
|
4805
4915
|
const bundles = await loadLocalBundles({ cwd: opts.cwd, home: opts.home }).catch(() => null);
|
|
4806
4916
|
const servers = (bundles?.config?.servers ?? []).map((s) => ({
|
|
@@ -5224,28 +5334,31 @@ function tokenize(text) {
|
|
|
5224
5334
|
if (!text) return [];
|
|
5225
5335
|
return text.toLowerCase().split(/[^a-z0-9]+/).filter((w) => w.length >= MIN_TOKEN_LEN);
|
|
5226
5336
|
}
|
|
5337
|
+
function emptyField() {
|
|
5338
|
+
return { len: 0, counts: /* @__PURE__ */ new Map() };
|
|
5339
|
+
}
|
|
5340
|
+
function addTokens(field, tokens) {
|
|
5341
|
+
for (const t of tokens) {
|
|
5342
|
+
field.counts.set(t, (field.counts.get(t) ?? 0) + 1);
|
|
5343
|
+
}
|
|
5344
|
+
field.len += tokens.length;
|
|
5345
|
+
return field;
|
|
5346
|
+
}
|
|
5227
5347
|
function buildDocFields(server) {
|
|
5228
|
-
const
|
|
5229
|
-
const
|
|
5348
|
+
const toolName = emptyField();
|
|
5349
|
+
const toolDescription = emptyField();
|
|
5230
5350
|
for (const tool of server.tools) {
|
|
5231
|
-
|
|
5232
|
-
|
|
5351
|
+
addTokens(toolName, tokenize(tool.name));
|
|
5352
|
+
addTokens(toolDescription, tokenize(tool.description));
|
|
5233
5353
|
}
|
|
5234
5354
|
return {
|
|
5235
|
-
namespace: tokenize(server.namespace),
|
|
5236
|
-
name: tokenize(server.name),
|
|
5237
|
-
description: tokenize(server.description),
|
|
5238
|
-
toolName
|
|
5239
|
-
toolDescription
|
|
5355
|
+
namespace: addTokens(emptyField(), tokenize(server.namespace)),
|
|
5356
|
+
name: addTokens(emptyField(), tokenize(server.name)),
|
|
5357
|
+
description: addTokens(emptyField(), tokenize(server.description)),
|
|
5358
|
+
toolName,
|
|
5359
|
+
toolDescription
|
|
5240
5360
|
};
|
|
5241
5361
|
}
|
|
5242
|
-
function termFreq(tokens, term) {
|
|
5243
|
-
let count = 0;
|
|
5244
|
-
for (const t of tokens) {
|
|
5245
|
-
if (t === term) count++;
|
|
5246
|
-
}
|
|
5247
|
-
return count;
|
|
5248
|
-
}
|
|
5249
5362
|
function bm25Score(queryTerms, fields, avgFieldLen, idfValues) {
|
|
5250
5363
|
let score = 0;
|
|
5251
5364
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -5255,12 +5368,12 @@ function bm25Score(queryTerms, fields, avgFieldLen, idfValues) {
|
|
|
5255
5368
|
const termIdf = idfValues.get(term);
|
|
5256
5369
|
if (termIdf === void 0 || termIdf <= 0) continue;
|
|
5257
5370
|
for (const [fieldName, weight] of Object.entries(FIELD_WEIGHTS)) {
|
|
5258
|
-
const
|
|
5259
|
-
if (
|
|
5260
|
-
const tf =
|
|
5371
|
+
const field = fields[fieldName];
|
|
5372
|
+
if (field.len === 0) continue;
|
|
5373
|
+
const tf = field.counts.get(term) ?? 0;
|
|
5261
5374
|
if (tf === 0) continue;
|
|
5262
5375
|
const avg = avgFieldLen[fieldName] || 1;
|
|
5263
|
-
const normLen = 1 - B + B * (
|
|
5376
|
+
const normLen = 1 - B + B * (field.len / avg);
|
|
5264
5377
|
const numerator = tf * (K1 + 1);
|
|
5265
5378
|
const denominator = tf + K1 * normLen;
|
|
5266
5379
|
score += weight * termIdf * (numerator / denominator);
|
|
@@ -5268,27 +5381,67 @@ function bm25Score(queryTerms, fields, avgFieldLen, idfValues) {
|
|
|
5268
5381
|
}
|
|
5269
5382
|
return score;
|
|
5270
5383
|
}
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5384
|
+
var MAX_CACHED_DOCS = 512;
|
|
5385
|
+
var docCache = /* @__PURE__ */ new Map();
|
|
5386
|
+
var MAX_CACHED_INDEXES = 4;
|
|
5387
|
+
var indexCache = /* @__PURE__ */ new Map();
|
|
5388
|
+
var indexBuilds = 0;
|
|
5389
|
+
var docBuilds = 0;
|
|
5390
|
+
function putBounded(cache, key, value, max) {
|
|
5391
|
+
if (cache.size >= max) {
|
|
5392
|
+
const oldest = cache.keys().next().value;
|
|
5393
|
+
if (oldest !== void 0) cache.delete(oldest);
|
|
5394
|
+
}
|
|
5395
|
+
cache.set(key, value);
|
|
5396
|
+
}
|
|
5397
|
+
function touch(cache, key, value) {
|
|
5398
|
+
cache.delete(key);
|
|
5399
|
+
cache.set(key, value);
|
|
5400
|
+
}
|
|
5401
|
+
var SEP = "\0";
|
|
5402
|
+
function esc(text) {
|
|
5403
|
+
return text.includes(SEP) ? text.replaceAll(SEP, SEP + SEP) : text;
|
|
5404
|
+
}
|
|
5405
|
+
function serverSignature(server) {
|
|
5406
|
+
let sig = `${esc(server.namespace)}${SEP}${esc(server.name)}${SEP}${esc(server.description ?? "")}`;
|
|
5407
|
+
for (const tool of server.tools) {
|
|
5408
|
+
sig += `${SEP}${esc(tool.name)}${SEP}${esc(tool.description ?? "")}`;
|
|
5409
|
+
}
|
|
5410
|
+
return sig;
|
|
5411
|
+
}
|
|
5412
|
+
function indexKeyFor(signatures) {
|
|
5413
|
+
let lens = "";
|
|
5414
|
+
for (const sig of signatures) lens += `${sig.length},`;
|
|
5415
|
+
return `${lens}|${signatures.join("")}`;
|
|
5416
|
+
}
|
|
5417
|
+
function docFieldsFor(signature, server) {
|
|
5418
|
+
const cached = docCache.get(signature);
|
|
5419
|
+
if (cached) {
|
|
5420
|
+
touch(docCache, signature, cached);
|
|
5421
|
+
return cached;
|
|
5422
|
+
}
|
|
5423
|
+
docBuilds++;
|
|
5424
|
+
const fields = buildDocFields(server);
|
|
5425
|
+
putBounded(docCache, signature, fields, MAX_CACHED_DOCS);
|
|
5426
|
+
return fields;
|
|
5427
|
+
}
|
|
5428
|
+
function buildIndex(servers, signatures) {
|
|
5429
|
+
indexBuilds++;
|
|
5430
|
+
const docs = servers.map((s, i) => ({ namespace: s.namespace, fields: docFieldsFor(signatures[i], s) }));
|
|
5431
|
+
const N = docs.length;
|
|
5276
5432
|
const df = /* @__PURE__ */ new Map();
|
|
5277
|
-
for (const { fields } of
|
|
5278
|
-
const bag = /* @__PURE__ */ new Set(
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
...fields.toolName,
|
|
5283
|
-
...fields.toolDescription
|
|
5284
|
-
]);
|
|
5433
|
+
for (const { fields } of docs) {
|
|
5434
|
+
const bag = /* @__PURE__ */ new Set();
|
|
5435
|
+
for (const fieldName of Object.keys(FIELD_WEIGHTS)) {
|
|
5436
|
+
for (const term of fields[fieldName].counts.keys()) bag.add(term);
|
|
5437
|
+
}
|
|
5285
5438
|
for (const term of bag) {
|
|
5286
5439
|
df.set(term, (df.get(term) ?? 0) + 1);
|
|
5287
5440
|
}
|
|
5288
5441
|
}
|
|
5289
|
-
const
|
|
5442
|
+
const idf = /* @__PURE__ */ new Map();
|
|
5290
5443
|
for (const [term, d] of df) {
|
|
5291
|
-
|
|
5444
|
+
idf.set(term, Math.log((N - d + 0.5) / (d + 0.5) + 1));
|
|
5292
5445
|
}
|
|
5293
5446
|
const totalLen = {
|
|
5294
5447
|
namespace: 0,
|
|
@@ -5297,12 +5450,10 @@ function rankServers(context, servers) {
|
|
|
5297
5450
|
toolName: 0,
|
|
5298
5451
|
toolDescription: 0
|
|
5299
5452
|
};
|
|
5300
|
-
for (const { fields } of
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
totalLen.toolName += fields.toolName.length;
|
|
5305
|
-
totalLen.toolDescription += fields.toolDescription.length;
|
|
5453
|
+
for (const { fields } of docs) {
|
|
5454
|
+
for (const fieldName of Object.keys(FIELD_WEIGHTS)) {
|
|
5455
|
+
totalLen[fieldName] += fields[fieldName].len;
|
|
5456
|
+
}
|
|
5306
5457
|
}
|
|
5307
5458
|
const denom = Math.max(N, 1);
|
|
5308
5459
|
const avgFieldLen = {
|
|
@@ -5312,11 +5463,14 @@ function rankServers(context, servers) {
|
|
|
5312
5463
|
toolName: totalLen.toolName / denom,
|
|
5313
5464
|
toolDescription: totalLen.toolDescription / denom
|
|
5314
5465
|
};
|
|
5466
|
+
return { docs, idf, avgFieldLen };
|
|
5467
|
+
}
|
|
5468
|
+
function scoreAgainstIndex(queryTerms, index) {
|
|
5315
5469
|
const results = [];
|
|
5316
|
-
for (const {
|
|
5317
|
-
const score = bm25Score(queryTerms, fields, avgFieldLen,
|
|
5470
|
+
for (const { namespace, fields } of index.docs) {
|
|
5471
|
+
const score = bm25Score(queryTerms, fields, index.avgFieldLen, index.idf);
|
|
5318
5472
|
if (score > 0) {
|
|
5319
|
-
results.push({ namespace
|
|
5473
|
+
results.push({ namespace, score });
|
|
5320
5474
|
}
|
|
5321
5475
|
}
|
|
5322
5476
|
results.sort((a, b) => {
|
|
@@ -5325,6 +5479,20 @@ function rankServers(context, servers) {
|
|
|
5325
5479
|
});
|
|
5326
5480
|
return results;
|
|
5327
5481
|
}
|
|
5482
|
+
function rankServers(context, servers) {
|
|
5483
|
+
const queryTerms = tokenize(context);
|
|
5484
|
+
if (queryTerms.length === 0 || servers.length === 0) return [];
|
|
5485
|
+
const signatures = servers.map(serverSignature);
|
|
5486
|
+
const indexKey = indexKeyFor(signatures);
|
|
5487
|
+
let index = indexCache.get(indexKey);
|
|
5488
|
+
if (index === void 0) {
|
|
5489
|
+
index = buildIndex(servers, signatures);
|
|
5490
|
+
putBounded(indexCache, indexKey, index, MAX_CACHED_INDEXES);
|
|
5491
|
+
} else {
|
|
5492
|
+
touch(indexCache, indexKey, index);
|
|
5493
|
+
}
|
|
5494
|
+
return scoreAgainstIndex(queryTerms, index);
|
|
5495
|
+
}
|
|
5328
5496
|
|
|
5329
5497
|
// src/foundry.ts
|
|
5330
5498
|
var SECRET_PREFIXES = ["sk_", "sk-", "tok_", "ghp_", "gho_", "xox", "pk_", "akia"];
|
|
@@ -7572,7 +7740,7 @@ import {
|
|
|
7572
7740
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
7573
7741
|
|
|
7574
7742
|
// src/auto-upgrade.ts
|
|
7575
|
-
import { spawn as
|
|
7743
|
+
import { spawn as spawn4 } from "child_process";
|
|
7576
7744
|
import { realpathSync as realpathSync2 } from "fs";
|
|
7577
7745
|
import { dirname as dirname3, sep as sep2 } from "path";
|
|
7578
7746
|
function quoteShellArgIfNeeded(arg, platform = process.platform) {
|
|
@@ -7606,7 +7774,7 @@ function detectRunningInstallPrefix(argvPath) {
|
|
|
7606
7774
|
}
|
|
7607
7775
|
async function compareWithNpmPrefix(detected) {
|
|
7608
7776
|
await new Promise((res) => {
|
|
7609
|
-
const child =
|
|
7777
|
+
const child = spawn4("npm", ["prefix", "-g"], {
|
|
7610
7778
|
stdio: ["ignore", "pipe", "ignore"],
|
|
7611
7779
|
shell: process.platform === "win32"
|
|
7612
7780
|
});
|
|
@@ -7650,7 +7818,7 @@ async function fetchLatestVersion2() {
|
|
|
7650
7818
|
function defaultSpawn2(cmd, args) {
|
|
7651
7819
|
let errorFired = false;
|
|
7652
7820
|
const correctiveCmd = cmd === "npm" ? "npm install -g @yawlabs/mcp@latest" : cmd === "pnpm" ? "pnpm add -g @yawlabs/mcp@latest" : "bun add -g @yawlabs/mcp@latest";
|
|
7653
|
-
const child =
|
|
7821
|
+
const child = spawn4(cmd, args, {
|
|
7654
7822
|
stdio: "ignore",
|
|
7655
7823
|
// Stay a child of this process (not detached) so it dies with yaw-mcp
|
|
7656
7824
|
// if yaw-mcp exits mid-install -- a half-finished install is fine
|
|
@@ -7679,7 +7847,7 @@ function defaultSpawn2(cmd, args) {
|
|
|
7679
7847
|
async function maybeAutoUpgrade(deps = {}) {
|
|
7680
7848
|
const optOut = process.env.YAW_MCP_AUTO_UPGRADE;
|
|
7681
7849
|
if (optOut === "0" || optOut?.toLowerCase() === "false") return;
|
|
7682
|
-
const current = deps.currentVersion ?? (true ? "0.
|
|
7850
|
+
const current = deps.currentVersion ?? (true ? "0.74.0" : "dev");
|
|
7683
7851
|
if (current === "dev") return;
|
|
7684
7852
|
const method = (deps.isSeaImpl ? await deps.isSeaImpl() : await detectSea()) ? "binary" : detectInstallMethod(deps.argvPath ?? process.argv[1]);
|
|
7685
7853
|
const latest = await (deps.fetchLatestImpl ?? fetchLatestVersion2)();
|
|
@@ -8030,7 +8198,12 @@ function resolveArgs(args, bindings) {
|
|
|
8030
8198
|
if (args !== null && typeof args === "object") {
|
|
8031
8199
|
const out = {};
|
|
8032
8200
|
for (const [k, v] of Object.entries(args)) {
|
|
8033
|
-
|
|
8201
|
+
const resolved = resolveArgs(v, bindings);
|
|
8202
|
+
if (k === "__proto__") {
|
|
8203
|
+
Object.defineProperty(out, k, { value: resolved, writable: true, enumerable: true, configurable: true });
|
|
8204
|
+
} else {
|
|
8205
|
+
out[k] = resolved;
|
|
8206
|
+
}
|
|
8034
8207
|
}
|
|
8035
8208
|
return out;
|
|
8036
8209
|
}
|
|
@@ -9046,7 +9219,11 @@ function pruneJson(value) {
|
|
|
9046
9219
|
for (const [k, v] of Object.entries(value)) {
|
|
9047
9220
|
const pv = pruneJson(v);
|
|
9048
9221
|
if (pv !== void 0) {
|
|
9049
|
-
|
|
9222
|
+
if (k === "__proto__") {
|
|
9223
|
+
Object.defineProperty(out, k, { value: pv, writable: true, enumerable: true, configurable: true });
|
|
9224
|
+
} else {
|
|
9225
|
+
out[k] = pv;
|
|
9226
|
+
}
|
|
9050
9227
|
kept++;
|
|
9051
9228
|
}
|
|
9052
9229
|
}
|
|
@@ -9547,7 +9724,7 @@ import {
|
|
|
9547
9724
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
9548
9725
|
|
|
9549
9726
|
// src/uv-bootstrap.ts
|
|
9550
|
-
import { spawn as
|
|
9727
|
+
import { spawn as spawn5 } from "child_process";
|
|
9551
9728
|
import { createHash as createHash3 } from "crypto";
|
|
9552
9729
|
import { createWriteStream } from "fs";
|
|
9553
9730
|
import fs from "fs/promises";
|
|
@@ -9600,7 +9777,7 @@ async function onPath(cmd) {
|
|
|
9600
9777
|
};
|
|
9601
9778
|
let child;
|
|
9602
9779
|
try {
|
|
9603
|
-
child =
|
|
9780
|
+
child = spawn5(cmd, ["--version"], {
|
|
9604
9781
|
stdio: "ignore",
|
|
9605
9782
|
// Windows needs a shell for PATHEXT shim resolution (.cmd/.exe)
|
|
9606
9783
|
// so `uv --version` finds uv.cmd without an ENOENT false-negative.
|
|
@@ -9696,7 +9873,7 @@ async function extractArchive(archivePath, destDir) {
|
|
|
9696
9873
|
}
|
|
9697
9874
|
function runCommand(cmd, args) {
|
|
9698
9875
|
return new Promise((resolve8, reject) => {
|
|
9699
|
-
const child =
|
|
9876
|
+
const child = spawn5(cmd, args, {
|
|
9700
9877
|
stdio: ["ignore", "pipe", "pipe"],
|
|
9701
9878
|
shell: false,
|
|
9702
9879
|
windowsHide: process.platform === "win32"
|
|
@@ -9916,7 +10093,7 @@ async function connectToUpstream(config, onDisconnect, onListChanged) {
|
|
|
9916
10093
|
}
|
|
9917
10094
|
async function connectToUpstreamOnce(config, onDisconnect, onListChanged, attempt, disableOamRewrite) {
|
|
9918
10095
|
const client = new Client(
|
|
9919
|
-
{ name: "yaw-mcp", version: true ? "0.
|
|
10096
|
+
{ name: "yaw-mcp", version: true ? "0.74.0" : "dev" },
|
|
9920
10097
|
{ capabilities: {} }
|
|
9921
10098
|
);
|
|
9922
10099
|
let transport;
|
|
@@ -9934,10 +10111,10 @@ async function connectToUpstreamOnce(config, onDisconnect, onListChanged, attemp
|
|
|
9934
10111
|
let resolved = await resolveUvSpawn(config.command, config.args ?? []);
|
|
9935
10112
|
const effectiveRuntime = config.runtime ?? await defaultRuntime();
|
|
9936
10113
|
if (effectiveRuntime === "oam" && !disableOamRewrite && !oamDowngradedNamespaces.has(config.namespace)) {
|
|
9937
|
-
const rewritten = resolveOamSpawn(resolved.command, resolved.args);
|
|
10114
|
+
const rewritten = await resolveOamSpawn(resolved.command, resolved.args);
|
|
9938
10115
|
if (rewritten.command !== resolved.command) {
|
|
9939
10116
|
attempt.oamRewritten = true;
|
|
9940
|
-
attempt.oamVersion = probeOam().version;
|
|
10117
|
+
attempt.oamVersion = (await probeOam()).version;
|
|
9941
10118
|
resolved = rewritten;
|
|
9942
10119
|
}
|
|
9943
10120
|
}
|
|
@@ -10432,7 +10609,7 @@ var ConnectServer = class _ConnectServer {
|
|
|
10432
10609
|
static STATE_SAVE_DEBOUNCE_MS = 1e3;
|
|
10433
10610
|
constructor() {
|
|
10434
10611
|
this.server = new Server(
|
|
10435
|
-
{ name: "yaw-mcp", version: true ? "0.
|
|
10612
|
+
{ name: "yaw-mcp", version: true ? "0.74.0" : "dev" },
|
|
10436
10613
|
{
|
|
10437
10614
|
capabilities: {
|
|
10438
10615
|
tools: { listChanged: true },
|
|
@@ -11131,9 +11308,10 @@ var ConnectServer = class _ConnectServer {
|
|
|
11131
11308
|
activeServers.map((s) => this.rankableFor(s))
|
|
11132
11309
|
);
|
|
11133
11310
|
for (const r of ranked) scores.set(r.namespace, r.score);
|
|
11311
|
+
const byNamespace = new Map(activeServers.map((s) => [s.namespace, s]));
|
|
11312
|
+
const matched = ranked.map((r) => byNamespace.get(r.namespace)).filter((s) => s !== void 0);
|
|
11134
11313
|
const rankedSet = new Set(ranked.map((r) => r.namespace));
|
|
11135
11314
|
const rest = activeServers.filter((s) => !rankedSet.has(s.namespace));
|
|
11136
|
-
const matched = ranked.map((r) => activeServers.find((s) => s.namespace === r.namespace)).filter((s) => s !== void 0);
|
|
11137
11315
|
sorted = [...matched, ...rest];
|
|
11138
11316
|
} else {
|
|
11139
11317
|
sorted = activeServers;
|
|
@@ -12811,7 +12989,7 @@ if (subcommand === "compliance") {
|
|
|
12811
12989
|
`);
|
|
12812
12990
|
process.exitCode = 0;
|
|
12813
12991
|
} else if (subcommand === "--version" || subcommand === "-V") {
|
|
12814
|
-
process.stdout.write(`yaw-mcp ${true ? "0.
|
|
12992
|
+
process.stdout.write(`yaw-mcp ${true ? "0.74.0" : "dev"}
|
|
12815
12993
|
`);
|
|
12816
12994
|
process.exitCode = 0;
|
|
12817
12995
|
} else if (subcommand && !subcommand.startsWith("-")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yawlabs/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.74.0",
|
|
4
4
|
"mcpName": "io.github.YawLabs/mcp",
|
|
5
5
|
"description": "Yaw MCP -- MCP servers, managed. Free to run locally; Yaw Team adds cross-machine sync.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"vitest": "^4.1.9"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
|
-
"node": ">=
|
|
49
|
+
"node": ">=20"
|
|
50
50
|
},
|
|
51
51
|
"keywords": [
|
|
52
52
|
"mcp",
|