vexp-mcp 3.1.1 → 3.1.3
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/dist/daemon-client.js +45 -2
- package/dist/index.js +88 -0
- package/package.json +1 -1
package/dist/daemon-client.js
CHANGED
|
@@ -320,6 +320,48 @@ export class DaemonClient {
|
|
|
320
320
|
});
|
|
321
321
|
});
|
|
322
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* How long one call waits for the daemon, per tool.
|
|
325
|
+
*
|
|
326
|
+
* This was 30 s for every tool. verify_done does not fit it: on a field
|
|
327
|
+
* ledger of 26 calls (2026-09-09, a 229-file repo on a 9p mount) the median
|
|
328
|
+
* was 28.4 s and 12 ran past 30 s; both agent-initiated calls timed out here
|
|
329
|
+
* while the daemon finished the work (52 s, 42 s) and cached a verdict nobody
|
|
330
|
+
* read. The daemon never cancels on a client that stopped waiting, so a
|
|
331
|
+
* short budget only turns finished work into an error. Lockstep twin:
|
|
332
|
+
* `daemon_call_budget` in packages/vexp-core/src/mcp_stdio.rs (the test
|
|
333
|
+
* reads that file).
|
|
334
|
+
*/
|
|
335
|
+
static callBudgetMs(tool) {
|
|
336
|
+
switch (tool) {
|
|
337
|
+
case "verify_done":
|
|
338
|
+
return 120_000;
|
|
339
|
+
case "run_pipeline":
|
|
340
|
+
case "get_context_capsule":
|
|
341
|
+
return 90_000;
|
|
342
|
+
default:
|
|
343
|
+
return 30_000;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* What the agent reads when the budget runs out: the tool, that the daemon
|
|
348
|
+
* accepted the request and is still working on it, and for verify_done the
|
|
349
|
+
* one useful move — the finished verdict is memoized on the tree
|
|
350
|
+
* fingerprint, so one more call after the daemon is done returns instantly.
|
|
351
|
+
*/
|
|
352
|
+
static timeoutMessage(tool, budgetMs) {
|
|
353
|
+
let m = `Timeout: no response from daemon for tool '${tool}' after ${Math.round(budgetMs / 1000)}s. ` +
|
|
354
|
+
"The daemon accepted the request and keeps processing it (a client that stops waiting does not cancel it)";
|
|
355
|
+
if (tool === "verify_done") {
|
|
356
|
+
m +=
|
|
357
|
+
"; call verify_done once more in ~30s: a finished verdict on an unchanged tree is served " +
|
|
358
|
+
"from cache instantly. Phase timings for the slow call are in .vexp/daemon.log (grep verify_done).";
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
m += ".";
|
|
362
|
+
}
|
|
363
|
+
return m;
|
|
364
|
+
}
|
|
323
365
|
async callOnce(tool, params) {
|
|
324
366
|
return new Promise((resolve, reject) => {
|
|
325
367
|
const id = ++this.requestCounter;
|
|
@@ -328,13 +370,14 @@ export class DaemonClient {
|
|
|
328
370
|
let client;
|
|
329
371
|
let responseBuffer = "";
|
|
330
372
|
let settled = false;
|
|
373
|
+
const budgetMs = DaemonClient.callBudgetMs(tool);
|
|
331
374
|
const timeout = setTimeout(() => {
|
|
332
375
|
if (!settled) {
|
|
333
376
|
settled = true;
|
|
334
377
|
client?.destroy();
|
|
335
|
-
reject(new Error(
|
|
378
|
+
reject(new Error(DaemonClient.timeoutMessage(tool, budgetMs)));
|
|
336
379
|
}
|
|
337
|
-
},
|
|
380
|
+
}, budgetMs);
|
|
338
381
|
const settle = (fn) => {
|
|
339
382
|
if (!settled) {
|
|
340
383
|
settled = true;
|
package/dist/index.js
CHANGED
|
@@ -146,6 +146,57 @@ function allToolsEnabled() {
|
|
|
146
146
|
// discoverWorkspaceRoot). The Rust daemon registers itself in
|
|
147
147
|
// ~/.vexp/daemons.json on all platforms, which is the authoritative
|
|
148
148
|
// lookup when an agent spawns the MCP server from an unrelated cwd.
|
|
149
|
+
/**
|
|
150
|
+
* This MCP server's own version, from the package.json that ships it.
|
|
151
|
+
*
|
|
152
|
+
* Resolved from `process.argv[1]` rather than `__dirname`/`import.meta.url`,
|
|
153
|
+
* because the same source runs three ways: as the bundled CJS
|
|
154
|
+
* `vexp-cli/mcp/mcp-server.cjs`, as the copy in `vexp-vscode/dist/`, and from
|
|
155
|
+
* `src/` in development. In all three, the package.json one or two levels up
|
|
156
|
+
* from the entry script is the version the user installed.
|
|
157
|
+
*/
|
|
158
|
+
function mcpServerVersion() {
|
|
159
|
+
const entry = process.argv[1];
|
|
160
|
+
if (!entry)
|
|
161
|
+
return undefined;
|
|
162
|
+
const dir = path.dirname(path.resolve(entry));
|
|
163
|
+
for (const candidate of [
|
|
164
|
+
path.join(dir, "..", "package.json"),
|
|
165
|
+
path.join(dir, "..", "..", "package.json"),
|
|
166
|
+
]) {
|
|
167
|
+
try {
|
|
168
|
+
const pkg = JSON.parse(fs.readFileSync(candidate, "utf-8"));
|
|
169
|
+
if (typeof pkg.version === "string")
|
|
170
|
+
return pkg.version;
|
|
171
|
+
}
|
|
172
|
+
catch { /* keep looking */ }
|
|
173
|
+
}
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Is `recorded` strictly older than `mine`? Third copy of the comparison in
|
|
178
|
+
* vexp-cli/src/mcp-supervisor.ts (which carries the tests) and
|
|
179
|
+
* vexp-vscode/src/daemon-manager.ts. Unknown or unparseable never counts as
|
|
180
|
+
* older here: this one only decides whether to print a warning, and a wrong
|
|
181
|
+
* warning about your own build is worse than none.
|
|
182
|
+
*/
|
|
183
|
+
function isOlderVersion(mine, other) {
|
|
184
|
+
if (mine === other)
|
|
185
|
+
return false;
|
|
186
|
+
const parts = (v) => {
|
|
187
|
+
const nums = v.split("-")[0].split(".").map((n) => Number.parseInt(n, 10));
|
|
188
|
+
return nums.length === 3 && nums.every((n) => Number.isFinite(n)) ? nums : null;
|
|
189
|
+
};
|
|
190
|
+
const a = parts(mine);
|
|
191
|
+
const b = parts(other);
|
|
192
|
+
if (!a || !b)
|
|
193
|
+
return false;
|
|
194
|
+
for (let i = 0; i < 3; i++) {
|
|
195
|
+
if (a[i] !== b[i])
|
|
196
|
+
return a[i] < b[i];
|
|
197
|
+
}
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
149
200
|
export function createMcpServer(daemon) {
|
|
150
201
|
const server = new Server({ name: "vexp-mcp", version: "1.0.0" }, { capabilities: { tools: {} } });
|
|
151
202
|
// This surface used to publish expand_vexp_ref mid-session, the first time a
|
|
@@ -168,6 +219,42 @@ export function createMcpServer(daemon) {
|
|
|
168
219
|
? ALL_TOOL_DEFINITIONS
|
|
169
220
|
: MINIMAL_TOOL_DEFINITIONS.map(slimForListing),
|
|
170
221
|
}));
|
|
222
|
+
// ── Am I the build the user thinks they are talking to? ──────────────
|
|
223
|
+
//
|
|
224
|
+
// An MCP server is a long-lived detached process. Upgrading the CLI does
|
|
225
|
+
// not replace it, so agents can be served an old build indefinitely while
|
|
226
|
+
// `vexp --version` in a terminal reports the new one — a tester's agents
|
|
227
|
+
// ran two minor versions behind for as long as it took him to run doctor,
|
|
228
|
+
// and nothing in the MCP path itself said so (tier-4 field report,
|
|
229
|
+
// 2026-09-05). doctor already reports it, but an agent driving vexp purely
|
|
230
|
+
// through MCP never runs doctor and cannot know to ask.
|
|
231
|
+
//
|
|
232
|
+
// The daemon is spawned from the INSTALLED binary, so its version is the
|
|
233
|
+
// installed version: if this process is older than the daemon it is
|
|
234
|
+
// talking to, this process is the stale one. Checked once — a stale server
|
|
235
|
+
// stays stale for its lifetime — and prefixed to every tool result,
|
|
236
|
+
// because a warning the agent has to go looking for is the warning it does
|
|
237
|
+
// not see.
|
|
238
|
+
let staleBanner = null;
|
|
239
|
+
async function staleBuildNotice() {
|
|
240
|
+
if (staleBanner !== null)
|
|
241
|
+
return staleBanner;
|
|
242
|
+
staleBanner = "";
|
|
243
|
+
try {
|
|
244
|
+
const mine = mcpServerVersion();
|
|
245
|
+
if (!mine)
|
|
246
|
+
return staleBanner;
|
|
247
|
+
const status = (await daemon.call("index_status", {}));
|
|
248
|
+
const engine = typeof status?.engine_version === "string" ? status.engine_version : undefined;
|
|
249
|
+
if (engine && isOlderVersion(mine, engine)) {
|
|
250
|
+
staleBanner =
|
|
251
|
+
`> this MCP server is v${mine} but the installed vexp is v${engine} — you are being served ` +
|
|
252
|
+
`the OLD build; restart the MCP client, or run 'vexp setup' in the workspace root to replace it\n\n`;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
catch { /* no daemon, older daemon, no engine_version: say nothing */ }
|
|
256
|
+
return staleBanner;
|
|
257
|
+
}
|
|
171
258
|
server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
172
259
|
const { name, arguments: args } = req.params;
|
|
173
260
|
try {
|
|
@@ -215,6 +302,7 @@ export function createMcpServer(daemon) {
|
|
|
215
302
|
content: [{ type: "text", text: `Unknown tool: ${name}` }],
|
|
216
303
|
};
|
|
217
304
|
}
|
|
305
|
+
text = (await staleBuildNotice()) + text;
|
|
218
306
|
return {
|
|
219
307
|
content: [{ type: "text", text }],
|
|
220
308
|
};
|