export_to_json
Export an Excalidraw drawing to JSON format for data transfer, storage, or integration with other applications.
Instructions
Export an Excalidraw drawing to JSON
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"id": "<id>"
},
"name": "export_to_json"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes |
Implementation Reference
- src/operations/export.ts:81-99 (handler)The handler function that exports a drawing by ID to JSON format by retrieving the drawing content after validation.
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 the export_to_json tool: requires a string 'id'.
export const ExportToJsonSchema = z.object({ id: z.string().min(1), }); - src/index.ts:100-104 (registration)Registration of the export_to_json tool in the server's listTools response, including name, description, and schema.
{ name: "export_to_json", description: "Export an Excalidraw drawing to JSON", inputSchema: zodToJsonSchema(exportOps.ExportToJsonSchema), }, - src/index.ts:192-200 (registration)Dispatch case in the callTool handler that parses arguments using the schema and invokes the exportToJson handler.
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 }], }; }