Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

A lent MCP server that refused to start starts again on the next call

milind-sonicc000a3310fb
diff --git a/electron/lent-mcp.mjs b/electron/lent-mcp.mjs
index 79d11098d9..ef95443bad 100644
--- a/electron/lent-mcp.mjs
+++ b/electron/lent-mcp.mjs
@@ -230,8 +230,8 @@ export function createLentMcp({ environment = async () => ({ ...inheritedEnviron
for (let attempt = 0; ; attempt++) {
const live = await ready(server, signal);
clearTimeout(live.idle);
+ try { await live.started; } catch (error) { live.failed = true; stop(server.name); throw error; }
try {
- await live.started;
const result = await work(live.client);
live.idle = setTimeout(() => stop(server.name), IDLE_MS);
live.idle.unref?.();
diff --git a/electron/lent-mcp.node-test.mjs b/electron/lent-mcp.node-test.mjs
index c696f38ee2..52c0656350 100644
--- a/electron/lent-mcp.node-test.mjs
+++ b/electron/lent-mcp.node-test.mjs
@@ -93,6 +93,20 @@ test("a command server starts once, from the home folder, with its saved key, an
assert.equal(fresh.key, "new-key");
});
+test("a server that refuses to start is started again on the next call, not kept refusing", async t => {
+ let refusals = 1;
+ const { url, seen } = await httpFixture(t, (req, res, message) => {
+ if (!("id" in message)) { res.writeHead(202).end(); return; }
+ if (message.method === "initialize" && refusals-- > 0) { res.writeHead(200, { "content-type": "application/json" }).end(JSON.stringify({ jsonrpc: "2.0", id: message.id, error: { code: -32000, message: "warming up" } })); return; }
+ res.writeHead(200, { "content-type": "application/json" }).end(JSON.stringify({ jsonrpc: "2.0", id: message.id, result: message.method === "initialize" ? { protocolVersion: "2025-03-26" } : { tools: [{ name: "search" }] } }));
+ });
+ const lent = createLentMcp();
+ t.after(() => lent.close());
+ await assert.rejects(lent.call({ action: "mcp_tools", server: http(url) }, signal()), /warming up/);
+ assert.deepEqual(await lent.call({ action: "mcp_tools", server: http(url) }, signal()), { tools: [{ name: "search" }] });
+ assert.equal(seen.filter(request => request.message.method === "initialize").length, 2);
+});
+
test("a command server that can't start says so by its program's name, never with its keys", async t => {
const { lent } = await stdioFixture(t);
const missing = { name: "notes", command: path.join(tmpdir(), "omb-no-such-program"), args: [], env: { NOTES_TOKEN: "never-echoed" } };