Skip to main content
Glama
RamboRogers

FAL Image/Video MCP Server

by RamboRogers

flux_kontext

Generate images with precise prompt adherence and typography control using the FLUX Kontext Pro model through the FAL Image/Video MCP Server.

Instructions

FLUX Kontext Pro - State-of-the-art prompt adherence and typography

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesText prompt for image generation
image_sizeNolandscape_4_3
num_imagesNo
num_inference_stepsNo
guidance_scaleNo

Implementation Reference

  • Core handler function for flux_kontext (image generation model). Prepares parameters (including flux-specific steps/guidance), calls fal.subscribe on the specific endpoint, processes images with download/dataUrl/autoopen, and returns formatted result.
    private async handleImageGeneration(args: any, model: any) {
      const {
        prompt,
        image_size = 'landscape_4_3',
        num_inference_steps = 25,
        guidance_scale = 3.5,
        num_images = 1,
        negative_prompt,
        safety_tolerance,
        raw,
      } = args;
    
      try {
        // Configure FAL client lazily with query config override
        configureFalClient(this.currentQueryConfig);
        const inputParams: any = { prompt };
        
        // Add common parameters
        if (image_size) inputParams.image_size = image_size;
        if (num_images > 1) inputParams.num_images = num_images;
        
        // Add model-specific parameters based on model capabilities
        if (model.id.includes('flux') || model.id.includes('stable_diffusion')) {
          if (num_inference_steps) inputParams.num_inference_steps = num_inference_steps;
          if (guidance_scale) inputParams.guidance_scale = guidance_scale;
        }
        if ((model.id.includes('stable_diffusion') || model.id === 'ideogram_v3') && negative_prompt) {
          inputParams.negative_prompt = negative_prompt;
        }
        if (model.id.includes('flux_pro') && safety_tolerance) {
          inputParams.safety_tolerance = safety_tolerance;
        }
        if (model.id === 'flux_pro_ultra' && raw !== undefined) {
          inputParams.raw = raw;
        }
    
        const result = await fal.subscribe(model.endpoint, { input: inputParams });
        const imageData = result.data as FalImageResult;
    
        const processedImages = await downloadAndProcessImages(imageData.images, model.id);
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                model: model.name,
                id: model.id,
                endpoint: model.endpoint,
                prompt,
                images: processedImages,
                metadata: inputParams,
                download_path: DOWNLOAD_PATH,
                data_url_settings: {
                  enabled: ENABLE_DATA_URLS,
                  max_size_mb: Math.round(MAX_DATA_URL_SIZE / 1024 / 1024),
                },
                autoopen_settings: {
                  enabled: AUTOOPEN,
                  note: AUTOOPEN ? "Files automatically opened with default application" : "Auto-open disabled"
                },
              }, null, 2),
            },
          ],
        };
      } catch (error) {
        throw new Error(`${model.name} generation failed: ${error}`);
      }
    }
  • src/index.ts:102-102 (registration)
    Registration of the flux_kontext tool in MODEL_REGISTRY.imageGeneration array, defining its ID, FAL endpoint, name, and description.
    { id: 'flux_kontext', endpoint: 'fal-ai/flux-pro/kontext/text-to-image', name: 'FLUX Kontext Pro', description: 'State-of-the-art prompt adherence and typography' },
  • Dynamic input schema generation for flux_kontext tool (name=model.id). For imageGeneration category: defines required 'prompt', optional image_size, num_images, flux-specific num_inference_steps/guidance_scale.
    private generateToolSchema(model: any, category: string) {
      const baseSchema = {
        name: model.id,
        description: `${model.name} - ${model.description}`,
        inputSchema: {
          type: 'object',
          properties: {} as any,
          required: [] as string[],
        },
      };
    
      if (category === 'imageGeneration') {
        baseSchema.inputSchema.properties = {
          prompt: { type: 'string', description: 'Text prompt for image generation' },
          image_size: { type: 'string', enum: ['square_hd', 'square', 'portrait_4_3', 'portrait_16_9', 'landscape_4_3', 'landscape_16_9'], default: 'landscape_4_3' },
          num_images: { type: 'number', default: 1, minimum: 1, maximum: 4 },
        };
        baseSchema.inputSchema.required = ['prompt'];
        
        // Add model-specific parameters
        if (model.id.includes('flux') || model.id.includes('stable_diffusion')) {
          baseSchema.inputSchema.properties.num_inference_steps = { type: 'number', default: 25, minimum: 1, maximum: 50 };
          baseSchema.inputSchema.properties.guidance_scale = { type: 'number', default: 3.5, minimum: 1, maximum: 20 };
        }
        if (model.id.includes('stable_diffusion') || model.id === 'ideogram_v3') {
          baseSchema.inputSchema.properties.negative_prompt = { type: 'string', description: 'Negative prompt' };
        }
      } else if (category === 'textToVideo') {
        baseSchema.inputSchema.properties = {
          prompt: { type: 'string', description: 'Text prompt for video generation' },
          duration: { type: 'number', default: 5, minimum: 1, maximum: 30 },
          aspect_ratio: { type: 'string', enum: ['16:9', '9:16', '1:1', '4:3', '3:4'], default: '16:9' },
        };
        baseSchema.inputSchema.required = ['prompt'];
      } else if (category === 'imageToVideo') {
        baseSchema.inputSchema.properties = {
          image_url: { type: 'string', description: 'URL of the input image' },
          prompt: { type: 'string', description: 'Motion description prompt' },
          duration: { type: 'string', enum: ['5', '10'], default: '5', description: 'Video duration in seconds' },
          aspect_ratio: { type: 'string', enum: ['16:9', '9:16', '1:1'], default: '16:9' },
          negative_prompt: { type: 'string', description: 'What to avoid in the video' },
          cfg_scale: { type: 'number', default: 0.5, minimum: 0, maximum: 1, description: 'How closely to follow the prompt' }
        };
        baseSchema.inputSchema.required = ['image_url', 'prompt'];
      }
    
      return baseSchema;
    }
  • src/index.ts:399-402 (registration)
    Registration loop in listTools handler that adds flux_kontext schema to the tools list using generateToolSchema.
    // Generate tools for each category
    for (const model of MODEL_REGISTRY.imageGeneration) {
      tools.push(this.generateToolSchema(model, 'imageGeneration'));
    }
  • Dispatch logic in CallToolRequestSchema handler that routes flux_kontext calls (matching imageGeneration) to the handleImageGeneration function.
    if (MODEL_REGISTRY.imageGeneration.find(m => m.id === name)) {
      return await this.handleImageGeneration(args, model);
    } else if (MODEL_REGISTRY.textToVideo.find(m => m.id === name)) {
Behavior1/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. The description mentions 'prompt adherence and typography' but doesn't explain what this means operationally. It fails to disclose whether this is a read or write operation, what resources it affects, any authentication requirements, rate limits, or what the output looks like. For a tool with 5 parameters and no output schema, this lack of behavioral information 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.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with a single sentence, but it's front-loaded with marketing language rather than functional information. While it avoids unnecessary verbosity, the brevity comes at the cost of clarity, as it doesn't effectively communicate the tool's purpose or usage. The structure is simple but under-specified.

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

Completeness1/5

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

Given the complexity (5 parameters, no annotations, no output schema, low schema coverage), the description is completely inadequate. It doesn't explain what the tool does, when to use it, how parameters affect behavior, or what to expect as output. For an image generation tool among many siblings, this lack of contextual information makes it impossible for an agent to use the tool correctly without additional guessing or trial-and-error.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is only 20% (only the 'prompt' parameter has a description), so the description must compensate for the undocumented parameters. The description mentions 'prompt adherence and typography', which loosely relates to the 'prompt' parameter but doesn't add meaningful semantics beyond what the schema already states ('Text prompt for image generation'). It provides no context for the other 4 parameters (image_size, num_images, num_inference_steps, guidance_scale), failing to explain their purpose or how they affect the tool's behavior.

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

Purpose2/5

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

The description 'FLUX Kontext Pro - State-of-the-art prompt adherence and typography' is vague and tautological. It restates the tool name ('FLUX Kontext') and adds marketing language ('State-of-the-art') without specifying what the tool actually does. It mentions 'prompt adherence and typography' but doesn't clarify if this is for image generation, text processing, or another function. The description fails to provide a clear verb+resource statement that distinguishes it from sibling tools like 'flux_dev' or 'stable_diffusion_35'.

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

Usage Guidelines1/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. With multiple sibling tools for image generation (e.g., 'flux_dev', 'hidream', 'imagen4'), there is no indication of what makes 'flux_kontext' unique or when it should be preferred. No context, exclusions, or alternatives are mentioned, leaving the agent with no usage direction.

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/RamboRogers/fal-image-video-mcp'

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