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 };
                }
            }
        }

Tool Definition Quality

Score is being calculated. Check back soon.

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