Skip to main content
Glama

control

Generate images with structural control using canny, depth, or pose guidance from input images and text prompts.

Instructions

Generate an image using structural control

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeYesType of control to use
imageYesInput control image path
promptYesText prompt for generation
stepsNoNumber of inference steps
guidanceNoGuidance scale
outputNoOutput filename

Implementation Reference

  • The main handler for the MCP 'control' tool. It validates the input arguments according to ControlArgs type, constructs CLI arguments, spawns the fluxcli.py process with 'control' command, captures output, and returns it as tool response.
    case 'control': {
        const args = request.params.arguments as ControlArgs;
        // Validate required fields
        const type = this.validateRequiredString(args.type, 'type') as ControlType;
        const image = this.validateRequiredString(args.image, 'image');
        const prompt = this.validateRequiredString(args.prompt, 'prompt');
    
        // Validate optional numeric fields
        const steps = this.validateNumber(args.steps, 'steps', 1, 100);
        const guidance = this.validateNumber(args.guidance, 'guidance', 0, 100);
    
        const cmdArgs = ['control'];
        cmdArgs.push('--type', type);
        cmdArgs.push('--image', image);
        cmdArgs.push('--prompt', prompt);
        if (steps) cmdArgs.push('--steps', steps.toString());
        if (guidance !== undefined) cmdArgs.push('--guidance', guidance.toString());
        if (args.output) cmdArgs.push('--output', args.output);
    
        const output = await this.runPythonCommand(cmdArgs);
        return {
            content: [{ type: 'text', text: output }],
        };
    }
  • src/index.ts:250-285 (registration)
    Registration of the 'control' tool in the MCP server's listTools response, including name, description, and detailed inputSchema matching the ControlArgs interface.
    {
        name: 'control',
        description: 'Generate an image using structural control',
        inputSchema: {
            type: 'object',
            properties: {
                type: {
                    type: 'string',
                    description: 'Type of control to use',
                    enum: ['canny', 'depth', 'pose'],
                },
                image: {
                    type: 'string',
                    description: 'Input control image path',
                },
                prompt: {
                    type: 'string',
                    description: 'Text prompt for generation',
                },
                steps: {
                    type: 'number',
                    description: 'Number of inference steps',
                    default: 50,
                },
                guidance: {
                    type: 'number',
                    description: 'Guidance scale',
                },
                output: {
                    type: 'string',
                    description: 'Output filename',
                },
            },
            required: ['type', 'image', 'prompt'],
        },
    },
  • TypeScript interface defining the structure of arguments expected by the 'control' tool handler.
    export interface ControlArgs {
      type: ControlType;
      image: string;
      prompt: string;
      steps?: number;
      guidance?: number;
      output?: string;
    }
  • Type definition for valid control types used in ControlArgs.
    export type ControlType = 'canny' | 'depth' | 'pose';
  • Underlying Python helper method invoked by the CLI 'control' command, which makes the actual API call to BFL for control-guided image generation (canny, depth, pose). Called indirectly by the MCP handler via subprocess.
    def control_generate(self, control_type: str, control_image: str, prompt: str, **kwargs) -> Optional[str]:
        """Generate an image using any supported control type."""
        endpoints = {
            'canny': '/v1/flux-pro-1.0-canny',
            'depth': '/v1/flux-pro-1.0-depth',
            'pose': '/v1/flux-pro-1.0-pose'
        }
        
        default_params = {
            'canny': {'guidance': 30},
            'depth': {'guidance': 15},
            'pose': {'guidance': 25}
        }
        
        if control_type not in endpoints:
            raise ValueError(f"Unsupported control type: {control_type}")
            
        payload = {
            "prompt": prompt,
            "control_image": self.encode_image(control_image),
            "steps": kwargs.get('steps', 50),
            "output_format": kwargs.get('output_format', 'jpeg'),
            "safety_tolerance": kwargs.get('safety_tolerance', 2)
        }
        
        payload.update(default_params.get(control_type, {}))
        payload.update(kwargs)
        
        response = requests.post(
            f"{self.base_url}{endpoints[control_type]}",
            json=payload,
            headers=self.headers
        )
        
        task_id = response.json().get('id')
        if not task_id:
            return None
            
        result = self.get_task_result(task_id)
        if result and result.get('result', {}).get('sample'):
            return result['result']['sample']
        return None
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It mentions 'structural control' but doesn't explain what this entails operationally—such as how control affects generation, whether it modifies existing images or creates new ones, potential side effects, or performance characteristics. This leaves significant gaps for a tool with 6 parameters.

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 with zero wasted words. It's appropriately sized and front-loaded, making it easy to parse quickly.

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?

Given the complexity (6 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain what 'structural control' means, how it interacts with parameters, or what the tool returns. For a generation tool with multiple controls, more context is needed to guide effective use.

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 fully documents all 6 parameters. The description adds no additional meaning about parameters beyond implying 'structural control' relates to the 'type' parameter. Baseline 3 is appropriate as the schema does the heavy lifting.

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

Purpose3/5

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

The description 'Generate an image using structural control' states a clear purpose (generating images with control mechanisms) but is vague about what 'structural control' means and doesn't distinguish from sibling tools like 'generate', 'img2img', or 'inpaint'. It doesn't specify what makes this tool unique compared to those alternatives.

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 sibling tools ('generate', 'img2img', 'inpaint'). There's no mention of appropriate contexts, prerequisites, or exclusions. The agent must infer usage from the tool name and parameters 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/jmanhype/mcp-flux-studio'

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