Skip to content

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

Lent MCP: refuse a server that needs the person's computer only on My Cloud

milind-soni0ad0332f7ba8
diff --git a/server/lent-mcp.test.ts b/server/lent-mcp.test.ts
index aaee184a2f..4f48034c52 100644
--- a/server/lent-mcp.test.ts
+++ b/server/lent-mcp.test.ts
@@ -13,7 +13,7 @@ const notes = { command: "/Users/ada/bin/notes-mcp", args: [], env: { NOTES_TOKE
const here = (over: Partial<HereChecks> = {}): HereChecks => ({ exists: () => false, program: () => true, answers: async () => false, ...over });
type Online = NonNullable<ReturnType<SharedComputers["runsOn"]>["online"]>;
-function fixture(options: { online?: Partial<Online> | null; known?: { lent: boolean } | null; principal?: string | null; servers?: Record<string, unknown>; mcpServers?: string[]; toolScope?: unknown; answer?: (operation: Record<string, unknown>) => unknown; lenders?: ReturnType<SharedComputers["mcpLenders"]>; here?: HereChecks } = {}) {
+function fixture(options: { online?: Partial<Online> | null; known?: { lent: boolean } | null; principal?: string | null; servers?: Record<string, unknown>; mcpServers?: string[]; toolScope?: unknown; answer?: (operation: Record<string, unknown>) => unknown; lenders?: ReturnType<SharedComputers["mcpLenders"]>; here?: HereChecks; personal?: boolean; place?: string } = {}) {
const requests: Array<{ operation: Record<string, unknown>; principal: string | null }> = [];
const online = options.online === null ? null : { id: "mac-1", name: "Ada's Mac", platform: "darwin" as const, terminal: false, mcpServers: true, ...options.online };
const computers: LentMcpDeps["computers"] = {
@@ -38,8 +38,8 @@ function fixture(options: { online?: Partial<Online> | null; known?: { lent: boo
mint: () => { minted.push("token"); return "turn-bearer"; },
active: () => true,
origin: "http://127.0.0.1:4242",
- personal: true,
- place: "My Cloud",
+ personal: options.personal ?? true,
+ place: options.place ?? "My Cloud",
here: options.here ?? here(),
});
return { lent, requests, minted };
@@ -210,6 +210,8 @@ describe("Test, and adding a server that needs the person's computer", () => {
expect(await missing.lent.place(command, { principal: "cloud-home" })).toEqual({ ok: false, error: "This command runs on the person's own computer, and no computer is lent to My Cloud now. Ask them to lend their Mac or PC with its terminal, then add it again." });
const answered = fixture({ here: here({ answers: async () => true }) });
expect(await answered.lent.place(address, { principal: "cloud-home" })).toEqual({ ok: true, server: address });
+ const server = fixture({ personal: false, place: "this server" });
+ expect(await server.lent.place(address, { principal: "cloud-home" }), "a desktop or self-hosted server runs on a computer of its own").toEqual({ ok: true, server: address });
});
it("with several lent: the one named, else the one the adder is on, else the newest for the person, else the bot asks", async () => {
diff --git a/server/lent-mcp.ts b/server/lent-mcp.ts
index 5ad7e277ef..cd65b610d6 100644
--- a/server/lent-mcp.ts
+++ b/server/lent-mcp.ts
@@ -279,6 +279,8 @@ export function createLentMcp(deps: LentMcpDeps) {
const lenders = deps.computers.mcpLenders(who.principal);
if (!(await needsTheirComputer(server, here))) return { ok: true, server };
if (!lenders.length) {
+ // Only My Cloud has no computer of its own: elsewhere the server runs on one, so a missing program is just missing.
+ if (!deps.personal) return { ok: true, server };
const remote = isRemoteMcpServer(server);
return { ok: false, error: `${remote ? "That address is" : "This command runs"} on the person's own computer, and no computer is lent to ${deps.place} now. Ask them to lend their Mac or PC${remote ? "" : " with its terminal"}, then add it again.` };
}