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:
+3
-2
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user