delete_drawing
Remove a specific Excalidraw drawing by its ID using the Excalidraw MCP Server. This tool simplifies drawing management by allowing users to delete unwanted or outdated diagrams efficiently.
Instructions
Delete an Excalidraw drawing by ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes |
Implementation Reference
- src/operations/drawings.ts:131-150 (handler)The core handler function that deletes the drawing files (content and metadata) for the given ID from the storage directory.export async function deleteDrawing(id: string): Promise<void> { 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); // Delete the drawing file await fs.unlink(filePath); // Delete the metadata file await fs.unlink(metadataPath); } catch (error) { throw new ExcalidrawResourceNotFoundError(`Drawing with ID ${id} not found`); } }
- src/operations/drawings.ts:37-39 (schema)Zod schema for validating the input to the delete_drawing tool, requiring an 'id' string.export const DeleteDrawingSchema = z.object({ id: z.string().min(1), });
- index.ts:78-81 (registration)Tool registration in the listTools handler, defining name, description, and input schema.name: "delete_drawing", description: "Delete an Excalidraw drawing by ID", inputSchema: zodToJsonSchema(drawings.DeleteDrawingSchema), },
- index.ts:137-143 (handler)Dispatcher handler in the main switch statement that parses arguments and calls the deleteDrawing function.case "delete_drawing": { const args = drawings.DeleteDrawingSchema.parse(request.params.arguments); await drawings.deleteDrawing(args.id); return { content: [{ type: "text", text: JSON.stringify({ success: true }, null, 2) }], }; }