export_to_svg
Convert Excalidraw drawings to SVG format for scalable vector graphics that maintain quality at any size.
Instructions
Export an Excalidraw drawing to SVG
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_svg"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes |
Implementation Reference
- src/operations/export.ts:26-48 (handler)The core handler function that executes the export_to_svg tool logic: validates ID, fetches drawing, generates placeholder SVG, handles errors.
export async function exportToSvg(id: string): Promise<string> { // Validate the ID for security validateFileId(id); 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( sanitizeErrorMessage(error, "Failed to export drawing to SVG") ); } - src/operations/export.ts:7-9 (schema)Zod schema for input validation of the export_to_svg tool, requiring a non-empty string 'id'.
export const ExportToSvgSchema = z.object({ id: z.string().min(1), }); - src/index.ts:90-94 (registration)Tool registration entry in the listTools handler, defining name, description, and input schema for export_to_svg.
{ name: "export_to_svg", description: "Export an Excalidraw drawing to SVG", inputSchema: zodToJsonSchema(exportOps.ExportToSvgSchema), }, - src/index.ts:166-174 (handler)Dispatch logic in the CallToolRequestSchema handler that parses arguments, calls the exportToSvg function, and formats the response.
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 }], }; }