Skip to main content
Glama
sammyl720

Image Generator MCP Server

by sammyl720

generate_image

Create custom images from text descriptions using AI, saving them to your specified directory with a chosen filename.

Instructions

Generate an image from a prompt.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesA prompt detailing what image to generate.
imageNameYesThe filename for the image excluding any extensions.

Implementation Reference

  • Core handler function that generates the image using OpenAI DALL-E 3 API and returns base64 encoded image.
    async generateImage(prompt: string, size: ImageGenerateParams['size'] = "1024x1024") {
        const response = await this.openai.images.generate({
            model: IMAGE_MODEL,
            prompt,
            size,
            response_format: 'b64_json'
        });
        return response.data[0].b64_json;
    }
  • MCP CallToolRequestSchema handler specifically for 'generate_image': validates args, calls ImageGenerator, saves image file, returns resource URI.
    if (request.params.name !== "generate_image") {
      throw new McpError(
        ErrorCode.MethodNotFound,
        `Unknown tool: ${request.params.name}`
      );
    }
    
    if (!isValidImageGenerationArgs(request.params.arguments)) {
      throw new McpError(
        ErrorCode.InvalidParams,
        "Invalid image generation arguments"
      )
    };
    
    const { prompt, imageName } = request.params.arguments;
    const base64 = await new ImageGenerator().generateImage(prompt);
    const fileName = `${imageName.replace(/\..*$/, '')}.png`;
    const filepath = await imageSaver.saveBase64(fileName, base64!);
    
    return {
      toolResult: {
        uri: `file://${filepath}`,
        type: 'image',
        mimeType: 'image/png'
      }
    }
  • src/index.ts:53-71 (registration)
    Tool registration in ListToolsRequestSchema handler, including name, description, and input schema.
      tools: [{
        name: "generate_image",
        description: "Generate an image from a prompt.",
        inputSchema: {
          type: "object",
          properties: {
            prompt: {
              type: "string",
              description: "A prompt detailing what image to generate."
            },
            imageName: {
              type: "string",
              description: "The filename for the image excluding any extensions."
            }
          },
          required: ["prompt", "imageName"]
        }
      }]
    })
  • Validation function for generate_image input arguments matching the schema.
    export function isValidImageGenerationArgs(args: any): args is ImageGenerationRequestParams {
        return typeof args === "object" &&
            args !== null &&
            "prompt" in args &&
            typeof args.prompt === 'string' &&
            "imageName" in args &&
            typeof args.imageName === 'string';  
    }
  • TypeScript interface defining the input parameters for generate_image tool.
    export interface ImageGenerationRequestParams {
        prompt: string;
        imageName: string;
    }
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 mentions generation but doesn't describe side effects (e.g., file creation, rate limits, permissions needed, or output format). For a tool that likely creates files, this lack of detail is a significant gap.

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 extremely concise with a single sentence that directly states the tool's function. It is front-loaded and wastes no words, making it easy to parse quickly. Every word earns its place.

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?

Given the tool's complexity (image generation likely involves file creation and AI processing), no annotations, and no output schema, the description is incomplete. It lacks details on behavioral traits, output handling, and usage context, leaving significant gaps for an AI agent to understand how to invoke it correctly.

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?

Schema description coverage is 100%, so the schema already documents both parameters ('prompt' and 'imageName') adequately. The description adds no additional meaning beyond what the schema provides, such as prompt formatting tips or filename conventions. Baseline 3 is appropriate when schema does 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 tool's purpose with a specific verb ('generate') and resource ('image'), and specifies the input mechanism ('from a prompt'). It doesn't need sibling differentiation since there are no sibling tools. However, it could be more specific about the type of image generation (e.g., AI model, format).

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, prerequisites, or constraints. It simply states what the tool does without context about appropriate use cases or limitations. With no sibling tools, this is less critical but still a gap.

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/sammyl720/image-generator-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server