π€ This project was entirely generated by Claude Code - an AI coding assistant that can create complete, production-ready applications from scratch.
A Model Context Protocol (MCP) server that provides AI image generation and editing capabilities using Google's Gemini 2.5 Flash Image API. Generate stunning images, edit existing ones, and iterate on your creations with simple text prompts.
- π¨ Generate Images: Create new images from text descriptions
- βοΈ Edit Images: Modify existing images with text prompts
- π Iterative Editing: Continue editing the last generated/edited image
- πΌοΈ Multiple Reference Images: Use reference images for style transfer and guidance
- π Cross-Platform: Smart file paths for Windows, macOS, and Linux
- π§ Easy Setup: Simple configuration with API key
- π Auto File Management: Automatic image saving with organized naming
-
Get your Gemini API key:
- Visit Google AI Studio
- Create a new API key
- Copy it for configuration
-
Configure the MCP server: See configuration examples for your specific client below (Claude Code, Cursor, or other MCP clients).
Add this to your Claude Code MCP settings:
Option A: With environment variable (Recommended - Most Secure)
{
"mcpServers": {
"nano-banana": {
"command": "npx",
"args": ["nano-banana-mcp"],
"env": {
"GEMINI_API_KEY": "your-gemini-api-key-here"
}
}
}
}Option B: Without environment variable
{
"mcpServers": {
"nano-banana": {
"command": "npx",
"args": ["nano-banana-mcp"]
}
}
}Generate an image of a sunset over mountains
Edit this image to add some birds in the sky
Continue editing to make it more dramatic
Add to your Cursor MCP configuration:
Option A: With environment variable (Recommended)
{
"nano-banana": {
"command": "npx",
"args": ["nano-banana-mcp"],
"env": {
"GEMINI_API_KEY": "your-gemini-api-key-here"
}
}
}Option B: Without environment variable
{
"nano-banana": {
"command": "npx",
"args": ["nano-banana-mcp"]
}
}- Ask Cursor to generate images for your app
- Create mockups and prototypes
- Generate assets for your projects
If you're using a different MCP client, you can configure nano-banana-mcp using any of these methods:
Method A: Environment Variable in MCP Config (Recommended)
{
"nano-banana": {
"command": "npx",
"args": ["nano-banana-mcp"],
"env": {
"GEMINI_API_KEY": "your-gemini-api-key-here"
}
}
}Method B: System Environment Variable
export GEMINI_API_KEY="your-gemini-api-key-here"
npx nano-banana-mcpMethod C: Using the Configure Tool
npx nano-banana-mcp
# The server will prompt you to configure when first used
# This creates a local .nano-banana-config.json fileCreate a new image from a text prompt.
generate_image({
prompt: "A futuristic city at night with neon lights"
})Edit a specific image file.
edit_image({
imagePath: "/path/to/image.png",
prompt: "Add a rainbow in the sky",
referenceImages?: ["/path/to/reference.jpg"] // optional
})Continue editing the last generated/edited image.
continue_editing({
prompt: "Make it more colorful",
referenceImages?: ["/path/to/style.jpg"] // optional
})Get information about the last generated image.
get_last_image_info()Configure your Gemini API key.
configure_gemini_token({
apiKey: "your-gemini-api-key"
})Check if the API key is configured.
get_configuration_status()The MCP server loads your API key in the following priority order:
-
π₯ MCP Configuration Environment Variables (Highest Priority)
- Set in your
claude_desktop_config.jsonor MCP client config - Most secure as it's contained within the MCP configuration
- Example:
"env": { "GEMINI_API_KEY": "your-key" }
- Set in your
-
π₯ System Environment Variables
- Set in your shell/system environment
- Example:
export GEMINI_API_KEY="your-key"
-
π₯ Local Configuration File (Lowest Priority)
- Created when using the
configure_gemini_tokentool - Stored as
.nano-banana-config.jsonin current directory - Automatically ignored by Git and NPM
- Created when using the
π‘ Recommendation: Use Method 1 (MCP config env variables) for the best security and convenience.
Images are automatically saved to platform-appropriate locations:
- Windows:
%USERPROFILE%\\Documents\\nano-banana-images\\ - macOS/Linux:
./generated_imgs/(in current directory) - System directories:
~/nano-banana-images/(when run from system paths)
File naming convention:
- Generated images:
generated-[timestamp]-[id].png - Edited images:
edited-[timestamp]-[id].png
generate_image- Create your base imagecontinue_editing- Refine and improvecontinue_editing- Add final touches
generate_image- Create base contentedit_image- Use reference images for stylecontinue_editing- Fine-tune the result
generate_image- Start with a conceptget_last_image_info- Check current statecontinue_editing- Make adjustments- Repeat until satisfied
This project was created with Claude Code and follows these technologies:
- TypeScript - Type-safe development
- Node.js - Runtime environment
- Zod - Schema validation
- Google GenAI - Image generation API
- MCP SDK - Model Context Protocol
# Clone the repository
git clone https://github.com/claude-code/nano-banana-mcp.git
cd nano-banana-mcp
# Install dependencies
npm install
# Run in development mode
npm run dev
# Build for production
npm run build
# Run tests
npm test- Node.js 18.0.0 or higher
- Gemini API key from Google AI Studio
- Compatible with Claude Code, Cursor, and other MCP clients
This project was generated by Claude Code, but contributions are welcome! Please feel free to:
- Report bugs
- Suggest new features
- Submit pull requests
- Improve documentation
MIT License - see LICENSE file for details.
- Claude Code - For generating this entire project
- Google AI - For the powerful Gemini 2.5 Flash Image API
- Anthropic - For the Model Context Protocol
- Open Source Community - For the amazing tools and libraries
- π Issues: GitHub Issues
- π Documentation: This README and inline code comments
- π¬ Discussions: GitHub Discussions
β¨ Generated with love by Claude Code - The future of AI-powered development is here!