Skip to content

Support Image Content in MCP tool results #2136

Description

@hallmark

What would you like to be added?

Support the Image Content MCP tool result data type. When an MCP server responds with base64 encoded image data as part of its tool result, Gemini is not able to "see" the image.

Let's improve Gemini CLI to allow it to "see" images within MCP tool responses.

I can currently think of two possible approaches:

  1. Generative AI SDK
  2. Gemini CLI
    • Modify the Gemini CLI, as an MCP app, to intercept image content in MCP tool responses.
    • Potentially substitute a text placeholder: "The tool responded with an image here. The image can be found after this function response."
    • Then add inlineData with the base64 image data, pushed as a new Part after the functionResponse.
    • Possible code location to understand this suggestion:
      const responseParts: Part[] = await this.mcpTool.callTool(functionCalls);
      return {
      llmContent: responseParts,
      returnDisplay: getStringifiedResultForDisplay(responseParts),
      };
    • Bonus: I'd yolo support for MCP Audio Content here as well and see if it works! I don't see why it wouldn't. 🤷

Why is this needed?

This autonomous agent loop is getting popular:

Start with a UI mock -> write UI code -> take_screenshot -> edit code -> take_screenshot -> ..

MCP tools such as Puppeteer that are able to return screenshot image responses will be very handy to make this work within Gemini CLI.

Additional context

This is a similar or the same issue as with Cline: cline/cline#1865

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Qualitypriority/p2Important but can be addressed in a future release.

    Type

    No type

    Projects

    Status
    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions