Skip to main content
Glama

drawing_generateCanvas

Create a new drawing canvas by specifying width and height in pixels for digital artwork or diagrams.

Instructions

Generate a new drawing canvas with specified width and height.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
widthYesWidth of the canvas in pixels
heightYesHeight of the canvas in pixels

Implementation Reference

  • index.ts:87-105 (handler)
    MCP tool handler case that processes the drawing_generateCanvas tool call, invokes the generateCanvas helper, and returns success/error response.
    case "drawing_generateCanvas":
      try {
        currentCanvas = drawingTool.generateCanvas(args.width, args.height);
        return {
          content: [{
            type: "text",
            text: `Canvas generated with width: ${args.width}, height: ${args.height}`,
          }],
          isError: false,
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: `Failed to generate canvas: ${(error as Error).message}`,
          }],
          isError: true,
        };
      }
  • Core helper function that creates and returns a new Canvas instance with the specified dimensions.
    function generateCanvas(width: number, height: number): Canvas {
        return new Canvas(width, height);
    }
  • index.ts:22-33 (registration)
    Tool registration object in the TOOLS array used for ListToolsRequest, includes name, description, and input schema.
    {
      name: "drawing_generateCanvas",
      description: "Generate a new drawing canvas with specified width and height.",
      inputSchema: {
        type: "object",
        properties: {
          width: { type: "number", description: "Width of the canvas in pixels" },
          height: { type: "number", description: "Height of the canvas in pixels" },
        },
        required: ["width", "height"],
      },
    },
  • Canvas class definition with constructor that initializes pixel array to white background, used by generateCanvas.
    class Canvas {
        width: number;
        height: number;
        pixels: Pixel[][];
    
        constructor(width: number, height: number) {
            if (typeof width !== 'number' || width <= 0 || typeof height !== 'number' || height <= 0) {
                throw new Error("Canvas dimensions must be positive numbers.");
            }
            this.width = width;
            this.height = height;
            this.pixels = [];
            for (let y = 0; y < height; y++) {
                this.pixels[y] = [];
                for (let x = 0; x < width; x++) {
                    // Default to white background
                    this.pixels[y][x] = { r: 255, g: 255, b: 255, a: 255 };
                }
            }
        }
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 generates a canvas but lacks details on side effects (e.g., if it overwrites existing canvases, requires specific permissions, or has rate limits). This leaves significant gaps for a creation tool with no structured safety hints.

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, efficient sentence that directly states the tool's purpose and parameters without unnecessary words. It is front-loaded and appropriately sized for its simple function.

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

Completeness2/5

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

For a creation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what the tool returns (e.g., a canvas ID or status), potential errors, or how it interacts with sibling tools. Given the complexity of a generative operation, more context is needed for effective use.

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

Parameters3/5

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

The schema description coverage is 100%, with both parameters (width and height) clearly documented in the schema. The description adds no additional meaning beyond implying these parameters are required, which is already covered by the schema's required fields. Baseline 3 is appropriate as the schema handles the heavy lifting.

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 verb ('Generate') and resource ('a new drawing canvas'), making the purpose understandable. However, it doesn't explicitly differentiate this tool from its siblings (e.g., drawing_getCanvasData, drawing_getCanvasPng), which also involve canvas operations but for retrieval rather than creation.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, such as needing an existing canvas for sibling tools, or specify contexts where generating a canvas is appropriate (e.g., initialization vs. modification).

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