feat: make MCP server registrations persistent across peer disconnects
Persistent MCP servers (opt-in via `persistent: true`) survive host disconnects — they appear as offline in mcp_list and auto-restore when the host reconnects. Ephemeral servers (default) still clean up on disconnect. Offline servers return a clear error on mcp_call with time-since-disconnect info. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -931,6 +931,7 @@ export class BrokerClient {
|
||||
serverName: string,
|
||||
description: string,
|
||||
tools: Array<{ name: string; description: string; inputSchema: Record<string, unknown> }>,
|
||||
persistent?: boolean,
|
||||
): Promise<{ serverName: string; toolCount: number } | null> {
|
||||
if (!this.ws || this.ws.readyState !== this.ws.OPEN) return null;
|
||||
return new Promise((resolve) => {
|
||||
@@ -938,7 +939,7 @@ export class BrokerClient {
|
||||
this.mcpRegisterResolvers.set(reqId, { resolve, timer: setTimeout(() => {
|
||||
if (this.mcpRegisterResolvers.delete(reqId)) resolve(null);
|
||||
}, 5_000) });
|
||||
this.ws!.send(JSON.stringify({ type: "mcp_register", serverName, description, tools, _reqId: reqId }));
|
||||
this.ws!.send(JSON.stringify({ type: "mcp_register", serverName, description, tools, ...(persistent ? { persistent: true } : {}), _reqId: reqId }));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user