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.
This commit is contained in:
Scott Friedman
2026-01-25 00:29:37 +08:00
committed by yctimlin
parent 381bc98bff
commit fe4bf8e787
+2 -1
View File
@@ -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,