get_drawing
Retrieve an Excalidraw drawing by its unique ID to access, view, or edit existing diagrams within the Excalidraw MCP Server.
Instructions
Get an Excalidraw drawing by ID
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes |
Implementation Reference
- src/operations/drawings.ts:93-127 (handler)Implements the core logic to retrieve a drawing by ID: validates ID, reads content and metadata from storage files, handles errors.
export async function getDrawing( id: string ): Promise<{ id: string; name: string; content: string; metadata: any }> { // Validate the ID for security validateFileId(id); 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 = safeJsonParse(metadataStr, "drawing metadata"); return { id, name: metadata.name, content, metadata, }; } catch (error) { if (error instanceof ExcalidrawValidationError) { throw error; // Re-throw validation errors as-is } throw new ExcalidrawResourceNotFoundError( sanitizeErrorMessage(error, `Drawing with ID ${id} not found`) ); } } - src/operations/drawings.ts:41-43 (schema)Zod schema for validating input to get_drawing tool (requires 'id' string).
export const GetDrawingSchema = z.object({ id: z.string().min(1), }); - src/index.ts:70-74 (registration)Registers the 'get_drawing' tool in the MCP server with name, description, and input schema.
{ name: "get_drawing", description: "Get an Excalidraw drawing by ID", inputSchema: zodToJsonSchema(drawings.GetDrawingSchema), }, - src/index.ts:126-132 (handler)Dispatcher handler in main server that parses args, calls getDrawing, and formats response for MCP.
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) }], }; }