Skip to main content
Glama

drawing_generateCanvas

Create a customizable drawing canvas by specifying width and height in pixels for use in AI-assisted painting projects.

Instructions

Generate a new drawing canvas with specified width and height.

Input Schema

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

Implementation Reference

  • index.ts:87-105 (handler)
    MCP tool handler for 'drawing_generateCanvas' that calls the generateCanvas helper and manages canvas state.
    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, }; }
  • Input schema for the drawing_generateCanvas tool defining required width and height parameters.
    { 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"], }, },
  • index.ts:290-292 (registration)
    Registration of the CallToolRequestSchema dispatcher that routes to the tool handler.
    server.setRequestHandler(CallToolRequestSchema, async (request) => handleToolCall(request.params.name, request.params.arguments ?? {}) );
  • Helper function implementing canvas generation by instantiating Canvas class.
    function generateCanvas(width: number, height: number): Canvas { return new Canvas(width, height); }
  • Canvas class constructor that initializes pixel array with white background.
    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 }; } }

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