Skip to main content
Glama

drawing_getCanvasData

Retrieve the pixel data of the drawing canvas as JSON for analysis or further processing using the mcp-painter server.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Executes the drawing_getCanvasData tool: checks for existing canvas, calls drawingTool.getCanvasData to retrieve pixel data, returns it as formatted JSON text or error.
    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, }; }
  • index.ts:68-76 (registration)
    Registers the drawing_getCanvasData tool in the TOOLS array with 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: [], }, },
  • Input schema definition for the tool: empty object with no required properties.
    inputSchema: { type: "object", properties: {}, // No input needed to get canvas data required: [], },
  • Helper function that validates the Canvas instance and returns its pixel data by delegating to the class 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(); }
  • Core Canvas class method that directly returns the 2D pixels array, implementing the pixel data retrieval logic.
    getCanvasData(): Pixel[][] { // Renamed from getCanvas to getCanvasData for clarity return this.pixels; }

Other Tools

Related Tools

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