Skip to main content
Glama
mikeyny

Image Generation MCP Server

by mikeyny

generate-image

Create custom images from text prompts with configurable settings like aspect ratio, resolution, and output format. Save results to a specified directory.

Instructions

Generate an image based on a prompt

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aspect_ratioNo
filenameNoBase filename to save the image(s) with
go_fastNo
megapixelsNo
num_inference_stepsNo
num_outputsNo
output_dirYesFull absolute path to output directory. For Windows, use double backslashes like 'C:\\Users\\name\\path'. For Unix/Mac use '/path/to/dir'. Always use the proper path otherwise you will get an error.
output_formatNo
output_qualityNo
promptYes

Implementation Reference

  • Handler function for the 'generate-image' tool. It calls imageService.generateImages(params) and returns the JSON stringified result or error message.
    async (params) => { try { const result = await imageService.generateImages(params); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error: any) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } }
  • Zod input schema definition for the 'generate-image' tool parameters.
    { prompt: z.string(), output_dir: z.string().describe("Full absolute path to output directory. For Windows, use double backslashes like 'C:\\\\Users\\\\name\\\\path'. For Unix/Mac use '/path/to/dir'. Always use the proper path otherwise you will get an error."), filename: z.string().optional().describe("Base filename to save the image(s) with"), go_fast: z.boolean().optional(), megapixels: z.enum(["1", "2", "4"]).optional(), num_outputs: z.number().min(1).max(4).optional(), aspect_ratio: z.enum(["1:1", "4:3", "16:9"]).optional(), output_format: z.enum(["webp", "png", "jpeg"]).optional(), output_quality: z.number().min(1).max(100).optional(), num_inference_steps: z.number().min(4).max(20).optional() },
  • src/server.ts:19-52 (registration)
    Registration of the 'generate-image' tool on the MCP server using server.tool() with name, description, schema, and handler.
    server.tool( "generate-image", "Generate an image based on a prompt", { prompt: z.string(), output_dir: z.string().describe("Full absolute path to output directory. For Windows, use double backslashes like 'C:\\\\Users\\\\name\\\\path'. For Unix/Mac use '/path/to/dir'. Always use the proper path otherwise you will get an error."), filename: z.string().optional().describe("Base filename to save the image(s) with"), go_fast: z.boolean().optional(), megapixels: z.enum(["1", "2", "4"]).optional(), num_outputs: z.number().min(1).max(4).optional(), aspect_ratio: z.enum(["1:1", "4:3", "16:9"]).optional(), output_format: z.enum(["webp", "png", "jpeg"]).optional(), output_quality: z.number().min(1).max(100).optional(), num_inference_steps: z.number().min(4).max(20).optional() }, async (params) => { try { const result = await imageService.generateImages(params); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error: any) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } } );
  • TypeScript interface defining ImageGenerationParams, matching the input schema for generate-image tool.
    export interface ImageGenerationParams { prompt: string; output_dir: string; filename?: string; go_fast?: boolean; megapixels?: "1" | "2" | "4"; num_outputs?: number; aspect_ratio?: "1:1" | "4:3" | "16:9"; output_format?: "webp" | "png" | "jpeg"; output_quality?: number; num_inference_steps?: number; }

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/mikeyny/ai-image-gen-mcp'

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