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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves data ('Get'), implying a read-only operation, but doesn't clarify if it requires specific permissions, has rate limits, or what happens if the canvas is empty. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior and constraints.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence that efficiently conveys the tool's function without unnecessary words. It is front-loaded with the core action and resource, making it easy to parse. Every part of the sentence earns its place by specifying the data format (JSON), which is crucial for differentiation.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is adequate but has gaps. It explains what the tool does but lacks details on behavioral aspects like error handling or return structure. Without an output schema, the agent doesn't know the JSON format specifics, which could be important for integration. The description is minimal but functional for a basic read operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters with 100% schema description coverage, so the schema fully documents the lack of inputs. The description doesn't need to add parameter details, as there are none to explain. It appropriately focuses on the tool's purpose without redundant information, meeting the baseline for zero parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and resource ('current pixel data of the drawing canvas as JSON'), making the purpose immediately understandable. It distinguishes from siblings like drawing_getCanvasPng by specifying JSON format, but doesn't fully differentiate from drawing_generateCanvas which might also retrieve canvas data. The description is specific but not exhaustive about sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives like drawing_getCanvasPng or drawing_generateCanvas is provided. The description implies it's for retrieving pixel data in JSON format, but doesn't specify use cases, prerequisites, or exclusions. Without annotations or context signals indicating limitations, the agent must infer usage from the tool name and description alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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