create_drawing
Create a new Excalidraw drawing by providing a name and content. Generate diagrams and visual representations for documentation, planning, or communication purposes.
Instructions
Create a new Excalidraw drawing
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | ||
| name | Yes |
Implementation Reference
- src/operations/drawings.ts:63-90 (handler)The primary handler function that executes the create_drawing tool logic: generates a unique ID, saves the drawing content to a JSON file, creates metadata, and returns the ID and name.export async function createDrawing( name: string, content: string ): Promise<{ id: string; name: string }> { await ensureStorageDir(); // Generate a unique ID for the drawing const id = `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`; // Create the drawing file const filePath = path.join(STORAGE_DIR, `${id}.json`); // Save the drawing content await fs.writeFile(filePath, content, "utf-8"); // Create a metadata file for the drawing const metadataPath = path.join(STORAGE_DIR, `${id}.meta.json`); const metadata = { id, name, createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(), }; await fs.writeFile(metadataPath, JSON.stringify(metadata, null, 2), "utf-8"); return { id, name }; }
- src/operations/drawings.ts:35-38 (schema)Zod schema for validating input parameters (name and content) of the create_drawing tool.export const CreateDrawingSchema = z.object({ name: z.string().min(1), content: z.string().min(1), });
- src/index.ts:65-69 (registration)Tool registration in the ListTools response, defining name, description, and input schema.{ name: "create_drawing", description: "Create a new Excalidraw drawing", inputSchema: zodToJsonSchema(drawings.CreateDrawingSchema), },
- src/index.ts:116-124 (registration)Dispatch handler in CallToolRequestSchema that parses arguments and invokes the createDrawing function.case "create_drawing": { const args = drawings.CreateDrawingSchema.parse( request.params.arguments ); const result = await drawings.createDrawing(args.name, args.content); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }