import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
import type { WorkbenchClient } from "../workbench/client.js";
export function registerWbReload(server: McpServer, client: WorkbenchClient): void {
server.registerTool(
"wb_reload",
{
description:
"Reload scripts or plugins in the Workbench. Use after editing .c script files or Workbench plugins to pick up changes without restarting.",
inputSchema: {
target: z
.enum(["scripts", "plugins", "both"])
.default("scripts")
.describe("What to reload: scripts, plugins, or both"),
},
},
async ({ target }) => {
try {
const result = await client.call<Record<string, unknown>>("EMCP_WB_Reload", { target });
return {
content: [
{
type: "text" as const,
text: `**Reload Complete**\n\n${result.message || "Reload triggered."}`,
},
],
};
} catch (e) {
const msg = e instanceof Error ? e.message : String(e);
return {
content: [{ type: "text" as const, text: `Error reloading: ${msg}` }],
};
}
}
);
}