export_to_svg
Convert Excalidraw drawings to SVG format for scalable vector graphics output.
Instructions
Export an Excalidraw drawing to SVG
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes |
Implementation Reference
- src/operations/export.ts:25-43 (handler)Core handler function that executes the export_to_svg tool logic: fetches the drawing by ID and generates SVG output.export async function exportToSvg(id: string): Promise<string> { try { // Get the drawing const drawing = await getDrawing(id); // Return the SVG content // Note: In a real implementation, we would use the Excalidraw API to convert the drawing to SVG // For now, we'll just return a placeholder return `<svg> <text x="10" y="20">Drawing: ${drawing.name}</text> <text x="10" y="40">This is a placeholder for the SVG export.</text> </svg>`; } catch (error) { if (error instanceof ExcalidrawResourceNotFoundError) { throw error; } throw new Error(`Failed to export drawing to SVG: ${(error as Error).message}`); } }
- src/operations/export.ts:6-8 (schema)Input schema validation for the export_to_svg tool using Zod.export const ExportToSvgSchema = z.object({ id: z.string().min(1), });
- index.ts:87-91 (registration)Tool registration in the MCP server's listTools response, defining name, description, and schema.{ name: "export_to_svg", description: "Export an Excalidraw drawing to SVG", inputSchema: zodToJsonSchema(exportOps.ExportToSvgSchema), },
- index.ts:153-159 (handler)MCP server request handler that parses arguments and delegates to the exportToSvg implementation.case "export_to_svg": { const args = exportOps.ExportToSvgSchema.parse(request.params.arguments); const result = await exportOps.exportToSvg(args.id); return { content: [{ type: "text", text: result }], }; }