Skip to main content
Glama

asset_generate_illustration

Generate brand-locked illustrations from a textual brief. Choose external prompt or API mode to apply brand colors and style references. Output multiple images in various aspect ratios.

Instructions

Generate one or more brand-locked illustrations. Two modes (external_prompt_only / api); inline_svg is not supported — path budget too small for a composed scene. Injects brand bundle (palette, style_refs, LoRA, style_id) where supported.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
briefYes
modeNo
brand_bundleNo
countNo
aspect_ratioNo4:3
output_dirNo

Implementation Reference

  • Main handler function for asset_generate_illustration. Processes the input, resolves mode (external_prompt_only or api), generates illustrations via AI providers (Flux/Ideogram/MJ), writes PNG files, runs validation, and returns results.
    export async function generateIllustration(
      input: GenerateIllustrationInputT
    ): Promise<AssetGenerationResult> {
      const { width, height } = aspectToPixels(input.aspect_ratio);
    
      const spec = await enhancePrompt({
        brief: input.brief,
        asset_type: "illustration",
        ...(input.brand_bundle && { brand_bundle: input.brand_bundle })
      });
    
      const { mode } = resolveMode(input.mode, "illustration", spec.target_model, spec.fallback_models);
    
      if (mode === "inline_svg") {
        // Modes.ts doesn't list inline_svg for illustration, so resolveMode
        // will have already thrown if the caller asked for it. Belt-and-braces.
        throw new Error(
          "mode=inline_svg is not supported for asset_generate_illustration — path budget insufficient for a composed scene. Use external_prompt_only or api."
        );
      }
    
      if (mode === "external_prompt_only") {
        return buildExternalPromptPlan("illustration", input.brief, spec);
      }
    
      // api mode
      const chosen = chooseApiTargetOrFallback("illustration", input.brief, spec, {
        images: input.count
      });
      if (chosen.kind === "external") return chosen.plan;
      const apiModel = chosen.model;
    
      const outDir = input.output_dir ?? resolve(CONFIG.outputDir, `illustration-${Date.now()}`);
      mkdirSync(outDir, { recursive: true });
    
      const variants: Array<{
        path: string;
        format: string;
        width?: number;
        height?: number;
        bytes?: number;
      }> = [];
      const warnings: string[] = [...spec.warnings, ...chosen.warnings];
      let modelUsed = apiModel;
      let firstSeed = 0;
      let prompt_hash = "";
      let params_hash = "";
    
      for (let i = 0; i < input.count; i++) {
        const seed = (typeof spec.params["seed"] === "number" ? spec.params["seed"] : 0) + i * 1000003;
        const ck = computeCacheKey({
          model: apiModel,
          seed,
          prompt: spec.rewritten_prompt,
          params: spec.params
        });
        if (i === 0) {
          firstSeed = seed;
          prompt_hash = ck.prompt_hash;
          params_hash = ck.params_hash;
        }
    
        const gen = await generate(apiModel, {
          prompt: spec.rewritten_prompt,
          width,
          height,
          seed,
          ...(input.brand_bundle?.style_refs && { reference_images: input.brand_bundle.style_refs }),
          ...(input.brand_bundle?.style_id && { style_id: input.brand_bundle.style_id }),
          ...(input.brand_bundle?.palette && { palette: input.brand_bundle.palette }),
          ...(input.brand_bundle?.lora && { lora: input.brand_bundle.lora }),
          output_format: "png"
        });
        modelUsed = gen.model;
    
        const p = resolve(outDir, `illustration-${String(i + 1).padStart(2, "0")}.png`);
        writeFileSync(p, gen.image);
        variants.push({ path: p, format: "png", width, height, bytes: gen.image.length });
      }
    
      const validation = await tier0({
        image: Buffer.alloc(1),
        asset_type: "illustration",
        expected_width: width,
        expected_height: height,
        transparency_required: false,
        ...(input.brand_bundle && { brand_bundle: input.brand_bundle })
      });
    
      return {
        mode: "api",
        asset_type: "illustration",
        brief: input.brief,
        brand_bundle_hash: hashBundle(input.brand_bundle ?? null),
        variants,
        provenance: { model: modelUsed, seed: firstSeed, prompt_hash, params_hash },
        validations: validation,
        warnings
      };
    }
  • Helper function that converts aspect ratio strings (e.g. '4:3', '16:9') to pixel dimensions for image generation.
    function aspectToPixels(ar: string): { width: number; height: number } {
      switch (ar) {
        case "1:1":
          return { width: 1024, height: 1024 };
        case "4:3":
          return { width: 2048, height: 1536 };
        case "16:9":
          return { width: 1920, height: 1080 };
        case "2:1":
          return { width: 1600, height: 800 };
        case "3:2":
          return { width: 1500, height: 1000 };
        default:
          return { width: 2048, height: 1536 };
      }
    }
  • Zod input schema for GenerateIllustrationInput. Validates brief (min 3 chars), mode, brand_bundle, count (1-20), aspect_ratio, and output_dir.
    export const GenerateIllustrationInput = z.object({
      brief: z.string().min(3),
      mode: ModeSchema.optional(),
      brand_bundle: BrandBundleSchema.optional(),
      count: z.number().int().min(1).max(20).default(1),
      aspect_ratio: z.enum(["1:1", "4:3", "16:9", "2:1", "3:2"]).default("4:3"),
      output_dir: z.string().optional()
    });
  • Tool registration entry: defines name, description, and inputSchema for asset_generate_illustration in the MCP server tool list.
    {
      name: "asset_generate_illustration",
      description:
        "Generate one or more brand-locked illustrations. Two modes (external_prompt_only / api); inline_svg is not supported — path budget too small for a composed scene. Injects brand bundle (palette, style_refs, LoRA, style_id) where supported.",
      inputSchema: {
        type: "object",
        properties: {
          brief: { type: "string" },
          mode: {
            type: "string",
            enum: ["external_prompt_only", "api"]
          },
          brand_bundle: { type: "object" },
          count: { type: "integer", minimum: 1, maximum: 20, default: 1 },
          aspect_ratio: {
            type: "string",
            enum: ["1:1", "4:3", "16:9", "2:1", "3:2"],
            default: "4:3"
          },
          output_dir: { type: "string" }
        },
        required: ["brief"]
      },
      annotations: { openWorldHint: true }
    },
  • Case statement in the tool dispatch switch that routes 'asset_generate_illustration' to call generateIllustration() with parsed input.
    case "asset_generate_illustration":
      result = await generateIllustration(GenerateIllustrationInput.parse(args ?? {}));
      break;
