Skip to content

AI-native design editor. Open-source Figma alternative.

fix(mcp): add save_file tool and fix stale dist imports

Danila Poyarkov7e7036b4229f
diff --git a/packages/mcp/src/server.ts b/packages/mcp/src/server.ts
index 423280309..e158f3b75 100644
--- a/packages/mcp/src/server.ts
+++ b/packages/mcp/src/server.ts
@@ -310,6 +310,25 @@ export function startServer(options: ServerOptions = {}) {
)
}
+ register(
+ 'save_file',
+ {
+ description:
+ 'Save the current document to disk. Uses the existing file path if available, otherwise prompts for a location.',
+ inputSchema: z.object({})
+ },
+ async () => {
+ try {
+ const result = await sendToBrowser({ command: 'save_file' })
+ const res = result as { ok?: boolean; error?: string }
+ if (res.ok === false) return fail(new Error(res.error))
+ return ok({ saved: true })
+ } catch (e) {
+ return fail(e)
+ }
+ }
+ )
+
register(
'get_codegen_prompt',
{
diff --git a/src/automation/server.ts b/src/automation/server.ts
index d2846b492..b47dc14a8 100644
--- a/src/automation/server.ts
+++ b/src/automation/server.ts
@@ -120,13 +120,20 @@ export function connectAutomation(getStore: () => EditorStore, authToken: string
return { ok: true, result: { jsx } }
}
+ async function handleSaveFile(store: EditorStore): Promise<unknown> {
+ await store.saveFigFile()
+ return { ok: true }
+ }
+
const commandHandlers: Partial<
Record<string, (store: EditorStore, args: unknown) => Promise<unknown>>
> = {
eval: handleEval,
tool: handleTool,
export: handleExport,
- export_jsx: handleExportJsx
+ export_jsx: handleExportJsx,
+
+ save_file: handleSaveFile
}
async function handleRequest(_id: string, command: string, args: unknown): Promise<unknown> {