Skip to main content
Glama

drawing_getCanvasData

Extract current canvas pixel data as JSON to analyze or process drawing content programmatically.

Instructions

Get the current pixel data of the drawing canvas as JSON.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The tool handler case in handleToolCall function: checks for existing canvas, calls drawingTool.getCanvasData, stringifies and returns as text content.
    case "drawing_getCanvasData": if (!currentCanvas) { return { content: [{ type: "text", text: "Error: No canvas generated. Please use 'drawing_generateCanvas' first.", }], isError: true, }; } try { const canvasData = drawingTool.getCanvasData(currentCanvas); // Use getCanvasData // Return canvas data as JSON text content return { content: [{ type: "text", text: JSON.stringify(canvasData, null, 2), // Stringify for readable JSON }], isError: false, }; } catch (error) { return { content: [{ type: "text", text: `Failed to get canvas data: ${(error as Error).message}`, }], isError: true, }; }
  • Tool schema definition in TOOLS array: name, description, and empty input schema.
    { name: "drawing_getCanvasData", description: "Get the current pixel data of the drawing canvas as JSON.", inputSchema: { type: "object", properties: {}, // No input needed to get canvas data required: [], }, },
  • Exported getCanvasData function: validates Canvas instance and delegates to its getCanvasData method.
    function getCanvasData(canvas: Canvas): Pixel[][] { // Exporting getCanvasData instead of getCanvas if (!(canvas instanceof Canvas)) { throw new Error("Invalid canvas object provided."); } return canvas.getCanvasData(); }
  • Canvas class getCanvasData method: returns the internal 2D pixels array.
    getCanvasData(): Pixel[][] { // Renamed from getCanvas to getCanvasData for clarity return this.pixels; }

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/flrngel/mcp-painter'

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