Skip to main content
Glama

get_drawing

Retrieve an Excalidraw drawing by its unique ID to access, view, or edit existing diagrams within the Excalidraw MCP Server.

Instructions

Get an Excalidraw drawing by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes

Implementation Reference

  • Implements the core logic to retrieve a drawing by ID: validates ID, reads content and metadata from storage files, handles errors.
    export async function getDrawing( id: string ): Promise<{ id: string; name: string; content: string; metadata: any }> { // Validate the ID for security validateFileId(id); await ensureStorageDir(); // Get the drawing file path const filePath = path.join(STORAGE_DIR, `${id}.json`); const metadataPath = path.join(STORAGE_DIR, `${id}.meta.json`); try { // Read the drawing content const content = await fs.readFile(filePath, "utf-8"); // Read the metadata const metadataStr = await fs.readFile(metadataPath, "utf-8"); const metadata = safeJsonParse(metadataStr, "drawing metadata"); return { id, name: metadata.name, content, metadata, }; } catch (error) { if (error instanceof ExcalidrawValidationError) { throw error; // Re-throw validation errors as-is } throw new ExcalidrawResourceNotFoundError( sanitizeErrorMessage(error, `Drawing with ID ${id} not found`) ); } }
  • Zod schema for validating input to get_drawing tool (requires 'id' string).
    export const GetDrawingSchema = z.object({ id: z.string().min(1), });
  • src/index.ts:70-74 (registration)
    Registers the 'get_drawing' tool in the MCP server with name, description, and input schema.
    { name: "get_drawing", description: "Get an Excalidraw drawing by ID", inputSchema: zodToJsonSchema(drawings.GetDrawingSchema), },
  • Dispatcher handler in main server that parses args, calls getDrawing, and formats response for MCP.
    case "get_drawing": { const args = drawings.GetDrawingSchema.parse(request.params.arguments); const result = await drawings.getDrawing(args.id); 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/andreswebs-public-images/excalidraw-mcp'

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