continue_editing
Modify the most recent image in your session by describing changes like color adjustments, element additions, or background removal. Supports iterative improvements and optional reference images for style transfer.
Instructions
Continue editing the LAST image that was generated or edited in this session, optionally using additional reference images. Use this for iterative improvements, modifications, or changes to the most recent image. This automatically uses the previous image without needing a file path.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| aspectRatio | No | Optional aspect ratio for the edited image. Default is 1:1 (1024×1024). | |
| prompt | Yes | Text describing the modifications/changes/improvements to make to the last image (e.g., 'change the hat color to red', 'remove the background', 'add flowers') | |
| referenceImages | No | Optional array of file paths to additional reference images to use during editing (e.g., for style transfer, adding elements from other images, etc.) |
Implementation Reference
- src/index.ts:574-610 (handler)The handler function for the 'continue_editing' tool. It checks if an OpenRouter token is configured and if a previous image exists, then delegates to the edit_image logic using the last image path.private async continueEditing(request: CallToolRequest): Promise<CallToolResult> { if (!this.ensureConfigured()) { throw new McpError(ErrorCode.InvalidRequest, "OpenRouter API token not configured. Use configure_openrouter_token first."); } if (!this.lastImagePath) { throw new McpError(ErrorCode.InvalidRequest, "No previous image found. Please generate or edit an image first, then use continue_editing for subsequent edits."); } const { prompt, referenceImages, aspectRatio } = request.params.arguments as { prompt: string; referenceImages?: string[]; aspectRatio?: AspectRatio; }; // 检查最后的图片文件是否存在 try { await fs.access(this.lastImagePath); } catch { throw new McpError(ErrorCode.InvalidRequest, `Last image file not found at: ${this.lastImagePath}. Please generate a new image first.`); } // Use editImage logic with lastImagePath return await this.editImage({ method: "tools/call", params: { name: "edit_image", arguments: { imagePath: this.lastImagePath, prompt: prompt, referenceImages: referenceImages, aspectRatio: aspectRatio } } } as CallToolRequest); }
- src/index.ts:139-160 (schema)Input schema for the continue_editing tool, defining parameters like prompt, optional referenceImages, and aspectRatio.inputSchema: { type: "object", properties: { prompt: { type: "string", description: "Text describing the modifications/changes/improvements to make to the last image (e.g., 'change the hat color to red', 'remove the background', 'add flowers')", }, referenceImages: { type: "array", items: { type: "string" }, description: "Optional array of file paths to additional reference images to use during editing (e.g., for style transfer, adding elements from other images, etc.)", }, aspectRatio: { type: "string", enum: ["1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"], description: "Optional aspect ratio for the edited image. Default is 1:1 (1024×1024).", }, }, required: ["prompt"], },
- src/index.ts:136-161 (registration)Registration of the continue_editing tool in the ListTools response, including name, description, and input schema.{ name: "continue_editing", description: "Continue editing the LAST image that was generated or edited in this session, optionally using additional reference images. Use this for iterative improvements, modifications, or changes to the most recent image. This automatically uses the previous image without needing a file path.", inputSchema: { type: "object", properties: { prompt: { type: "string", description: "Text describing the modifications/changes/improvements to make to the last image (e.g., 'change the hat color to red', 'remove the background', 'add flowers')", }, referenceImages: { type: "array", items: { type: "string" }, description: "Optional array of file paths to additional reference images to use during editing (e.g., for style transfer, adding elements from other images, etc.)", }, aspectRatio: { type: "string", enum: ["1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"], description: "Optional aspect ratio for the edited image. Default is 1:1 (1024×1024).", }, }, required: ["prompt"], }, },
- src/index.ts:190-191 (registration)Dispatch case in the CallToolRequest handler that routes to the continueEditing method.case "continue_editing": return await this.continueEditing(request);