update_drawing
Modify existing Excalidraw diagrams by providing new content to update specific drawings identified by their unique ID.
Instructions
Update an Excalidraw drawing by ID
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"id": "<id>",
"content": "<content>"
},
"name": "update_drawing"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ||
| content | Yes |
Implementation Reference
- src/operations/drawings.ts:102-128 (handler)Core handler function that updates the drawing content in the JSON file and updates the metadata with new timestamp.
export async function updateDrawing(id: string, content: string): Promise<{ id: string, name: string }> { await ensureStorageDir(); // Get the drawing file path const filePath = path.join(STORAGE_DIR, `${id}.json`); const metadataPath = path.join(STORAGE_DIR, `${id}.meta.json`); try { // Check if the drawing exists await fs.access(filePath); // Read the metadata const metadataStr = await fs.readFile(metadataPath, 'utf-8'); const metadata = JSON.parse(metadataStr); // Update the drawing content await fs.writeFile(filePath, content, 'utf-8'); // Update the metadata metadata.updatedAt = new Date().toISOString(); await fs.writeFile(metadataPath, JSON.stringify(metadata, null, 2), 'utf-8'); return { id, name: metadata.name }; } catch (error) { throw new ExcalidrawResourceNotFoundError(`Drawing with ID ${id} not found`); } } - index.ts:129-135 (handler)MCP server handler case that parses arguments using the schema and calls the updateDrawing function.
case "update_drawing": { const args = drawings.UpdateDrawingSchema.parse(request.params.arguments); const result = await drawings.updateDrawing(args.id, args.content); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; } - src/operations/drawings.ts:31-34 (schema)Zod schema defining the input parameters: id (string) and content (string).
export const UpdateDrawingSchema = z.object({ id: z.string().min(1), content: z.string().min(1), }); - index.ts:73-76 (registration)Tool registration in the ListTools response, including name, description, and input schema.
name: "update_drawing", description: "Update an Excalidraw drawing by ID", inputSchema: zodToJsonSchema(drawings.UpdateDrawingSchema), },