DEV Community

xbill for Google Developer Experts

Posted on • Originally published at Medium on

Nano Banana 2 Lite with MCP, and Antigravity CLI

This article covers the MCP setup and configuration for using Google Nano Banana 2 Lite and underlying Gemini LLM with Antigravity CLI to enhance and extend image operations over the MCP protocol.

What is Google Nano Banana 2 Lite?

Nano Banana 2 Lite (officially known as the Gemini 3.1 Flash-Lite Image model) is Google’s fastest and most cost-efficient AI image generation and editing model. It is built specifically for enterprises and developers who need to generate high-quality images quickly and affordably at a large scale. [1, 2, 3]

Key Features

  • Lightning-Fast Latency: Capable of generating high-quality images in about 4 seconds. [1, 2]
  • Cost-Efficient Pricing: Priced at approximately $0.034 per 1,000 images in Google AI Studio, undercutting standard models and previous versions. [1]
  • Real-World Grounding: Integrates with Google Web and Image Search to produce highly accurate visuals based on real-world information, such as live weather data and exact global locations. [1, 2]
  • Pro-Level Editing: Allows for nuanced image-editing capabilities, aspect ratio control, and text rendering/translation directly onto images. [1, 2]
  • Character Consistency: Retains the fidelity of subjects across multiple generations and scenarios, making it highly effective for storyboarding and marketing campaigns. [1, 2]

More details are here:

Start building with Nano Banana 2 Lite and Gemini Omni Flash

and here:

Gemini 3.1 Flash-Lite Image (Nano Banana 2 Lite) | Gemini Enterprise Agent Platform | Google Cloud Documentation

Antigravity CLI

Antigravity CLI is the follow-on successor to Gemini CLI- the terminal driven, agent assisted coding tool.

Full details on installing Antigravity CLI are here:

Getting Started with Antigravity CLI

Testing the Antigravity CLI Environment

Once you have all the tools in place- you can test the startup of Antigravity CLI.

You will need to authenticate with a Google Cloud Project or your Google Account:

agy
Enter fullscreen mode Exit fullscreen mode

This will start the interface:

Full Installation Instructions

The detailed installation instructions for Antigravity CLI are here:

Getting Started with Antigravity CLI

What is MCP?

Unless you have been living off grid without Internet- MCP is the new universal connector and next “Big Thing”.

More information is here:

What is Model Context Protocol (MCP)? A guide

Python MCP Documentation

The official GitHub Repo provides samples and documentation for getting started:

GitHub - modelcontextprotocol/python-sdk: The official Python SDK for Model Context Protocol servers and clients

Isn’t MCP overkill?

There are many ways to call models. Native MCP support in Google Antigravity opens up a new pathway to call the underlying Omni model.

Google Antigravity utilizes the Model Context Protocol (MCP) as a universal, open-standard “bridge” that allows AI agents to securely interact with external tools, APIs, and data sources. Combined with models like Gemini Nano Banana 2 Lite , this integration allows developers to build rich, agentic workflows natively. [1, 2, 3, 4]

Model Context Protocol (MCP) in Antigravity

MCP acts as a standardized communication layer for AI. Instead of needing hard-coded integrations for every data source or platform, MCP allows Antigravity’s AI agents to securely query external environments, ranging from your local files to cloud infrastructure. [1, 2]

  • Universal Tool Access: Allows your Gemini powered agent to discover and trigger specific tools (like reading logs, querying databases, or executing scripts) on demand. [1]
  • Security & Control: Supports both local execution and managed remote MCP servers hosted on Google Cloud, letting you limit access with granular approval gates. [1, 2]
  • Resource Discovery: Features Agentic Resource Discovery (ARD) so agents know exactly what tools and data are available in your ecosystem. [1]

Integrating Antigravity with Google Nano Banana 2 Flash Lite

