get_drawing
Retrieve an Excalidraw diagram by its unique identifier to access, view, or edit the drawing within the Excalidraw MCP Server.
Instructions
Get an Excalidraw drawing by ID
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes |
Implementation Reference
- index.ts:121-127 (handler)MCP CallToolRequestSchema handler case for 'get_drawing': parses input arguments using GetDrawingSchema and delegates to drawings.getDrawing(id), then formats result as text content.
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) }], }; } - src/operations/drawings.ts:75-99 (handler)Core implementation of getDrawing: reads drawing content and metadata from storage files, returns combined object or throws not found error.
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`); } } - src/operations/drawings.ts:26-29 (schema)Zod input schema for get_drawing tool: requires 'id' as non-empty string.
export const GetDrawingSchema = z.object({ id: z.string().min(1), }); - index.ts:68-71 (registration)Tool specification registration in MCP ListToolsRequestSchema response: defines name, description, and input schema.
name: "get_drawing", description: "Get an Excalidraw drawing by ID", inputSchema: zodToJsonSchema(drawings.GetDrawingSchema), },