Skip to main content
Glama

create_drawing

Create a new Excalidraw drawing by specifying a name and content to generate diagrams in formats like SVG, PNG, or JSON.

Instructions

Create a new Excalidraw drawing

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
contentYes

Implementation Reference

  • The core handler function that implements the create_drawing tool logic: generates a unique ID, saves the drawing content and metadata to JSON files in storage directory, 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 };
    }
  • Zod schema defining the input for create_drawing: name and content strings.
    export const CreateDrawingSchema = z.object({
      name: z.string().min(1),
      content: z.string().min(1),
    });
  • index.ts:63-66 (registration)
    Registration of the create_drawing tool in the MCP server's tool list, including name, description, and input schema.
      name: "create_drawing",
      description: "Create a new Excalidraw drawing",
      inputSchema: zodToJsonSchema(drawings.CreateDrawingSchema),
    },
  • MCP server dispatch handler for create_drawing: parses arguments using the schema and delegates to the createDrawing implementation.
    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) }],
      };
    }

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/i-tozer/excalidraw-mcp'

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