img2img
Transform existing images by generating new versions based on text prompts and reference visuals, enabling creative image editing and variation generation.
Instructions
Generate an image using another image as reference
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image | Yes | Input image path | |
| prompt | Yes | Text prompt for generation | |
| model | No | Model to use for generation | flux.1.1-pro |
| strength | No | Generation strength | |
| width | No | Output image width | |
| height | No | Output image height | |
| output | No | Output filename | outputs/generated.jpg |
| name | Yes | Name for the generation |
Implementation Reference
- src/index.ts:314-340 (handler)MCP tool handler for 'img2img': validates input arguments, builds command-line arguments for the underlying Python CLI, and spawns the process to execute the image-to-image generation.case 'img2img': { const args = request.params.arguments as Img2ImgArgs; // Validate required fields const image = this.validateRequiredString(args.image, 'image'); const prompt = this.validateRequiredString(args.prompt, 'prompt'); const name = this.validateRequiredString(args.name, 'name'); // Validate optional numeric fields const strength = this.validateNumber(args.strength, 'strength', 0, 1); const width = this.validateNumber(args.width, 'width', 256, 2048); const height = this.validateNumber(args.height, 'height', 256, 2048); const cmdArgs = ['img2img']; cmdArgs.push('--image', image); cmdArgs.push('--prompt', prompt); cmdArgs.push('--name', name); if (args.model) cmdArgs.push('--model', args.model); if (strength !== undefined) cmdArgs.push('--strength', strength.toString()); if (width) cmdArgs.push('--width', width.toString()); if (height) cmdArgs.push('--height', height.toString()); if (args.output) cmdArgs.push('--output', args.output); const output = await this.runPythonCommand(cmdArgs); return { content: [{ type: 'text', text: output }], }; }
- src/index.ts:170-214 (registration)Registration of the 'img2img' tool in the MCP server's tool list, including name, description, and input schema.name: 'img2img', description: 'Generate an image using another image as reference', inputSchema: { type: 'object', properties: { image: { type: 'string', description: 'Input image path', }, prompt: { type: 'string', description: 'Text prompt for generation', }, model: { type: 'string', description: 'Model to use for generation', enum: ['flux.1.1-pro', 'flux.1-pro', 'flux.1-dev', 'flux.1.1-ultra'], default: 'flux.1.1-pro', }, strength: { type: 'number', description: 'Generation strength', default: 0.85, }, width: { type: 'number', description: 'Output image width', }, height: { type: 'number', description: 'Output image height', }, output: { type: 'string', description: 'Output filename', default: 'outputs/generated.jpg', }, name: { type: 'string', description: 'Name for the generation', }, }, required: ['image', 'prompt', 'name'], }, },
- src/types.ts:47-58 (schema)TypeScript interface defining the typed arguments (Img2ImgArgs) used in the img2img handler and referenced in the tool registration.* Arguments for the img2img tool */ export interface Img2ImgArgs { image: string; prompt: string; name: string; model?: FluxModel; strength?: number; width?: number; height?: number; output?: string; }