Behavior3/5

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

The description discloses the brand injection behavior and the unsupported inline_svg, adding value over the openWorldHint annotation. However, it does not address auth needs, side effects, or rate limits, and the openWorldHint suggests potential mutations not fully explained.

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 concise with two front-loaded sentences, no redundant phrases, and efficiently conveys the core functionality and key constraints.

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

Completeness3/5

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

Given the lack of output schema and low schema coverage, the description covers the main purpose and modes but omits details on parameter behavior (count, aspect_ratio, output_dir) and return values. It is adequate for basic understanding but not fully self-contained.

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?

With 0% schema description coverage, the description compensates by explaining the mode parameter (two values) and brand_bundle (brand injection). However, it does not add semantics for count, aspect_ratio, or output_dir, leaving significant gaps for a 6-parameter tool.

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 verb 'Generate' and the resource 'brand-locked illustrations', and specifies two modes and brand injection. It distinguishes the tool from siblings by the brand-locking aspect and the unsupported inline_svg, making the purpose very clear.

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

Usage Guidelines3/5

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

The description mentions two modes but does not provide guidance on when to use one over the other, nor when to avoid this tool in favor of siblings like asset_generate_logo. The constraint about inline_svg is helpful but not a complete usage guideline.

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/MohamedAbdallah-14/prompt-to-asset'

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