Skip to main content
Glama
RamboRogers

FAL Image/Video MCP Server

by RamboRogers

execute_custom_model

Run any FAL AI model by specifying its endpoint and parameters to generate images, videos, or other media outputs directly from the MCP server.

Instructions

Execute any FAL model by specifying the endpoint directly

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endpointYesFAL model endpoint (e.g., fal-ai/flux/schnell, fal-ai/custom-model)
input_paramsYesInput parameters for the model (varies by model)
category_hintNoHint about the expected output type for proper handlingother

Implementation Reference

  • Core handler function that executes the custom model by subscribing to the FAL endpoint, processing outputs (images or videos), handling downloads, data URLs, and formatting the response.
    private async handleCustomModel(args: any) {
      const { endpoint, input_params, category_hint = 'other' } = args;
    
      try {
        // Configure FAL client lazily with query config override
        configureFalClient(this.currentQueryConfig);
        const result = await fal.subscribe(endpoint, { input: input_params });
    
        // Handle different output types based on category hint
        if (category_hint === 'image' || category_hint === 'other') {
          // Assume image output
          const data = result.data as any;
          if (data.images && Array.isArray(data.images)) {
            const processedImages = await downloadAndProcessImages(data.images, endpoint.replace(/[^a-zA-Z0-9]/g, '_'));
            
            return {
              content: [
                {
                  type: 'text',
                  text: JSON.stringify({
                    endpoint,
                    category_hint,
                    images: processedImages,
                    raw_output: data,
                    input_params,
                    download_path: DOWNLOAD_PATH,
                  }, null, 2),
                },
              ],
            };
          }
        } else if (category_hint === 'video' || category_hint === 'image_to_video') {
          // Assume video output
          const data = result.data as any;
          if (data.video) {
            const videoProcessed = await downloadAndProcessVideo(data.video.url, endpoint.replace(/[^a-zA-Z0-9]/g, '_'));
            
            return {
              content: [
                {
                  type: 'text',
                  text: JSON.stringify({
                    endpoint,
                    category_hint,
                    video: {
                      url: data.video.url,
                      dataUrl: videoProcessed.dataUrl,
                      localPath: videoProcessed.localPath,
                      width: data.video.width,
                      height: data.video.height,
                    },
                    raw_output: data,
                    input_params,
                    download_path: DOWNLOAD_PATH,
                  }, null, 2),
                },
              ],
            };
          }
        }
    
        // Fallback: return raw output
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                endpoint,
                category_hint,
                raw_output: result.data,
                input_params,
                note: "Raw output - model type not recognized for enhanced processing"
              }, null, 2),
            },
          ],
        };
      } catch (error) {
        throw new Error(`Custom model execution failed for ${endpoint}: ${error}`);
      }
    }
  • Tool schema definition including input parameters: endpoint, input_params (object), and optional category_hint for output processing.
    tools.push({
      name: 'execute_custom_model',
      description: 'Execute any FAL model by specifying the endpoint directly',
      inputSchema: {
        type: 'object',
        properties: {
          endpoint: {
            type: 'string',
            description: 'FAL model endpoint (e.g., fal-ai/flux/schnell, fal-ai/custom-model)'
          },
          input_params: {
            type: 'object',
            description: 'Input parameters for the model (varies by model)'
          },
          category_hint: {
            type: 'string',
            enum: ['image', 'video', 'image_to_video', 'other'],
            default: 'other',
            description: 'Hint about the expected output type for proper handling'
          }
        },
        required: ['endpoint', 'input_params']
      }
    });
  • src/index.ts:461-465 (registration)
    Dispatch registration in the stdio CallToolRequestSchema handler that calls the custom model handler when the tool name matches.
    if (name === 'list_available_models') {
      return await this.handleListModels(args);
    } else if (name === 'execute_custom_model') {
      return await this.handleCustomModel(args);
    }
  • src/index.ts:1051-1055 (registration)
    Dispatch registration in the HTTP direct tool call handler (duplicate logic for HTTP transport support).
    if (name === 'list_available_models') {
      toolResult = await this.handleListModels(args);
    } else if (name === 'execute_custom_model') {
      toolResult = await this.handleCustomModel(args);
    } else {
  • Duplicate tool schema definition for the HTTP tools/list endpoint.
      name: 'execute_custom_model',
      description: 'Execute any FAL model by specifying the endpoint directly',
      inputSchema: {
        type: 'object',
        properties: {
          endpoint: {
            type: 'string',
            description: 'FAL model endpoint (e.g., fal-ai/flux/schnell, fal-ai/custom-model)'
          },
          input_params: {
            type: 'object',
            description: 'Input parameters for the model (varies by model)'
          },
          category_hint: {
            type: 'string',
            enum: ['image', 'video', 'image_to_video', 'other'],
            default: 'other',
            description: 'Hint about the expected output type for proper handling'
          }
        },
        required: ['endpoint', 'input_params']
      }
    });
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool can 'Execute any FAL model' but doesn't mention authentication requirements, rate limits, error handling, execution time, or what happens when models fail. For a generic execution tool with potentially variable behavior, this leaves significant gaps in understanding how it behaves.

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 a single, efficient sentence that states the core purpose without unnecessary words. It's appropriately sized for a tool with good schema documentation and gets straight to the point with zero wasted text.

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

Completeness2/5

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

For a generic execution tool with 3 parameters, no annotations, no output schema, and many specialized sibling alternatives, the description is insufficient. It doesn't explain return values, error conditions, or how this tool relates to the specific model tools. The agent lacks critical context about what to expect from execution and when to choose this approach.

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 description coverage is 100%, so the schema already documents all three parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain endpoint format conventions, how input_params map to specific models, or practical examples of category_hint usage. Baseline 3 is appropriate when schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('Execute') and target resource ('any FAL model'), specifying that execution happens 'by specifying the endpoint directly'. This distinguishes it from sibling tools that appear to be specific model endpoints (e.g., flux_dev, stable_diffusion_35), but it doesn't explicitly contrast with those siblings in the description text.

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

Usage Guidelines2/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 the many sibling tools listed. It doesn't mention prerequisites, alternatives, or constraints for choosing this generic execution method over specific model tools. The agent must infer usage from context alone.

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