Skip to main content
Glama

continue_editing

Apply iterative improvements to the last image generated or edited in your session. Automatically uses the previous image without requiring file paths, enabling continuous refinement through text-based change descriptions.

Instructions

Continue editing the LAST image generated or edited in this session. Automatically uses the previous image without needing a file path. Use for iterative improvements.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesText describing changes to make to the last image (max 10,000 chars)
referenceImagesNoOptional array of file paths to reference images

Implementation Reference

  • The handleContinueEditing method is the main handler for the continue_editing tool. It checks if a previous image exists (lastImagePath), verifies the file still exists, parses arguments with ContinueEditingArgsSchema, then delegates to editImageInternal for the actual edit operation.
    private async handleContinueEditing(
      request: CallToolRequest
    ): Promise<CallToolResult> {
      if (!this.lastImagePath) {
        throw new McpError(
          ErrorCode.InvalidRequest,
          "No previous image found. Generate or edit an image first, then use continue_editing."
        );
      }
    
      // Verify the file still exists
      try {
        await fs.access(this.lastImagePath);
      } catch {
        throw new McpError(
          ErrorCode.InvalidRequest,
          "Last image file no longer exists. Generate a new image first."
        );
      }
    
      const parsed = ContinueEditingArgsSchema.safeParse(
        request.params.arguments
      );
      if (!parsed.success) {
        throw new McpError(
          ErrorCode.InvalidParams,
          parsed.error.errors.map((e) => e.message).join("; ")
        );
      }
    
      const { prompt, referenceImages } = parsed.data;
      return await this.editImageInternal(
        this.lastImagePath,
        prompt,
        referenceImages
      );
    }
  • ContinueEditingArgsSchema defines the input validation for continue_editing: a required prompt (string, 1-10,000 chars) and optional referenceImages (array of strings).
    export const ContinueEditingArgsSchema = z.object({
      prompt: z.string().min(1, "Prompt is required").max(10_000, "Prompt too long (max 10,000 chars)"),
      referenceImages: z.array(z.string()).optional(),
    });
  • src/index.ts:73-93 (registration)
    Tool registration for continue_editing in the TOOLS array, defining its name, description (for iterative improvements on the last image), and inputSchema with prompt and optional referenceImages.
      name: "continue_editing",
      description:
        "Continue editing the LAST image generated or edited in this session. Automatically uses the previous image without needing a file path. Use for iterative improvements.",
      inputSchema: {
        type: "object",
        properties: {
          prompt: {
            type: "string",
            description:
              "Text describing changes to make to the last image (max 10,000 chars)",
          },
          referenceImages: {
            type: "array",
            items: { type: "string" },
            description:
              "Optional array of file paths to reference images",
          },
        },
        required: ["prompt"],
      },
    },
  • editImageInternal is a shared helper method used by both edit_image and continue_editing tools. It validates paths, reads image files, handles reference images, calls the Gemini client to perform the edit, and returns the result with the edited image.
    private async editImageInternal(
      imagePath: string,
      prompt: string,
      referenceImages?: string[]
    ): Promise<CallToolResult> {
      const allowedDirs = getAllowedDirs();
    
      // Validate main image path
      const validatedPath = validatePath(imagePath, allowedDirs);
      const imageBuffer = await readImageFile(validatedPath);
      const mimeType = getMimeType(validatedPath);
      const imageBase64 = imageBuffer.toString("base64");
    
      // Validate and read reference images
      const refData: Array<{ base64: string; mimeType: string }> = [];
      if (referenceImages && referenceImages.length > 0) {
        for (const refPath of referenceImages) {
          const validatedRef = validatePath(refPath, allowedDirs);
          const refBuffer = await readImageFile(validatedRef);
          const refMime = getMimeType(validatedRef);
          refData.push({
            base64: refBuffer.toString("base64"),
            mimeType: refMime,
          });
        }
      }
    
      const result = await this.gemini.editImage(
        imageBase64,
        mimeType,
        prompt,
        refData.length > 0 ? refData : undefined
      );
    
      if (!result.filePath) {
        return {
          content: [{ type: "text", text: result.textContent }],
        };
      }
    
      this.lastImagePath = result.filePath;
    
      const statusText = [
        `Image edited with nanobanana (${this.gemini.getModelName()})`,
        `Original: ${imagePath}`,
        `Edit: "${prompt.length > 100 ? prompt.slice(0, 100) + "..." : prompt}"`,
        referenceImages?.length
          ? `Reference images: ${referenceImages.length}`
          : null,
        result.textContent ? `Description: ${result.textContent}` : null,
        `Saved to: ${result.filePath}`,
        `Use continue_editing to make further changes.`,
      ]
        .filter(Boolean)
        .join("\n\n");
    
      return {
        content: [
          { type: "text", text: statusText },
          {
            type: "image",
            data: result.base64Data,
            mimeType: result.mimeType,
          },
        ],
      };
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it operates on session state ('LAST image... in this session'), is stateful ('Automatically uses the previous image'), and is designed for 'iterative improvements'. However, it doesn't mention potential limitations like session duration, error handling, or what happens if no previous image exists, leaving some gaps.

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 front-loaded with the core purpose in the first sentence, followed by operational details and usage context. Every sentence earns its place: the first defines the tool, the second explains automation, and the third provides guidance. It's concise with zero wasted words.

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

Completeness4/5

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

Given the tool's moderate complexity (stateful operation, 2 parameters), no annotations, and no output schema, the description is largely complete. It covers purpose, usage, and key behavior. However, it lacks details on output format or error cases, which could be helpful for an agent. Since there's no output schema, some additional context on returns would improve completeness.

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 both parameters thoroughly. The description adds no specific parameter semantics beyond implying 'prompt' is for 'changes to make' and 'referenceImages' might be optional references. This meets the baseline of 3 since the schema does the heavy lifting.

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

Purpose5/5

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

The description clearly states the specific action ('Continue editing'), the resource ('the LAST image generated or edited in this session'), and distinguishes it from siblings by emphasizing it works on the 'previous image without needing a file path' unlike edit_image which likely requires a file path. The phrase 'iterative improvements' further clarifies its unique role.

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

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states when to use this tool ('Continue editing the LAST image... in this session') and provides clear alternatives by naming sibling tools (edit_image, generate_image) in the context. It specifies 'Automatically uses the previous image' which implies when not to use it (e.g., when starting fresh or editing a different image).

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/DojoCodingLabs/nanobanana-mcp'

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