get_drawing
Retrieve an Excalidraw drawing by its unique ID for viewing, editing, or exporting to formats like SVG, PNG, or JSON.
Instructions
Get an Excalidraw drawing by ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes |
Implementation Reference
- index.ts:121-127 (handler)Handler logic for the 'get_drawing' tool in the switch statement of CallToolRequestSchema. Parses arguments using GetDrawingSchema and calls drawings.getDrawing to fetch the drawing.case "get_drawing": { const args = drawings.GetDrawingSchema.parse(request.params.arguments); const result = await drawings.getDrawing(args.id); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }
- index.ts:68-71 (registration)Tool registration in the ListTools response, defining name, description, and input schema for 'get_drawing'.name: "get_drawing", description: "Get an Excalidraw drawing by ID", inputSchema: zodToJsonSchema(drawings.GetDrawingSchema), },
- src/operations/drawings.ts:26-28 (schema)Zod schema for input validation of the 'get_drawing' tool, requiring an 'id' string.export const GetDrawingSchema = z.object({ id: z.string().min(1), });
- src/operations/drawings.ts:75-99 (helper)Core helper function that implements the logic to retrieve a drawing by ID from storage files, reading content and metadata.export async function getDrawing(id: string): Promise<{ id: string, name: string, content: string, metadata: any }> { 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 { // Read the drawing content const content = await fs.readFile(filePath, 'utf-8'); // Read the metadata const metadataStr = await fs.readFile(metadataPath, 'utf-8'); const metadata = JSON.parse(metadataStr); return { id, name: metadata.name, content, metadata, }; } catch (error) { throw new ExcalidrawResourceNotFoundError(`Drawing with ID ${id} not found`); } }