export_to_json
Export an Excalidraw drawing 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:81-99 (handler)The core handler function that validates the drawing ID, fetches the drawing using getDrawing, and returns its JSON content. Handles errors appropriately.export async function exportToJson(id: string): Promise<string> { // Validate the ID for security validateFileId(id); 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( sanitizeErrorMessage(error, "Failed to export drawing to JSON") ); } }
- src/operations/export.ts:21-23 (schema)Zod schema defining the input for export_to_json: requires a non-empty string 'id'.export const ExportToJsonSchema = z.object({ id: z.string().min(1), });
- src/index.ts:100-104 (registration)Tool registration in the listTools response, specifying name, description, and input schema.{ name: "export_to_json", description: "Export an Excalidraw drawing to JSON", inputSchema: zodToJsonSchema(exportOps.ExportToJsonSchema), },
- src/index.ts:192-200 (handler)Dispatcher in the CallToolRequestSchema handler that parses arguments using the schema and calls the exportToJson function, returning the result as text content.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 }], }; }