Pairing Antigravity with Nano Banana 2 Lite expands the agent’s core capabilities, allowing it to act on multimodal inputs and execute complex tasks on your behalf. [1, 2, 3]

  • Enhanced Reasoning & Speed: The Antigravity agent harness combined with Nano Banana image models enables asynchronous subagents, allowing the system to delegate parallel background tasks. [1]
  • Workspaces: Antigravity 2.0 organizes MCP usage around specific projects, meaning you can configure MCP configurations (via mcp_config.json) per workspace directory. [1, 2, 3, 4, 5]
  • Multimodal Actions: Agents using Nano Banana Lite 2 can generate visual artifacts, trigger browser testing, and interact seamlessly with developer tools. [1, 2, 3]

So what is the Secret Sauce?

The Interactions API allows for a clean consistent call to the model.

The Interactions API is Google’s unified interface for building with Gemini AI models and autonomous agents. Rather than using multiple separate endpoints for text chat, tool use, image generation, or background agents, it provides a single, streamlined API to handle complex, stateful workflows. [1, 2, 3]

More information is here:

Interactions API | Gemini API | Google AI for Developers

and here:

Gemini Interactions API | Gemini API | Google AI for Developers

Setup the Basic Environment

At this point you should have a working Python environment and a working Antigravity CLI installation. The next step is to clone the GitHub samples repository with support scripts:

cd ~
git clone https://github.com/xbill9/nb2lite
Enter fullscreen mode Exit fullscreen mode

Then run init.sh from the cloned directory.

The script will attempt to determine your shell environment and set the correct variables:

cd nb2lite
source init.sh
Enter fullscreen mode Exit fullscreen mode

If your session times out or you need to re-authenticate- you can run the set_env.sh script to reset your environment variables:

cd nb2lite
source set_env.sh
Enter fullscreen mode Exit fullscreen mode

Variables like PROJECT_ID need to be setup for use in the various build scripts- so the set_env script can be used to reset the environment if you time-out.

Running the Python Code

First- switch the directory with the Python version of the MCP sample code:

make install
pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode

The project can also be linted:

xbill@penguin:~/nb2lite$ make lint
ruff check .
All checks passed!
ruff format --check .
2 files already formatted
mypy .
Success: no issues found in 2 source files
xbill@penguin:~/nb2lite$ 
Enter fullscreen mode Exit fullscreen mode

Antigravity CLI mcp_config.json

A sample MCP server file is provided in the .agents directory:

