export_to_json
Export Excalidraw drawings to JSON format for data storage, sharing, or integration with other applications.
Instructions
Export an Excalidraw drawing to JSON
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes |
Implementation Reference
- src/operations/export.ts:70-83 (handler)Core handler function that exports a drawing to JSON by retrieving the drawing content via getDrawing(id) and returning it as a string.export async function exportToJson(id: string): Promise<string> { try { // Get the drawing const drawing = await getDrawing(id); // Return the JSON content return drawing.content; } catch (error) { if (error instanceof ExcalidrawResourceNotFoundError) { throw error; } throw new Error(`Failed to export drawing to JSON: ${(error as Error).message}`); } }
- src/operations/export.ts:20-22 (schema)Zod input schema for the export_to_json tool, requiring a string 'id'.export const ExportToJsonSchema = z.object({ id: z.string().min(1), });
- index.ts:97-101 (registration)Registers the export_to_json tool in the listTools response with name, description, and schema reference.{ name: "export_to_json", description: "Export an Excalidraw drawing to JSON", inputSchema: zodToJsonSchema(exportOps.ExportToJsonSchema), },
- index.ts:175-181 (handler)MCP server handler for calling the export_to_json tool: parses arguments, invokes exportToJson, and formats response.case "export_to_json": { const args = exportOps.ExportToJsonSchema.parse(request.params.arguments); const result = await exportOps.exportToJson(args.id); return { content: [{ type: "text", text: result }], }; }