From fe4bf8e787306d40112f6cd164b522c71b67ee0b Mon Sep 17 00:00:00 2001 From: Scott Friedman <3011922+scttfrdmn@users.noreply.github.com> Date: Sat, 3 Jan 2026 20:18:11 -0800 Subject: [PATCH] Fix: Batch endpoint now respects element IDs from MCP server The batch creation endpoint was always generating new IDs, ignoring IDs passed from the MCP server. This caused sync issues where the MCP server would think elements were created with specific IDs, but the canvas had different IDs. This fix makes the batch endpoint behave like the single element endpoint: it now respects passed IDs (for MCP sync) or generates new ones if not provided. Fixes the 'MCP tool registration issues' mentioned in the roadmap. --- src/server.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/server.ts b/src/server.ts index 747c51e..c3abc2d 100644 --- a/src/server.ts +++ b/src/server.ts @@ -365,7 +365,8 @@ app.post('/api/elements/batch', (req: Request, res: Response) => { elementsToCreate.forEach(elementData => { const params = CreateElementSchema.parse(elementData); - const id = generateId(); + // Prioritize passed ID (for MCP sync), otherwise generate new ID + const id = params.id || generateId(); const element: ServerElement = { id, ...params, @@ -373,7 +374,7 @@ app.post('/api/elements/batch', (req: Request, res: Response) => { updatedAt: new Date().toISOString(), version: 1 }; - + elements.set(id, element); createdElements.push(element); });