{
  "mcpServers": {
    "nb2lite-agent": {
      "command": "python3",
      "args": [
        "/home/xbill/nb2lite/server.py"
      ]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Validation with Antigravity CLI

The final connection test uses Antigravity CLI as a MCP client with the Python code providing the MCP server:

MCP Servers

Plugins (~/.gemini/config/plugins)
> ✓ google-dev-knowledge Tools: search_documents, answer_query, get_documents
   ✓ nb2lite-agent Tools: generate_image, edit_image, edit_local_image
Enter fullscreen mode Exit fullscreen mode

the tools are reviewed:

 Here is the help guide for the NB2Lite Agent ( gemini-3.1-flash-lite-image ), which interfaces with the stateful
  Interactions API for generating and editing images.
  ──────
  ### 🌌 NB2Lite Agent Help & Configuration

  The agent uses the high-efficiency gemini-3.1-flash-lite-image model, enabling both initial image generation and
  stateful, multi-turn editing.

  #### ⚙️ Configuration & Environment

  • GEMINI_API_KEY / GOOGLE_API_KEY : Primary API keys to authenticate with the Gemini API (currently Not Set).
  • GEMINI_MODEL_NAME : The name of the interactions model to use (default: gemini-3.1-flash-lite-image ).
  • IMAGE_OUTPUT_DIR : Local directory where generated/edited images are stored (currently /home/xbill/nb2lite ).
  ──────
  #### 🧰 Available MCP Tools

  ##### 1. generate_image 

  Generates a new image from a text prompt and saves it locally.

  • Arguments:
      • prompt (required): Natural language description.
      • aspect_ratio (optional): '1:1' (default), '16:9' , '9:16' , '4:3' , '3:4' .
      • thinking_level (optional): 'minimal' , 'low' , 'medium' (default), 'high' .

  ##### 2. edit_image 

  Performs stateful multi-turn edits on a previously generated image using its interaction ID.

  • Arguments:
      • previous_interaction_id (required): The unique ID returned from the previous turn.
      • edit_prompt (required): Natural language description of changes/additions.
      • thinking_level (optional): 'minimal' , 'low' , 'medium' (default), 'high' .

  ##### 3. edit_local_image 

  Uploads a local image file in-line via Base64 and describes edits to apply.

  • Arguments:
      • image_path (required): Path to the local image.
      • edit_prompt (required): Natural language description of modifications.
      • aspect_ratio (optional): '1:1' (default), '16:9' , '9:16' , '4:3' , '3:4' .
      • thinking_level (optional): 'minimal' , 'low' , 'medium' (default), 'high' .

  ##### 4. get_help 

  Provides this help text and summarizes the server configuration.
  ──────
  ### 💾 File Output & Stateful Session Management

  • All successful generation and edit requests save the output image locally under IMAGE_OUTPUT_DIR with a
  concurrent-safe naming format: gen_<timestamp>_<uuid_hex>.<ext> .
  • Each API call sets store=True by default, generating a persistent interaction_id session context on Google's
  servers. Pass this ID as previous_interaction_id in subsequent edit_image calls to perform multi-turn
  modifications with high character, style, and pixel continuity.
Enter fullscreen mode Exit fullscreen mode

We have Lift Off!

Finally- the tools are now available for working with the Nano Banana2 Lite models:

> summarize the mcp tools

  The nb2lite-agent Model Context Protocol (MCP) server exposes four tools designed to work with the stateful
  Interactions API using the gemini-3.1-flash-lite-image model.

  ### 🧰 MCP Tool Summary

   Tool Name | Action / Purpose | Key Inputs | Outputs | Primary Use Case
  --------------------|----------------------|-----------------------|-----------------------|-----------------------
    generate_image | Generates a new | prompt , | Path to generated | Creating the initial
                      | image from scratch | aspect_ratio | image file, | baseline
                      | using a text prompt. | (default: '1:1' ), | interaction_id | image/concept.
                      | | thinking_level | |
                      | | (default: 'medium' ) | |
    edit_image | Modifies a | previous_interaction_| Path to modified | Stateful, multi-turn
                      | previously generated | id , edit_prompt , | image file, new | refinement (e.g.,
                      | image while | thinking_level | interaction_id | adding objects,
                      | preserving context, | (default: 'medium' ) | | changing clothes,
                      | style, and pixel | | | adjusting lighting).
                      | continuity. | | |
    edit_local_image | Uploads a local | image_path , | Path to edited image | Modifying custom
                      | image (Base64 | edit_prompt , | file, interaction_id | local assets or
                      | inline) and applies | aspect_ratio , | | sketches (e.g.,
                      | natural language | thinking_level | | turning a sketch into
                      | edits to it. | (default: 'medium' ) | | a 3D render).
    get_help | Retrieves current | None | Help message string | Troubleshooting
                      | configuration state | | detailing variables | configuration or
                      | and tool list. | | and schemas | double-checking
                      | | | | available options.

  ### 💡 Core Design Features

  • Stateful Continuity: Tools that generate or edit images automatically enable store=True under the hood. Using
  the returned interaction_id from a previous call allows seamless, iterative edits on Google's servers.
  • Thinking Budgets: The thinking_level parameter ( minimal , low , medium , high ) allows trade-offs between
  generation speed (latency) and the detail/correctness of complex compositions.
  • Thread-Safe Savings: Images are written to IMAGE_OUTPUT_DIR (currently /home/xbill/nb2lite ) using collision-
  resistant unique names ( gen_<timestamp>_<uuid>.png ).
Enter fullscreen mode Exit fullscreen mode

Enough, Already! Show me the Money!

Antigravity CLI was started up for a hands-on image editing session:

  Please wait while the banner image is being generated using the Gemini Interactions API. I will update you once it
  is ready.

  I have generated the banner image for your article "Nano Banana 2 Lite with MCP and Antigravity CLI" using the
  Gemini Interactions API.

  Here are the details of the generated image:

  • Saved Image: gen_1782839885_f1ecaeae.jpg
  • Interaction ID: v1_ChdTX3BEYXE2TE9jeWgxTWtQMjdxU3FBNBIXU19wRGFxNkxPY3loMU1rUDI3cVNxQTQ 
Enter fullscreen mode Exit fullscreen mode

Not a fan of Bananas?

> edit image • Saved Image: gen_1782839885_f1ecaeae.jpg
    • Interaction ID: v1_ChdTX3BEYXE2TE9jeWgxTWtQMjdxU3FBNBIXU19wRGFxNkxPY3loMU1rUDI3cVNxQTQ  
change the bananna to an apple!
Enter fullscreen mode Exit fullscreen mode

Not a fan of Apples?

> modify @[edit_1782840940_1737e465.jpg] to change the apple to a pinapple

  I will inspect the schema for the edit_local_image tool to ensure correct arguments are passed.

● Read(/home/xbill/.gemini/antigravity-cli/mcp/nb2lite-agent/edit_local_image.json) (ctrl+o to expand)

  I will call the edit_local_image tool to upload the local image and request the modification to change the apple
  to a pineapple.

● nb2lite-agent/edit_local_image(Edit local image) (ctrl+o to expand)

  I will retry editing the image, specifying a supported thinking level ( high ), as medium is not supported by the
  model.

● nb2lite-agent/edit_local_image(Edit local image) (ctrl+o to expand)

  I have successfully modified the image to replace the apple with a pineapple.

  • Original Image: edit_1782840940_1737e465.jpg
  • Modified Image: edit_local_1782841200_b6351285.jpg
  • Interaction ID: v1_ChdidjlEYXBXWUpOYkktOFlQNkpHZWdRTRIXYnY5RGFwV1lKTmJJLThZUDZKR2VnUU0
Enter fullscreen mode Exit fullscreen mode

One last example - the banner for this article was re-themed in steam-punk style:

> use the MCP tool to edit_local_image and retheme @[nano_banana_mcp.jpg] as steam-punk

  Please wait while the image is being rethemed using the Gemini Interactions API. I will update you once it is
  completed.

  I have successfully rethemed the image nano_banana_mcp.jpg to a steam-punk style using the Gemini Interactions API.

  Here are the details of the generated image:

  • Saved Image: edit_local_1782839741_1c2c5bd5.jpg
  • Interaction ID: v1_Chd1X2xEYW8yX01haVVfdU1QMXNXVXNBNBIXdV9sRGFvMl9NYWlVX3VNUDFzV1VzQTQ
Enter fullscreen mode Exit fullscreen mode

One last thought- Where are Agents?

Where are the Agents?

The Antigravity CLI harness itself uses agents to manage the workflow.

The additional touch point for leveraging the MCP interface is that they all are exposed as MCP tools. The MCP tools can be called directly from Agent code or used as a template for Interactions API calls embedded in an Agent.

Summary

The strategy for using MCP with Nano Banana 2 Lite and Antigravity CLI was validated with a incremental step by step approach.

A minimal stdio transport MCP Server was started from Python source code and validated with Antigravity CLI running as a MCP client in the same local environment.

This MCP Python server provided all of the management tools to interact with the model and generate high quality cyberpunk pineapple images.


Top comments (0)