Skip to main content
Glama

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
NameRequiredDescriptionDefault
idYes

Implementation Reference

  • 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") ); } }
  • 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), },
  • 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 }], }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/andreswebs-public-images/excalidraw-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server