Skip to main content
Glama

Create image variation

create_variation

Generate variations of a source image using DALL·E 2. Provide a PNG image path to create multiple altered versions, saved locally with returned file paths.

Instructions

Generate variations of an existing image using DALL·E 2 (the only model that supports variations). Results are saved to disk and file paths are returned.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYesAbsolute path to the source image (PNG, square, <4MB).
nNoNumber of variations to generate (default 1).
sizeNoOutput size. Default 1024x1024.
userNo
output_dirNo
filename_prefixNo
return_image_contentNo

Implementation Reference

  • The registerVariationTool function registers the 'create_variation' tool on the MCP server. The handler reads the source image as an upload, calls OpenAI's images.createVariation API with model 'dall-e-2', saves the resulting images to disk, and returns file paths (and optionally inline image content).
    export function registerVariationTool(server: McpServer): void {
      server.registerTool(
        "create_variation",
        {
          title: "Create image variation",
          description:
            "Generate variations of an existing image using DALL·E 2 (the only model that supports variations). Results are saved to disk and file paths are returned.",
          inputSchema,
        },
        async (args) => {
          try {
            const upload = await readImageAsUpload(args.image);
            const params: ImageCreateVariationParams = {
              model: "dall-e-2",
              image: upload,
              response_format: "b64_json",
            };
            if (args.n !== undefined) params.n = args.n;
            if (args.size) params.size = args.size;
            if (args.user) params.user = args.user;
    
            const client = getOpenAI();
            const response = await client.images.createVariation(params);
            const items = response.data ?? [];
            if (items.length === 0) {
              return errorContent(new Error("OpenAI returned no images."));
            }
    
            const outDir = resolveOutputDir(args.output_dir);
            const seed = `${Date.now()}_variation_${args.image}`;
            const saved = await Promise.all(
              items.map(async (item, i) => {
                const extracted = await extractImage(item, "png");
                return saveImage(extracted, outDir, args.filename_prefix ?? "variation", seed, i);
              }),
            );
    
            const summary = [
              `Generated ${saved.length} variation${saved.length === 1 ? "" : "s"} of ${args.image} with dall-e-2.`,
              `Saved to: ${outDir}`,
              "",
              ...saved.map((s, i) => `  [${i}] ${s.path} (${s.mime}, ${s.bytes} bytes)`),
            ].join("\n");
    
            return {
              content: buildContent(summary, saved, args.return_image_content === true),
            };
          } catch (err) {
            return errorContent(err);
          }
        },
      );
    }
  • Zod schema definitions for the 'create_variation' tool inputs: image (required absolute path), n (1-10 optional), size (256x256|512x512|1024x1024 optional), user (optional string), output_dir (optional), filename_prefix (optional), return_image_content (optional boolean).
    const inputSchema = {
      image: z.string().describe("Absolute path to the source image (PNG, square, <4MB)."),
      n: z.number().int().min(1).max(10).optional().describe("Number of variations to generate (default 1)."),
      size: z
        .enum(["256x256", "512x512", "1024x1024"])
        .optional()
        .describe("Output size. Default 1024x1024."),
      user: z.string().optional(),
      output_dir: z.string().optional(),
      filename_prefix: z.string().optional(),
      return_image_content: z.boolean().optional(),
    };
  • src/server.ts:22-22 (registration)
    Registration of the 'create_variation' tool by calling registerVariationTool(server) during server creation.
    registerVariationTool(server);
  • The tool name 'create_variation' is registered via server.registerTool('create_variation', ...).
    server.registerTool(
      "create_variation",
      {
  • Model definition for dall-e-2 showing supportsVariation: true, confirming dall-e-2 is the only model that supports the variation feature.
    supportsVariation: true,
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It discloses that results are saved to disk and file paths are returned, but does not cover potential side effects, error conditions, or rate limits. Adequate but not thorough.

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?

Two sentences deliver key information efficiently with no filler. Front-loaded with the primary verb and resource, making it easy to parse.

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

Completeness4/5

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

Given no output schema, the description mentions file paths returned, covering the essential output. With 7 parameters and no annotations, it could elaborate on return format or usage of optional parameters, but is largely sufficient for a simple generation tool.

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 coverage is 43%, with only image and size having descriptions. The description adds context that results are saved to disk, implying output_dir and filename_prefix usage, but does not fully explain user or return_image_content. Partially compensates for gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool generates variations of an existing image using DALL·E 2, specifying the resource and action. It distinguishes from siblings like generate_image and edit_image by highlighting the model and purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly mentions using DALL·E 2 as the only model supporting variations, guiding when to use this tool. It lacks explicit when-not-to-use or alternative tools, but provides clear context for appropriate use.

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/sam-david/openai-images-mcp'

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