export_to_png
Convert Excalidraw drawings to PNG format. Customize output with quality, scale, dark mode, and background settings. Ideal for sharing or embedding high-quality visuals.
Instructions
Export an Excalidraw drawing to PNG
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| exportBackground | No | ||
| exportWithDarkMode | No | ||
| id | Yes | ||
| quality | No | ||
| scale | No |
Implementation Reference
- src/operations/export.ts:46-67 (handler)The handler function that implements the export_to_png tool logic. Fetches the drawing by ID and returns a base64-encoded PNG image (placeholder in this implementation).export async function exportToPng( id: string, quality: number = 0.92, scale: number = 1, exportWithDarkMode: boolean = false, exportBackground: boolean = true ): Promise<string> { try { // Get the drawing const drawing = await getDrawing(id); // Return the PNG content as a base64 string // Note: In a real implementation, we would use the Excalidraw API to convert the drawing to PNG // For now, we'll just return a placeholder return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=='; } catch (error) { if (error instanceof ExcalidrawResourceNotFoundError) { throw error; } throw new Error(`Failed to export drawing to PNG: ${(error as Error).message}`); } }
- src/operations/export.ts:11-17 (schema)Zod schema defining the input parameters for the export_to_png tool.export const ExportToPngSchema = z.object({ id: z.string().min(1), quality: z.number().min(0).max(1).optional().default(0.92), scale: z.number().min(0.1).max(5).optional().default(1), exportWithDarkMode: z.boolean().optional().default(false), exportBackground: z.boolean().optional().default(true), });
- index.ts:92-96 (registration)Registers the export_to_png tool in the MCP server's list of tools, including its name, description, and input schema.{ name: "export_to_png", description: "Export an Excalidraw drawing to PNG", inputSchema: zodToJsonSchema(exportOps.ExportToPngSchema), },
- index.ts:161-173 (registration)Dispatches calls to the export_to_png tool in the MCP CallToolRequest handler by parsing input and invoking the exportToPng function.case "export_to_png": { const args = exportOps.ExportToPngSchema.parse(request.params.arguments); const result = await exportOps.exportToPng( args.id, args.quality, args.scale, args.exportWithDarkMode, args.exportBackground ); return { content: [{ type: "text", text: result }], }; }