Skip to main content
Glama

build_prompt

Create optimized image generation prompts by specifying subject, style, lighting, camera angle, mood, color palette, and quality enhancements.

Instructions

Build an optimized prompt from subject + style/lighting/camera/mood/color/quality options

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subjectYesMain subject of the image
styleNoVisual style
lightingNoLighting type
cameraNoCamera angle
moodNoMood/atmosphere
colorNoColor palette
quality_tagsNoQuality enhancement tags

Implementation Reference

  • The handleBuildPrompt function acts as the MCP tool handler, which calls the utility function `buildPrompt` and formats the result for the MCP client.
    export function handleBuildPrompt(args: z.infer<typeof buildPromptSchema>) {
      const prompt = buildPrompt(args);
      return {
        content: [{ type: "text" as const, text: `Generated prompt:\n${prompt}` }],
      };
    }
  • The buildPrompt helper function constructs the final text prompt by assembling user input with predefined mappings.
    export function buildPrompt(options: {
      subject: string;
      style?: string;
      lighting?: string;
      camera?: string;
      mood?: string;
      color?: string;
      quality_tags?: string[];
    }): string {
      const parts: string[] = [options.subject];
    
      if (options.style && styleMappings[options.style]) {
        parts.push(styleMappings[options.style]);
      }
      if (options.lighting && lightingMappings[options.lighting]) {
        parts.push(lightingMappings[options.lighting]);
      }
      if (options.camera && cameraMappings[options.camera]) {
        parts.push(cameraMappings[options.camera]);
      }
      if (options.mood && moodMappings[options.mood]) {
        parts.push(moodMappings[options.mood]);
      }
      if (options.color && colorMappings[options.color]) {
        parts.push(colorMappings[options.color]);
      }
      if (options.quality_tags) {
        for (const tag of options.quality_tags) {
          if (qualityTagMappings[tag]) {
            parts.push(qualityTagMappings[tag]);
          }
        }
      }
    
      return parts.join(", ");
    }
  • The zod schema for the 'build_prompt' tool, defining input validation and documentation for the parameters.
    export const buildPromptSchema = z.object({
      subject: z.string().describe("Main subject of the image"),
      style: z
        .enum(Object.keys(styleMappings) as [string, ...string[]])
        .optional()
        .describe("Visual style"),
      lighting: z
        .enum(Object.keys(lightingMappings) as [string, ...string[]])
        .optional()
        .describe("Lighting type"),
      camera: z
        .enum(Object.keys(cameraMappings) as [string, ...string[]])
        .optional()
        .describe("Camera angle"),
      mood: z
        .enum(Object.keys(moodMappings) as [string, ...string[]])
        .optional()
        .describe("Mood/atmosphere"),
      color: z
        .enum(Object.keys(colorMappings) as [string, ...string[]])
        .optional()
        .describe("Color palette"),
      quality_tags: z
        .array(z.enum(Object.keys(qualityTagMappings) as [string, ...string[]]))
        .optional()
        .describe("Quality enhancement tags"),
    });

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/doctorm333/promptpilot-mcp-server'

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