NanoBananaPro
Use Nano Banana Pro to generate image from text prompt and edit image
README
<h1>genai-mcp: GenAI MCP Server for Image Generation(eg. Nano Banana)</h1>
GenAI MCP Server
This project implements a Model Context Protocol (MCP) server for image generation and image editing using Google Gemini (via google.golang.org/genai) and Tongyi Wanxiang (Ali Bailian) image APIs, plus optional automatic upload of generated images to S3‑compatible object storage (AWS S3, Aliyun OSS, etc.).
The server exposes a streamable HTTP MCP endpoint and provides tools for Gemini and Wan:
gemini_generate_image– text → imagegemini_edit_image– image + text → edited image
Gemini / Nano Banana backend support
This MCP server currently supports the following Gemini‑compatible backends:
-
Google official Gemini API
- Use the default
GENAI_BASE_URL=https://generativelanguage.googleapis.com GENAI_API_KEYis a Google Gemini API key
- Use the default
-
dmxapi (Gemini‑compatible third‑party gateway)
- Set
GENAI_BASE_URLto the dmxapi Gemini endpoint (for examplehttps://www.dmxapi.cn) GENAI_API_KEYis the key issued by dmxapi- As long as the endpoint implements the
google.golang.org/genaicompatible Gemini API, no code changes are needed
- Set
Tongyi Wanxiang (Ali Bailian) backend support
When GENAI_PROVIDER=wan, the server will use Ali Bailian Tongyi Wanxiang image APIs (via DashScope) instead of Gemini:
- Set:
GENAI_PROVIDER=wanGENAI_BASE_URL=https://dashscope.aliyuncs.comGENAI_API_KEY=<your DashScope API key>GENAI_GEN_MODEL_NAME=wan2.5-t2i-preview(text → image)GENAI_EDIT_MODEL_NAME=wan2.5-i2i-preview(image → image)
- Wan provides a separate MCP tool set (see
internal/tools/wan.go):wan_create_generate_image_taskwan_query_generate_image_taskwan_create_edit_image_taskwan_query_edit_image_task
The Python test client in tests/mcp_client.py will automatically route calls to Gemini or Wan based on GENAI_PROVIDER (gemini by default, wan for Tongyi Wanxiang).
1. Prerequisites
- Go 1.21+ (recommended;
go.moduses module mode) - A valid Gemini API key
- Optional: S3 / OSS bucket for storing images
2. Configuration (.env)
Copy env.example to .env, then fill in real values.
GenAI configuration
# GenAI provider:
# - gemini: Google Gemini / compatible backend
# - wan: Ali Bailian Tongyi Wanxiang image APIs
GENAI_PROVIDER=gemini
# Shared GenAI endpoint / key for both providers
GENAI_BASE_URL=https://generativelanguage.googleapis.com
GENAI_API_KEY=your_api_key_here
# Model names:
# - When GENAI_PROVIDER=gemini: Gemini model names, e.g. gemini-3-pro-image-preview
# - When GENAI_PROVIDER=wan: Wanxiang model names, e.g. wan2.5-t2i-preview / wan2.5-i2i-preview
GENAI_GEN_MODEL_NAME=gemini-3-pro-image-preview
GENAI_EDIT_MODEL_NAME=gemini-3-pro-image-preview
# Request timeout in seconds for each GenAI call (generate / edit)
GENAI_TIMEOUT_SECONDS=120
# Image output format:
# - base64: return image as data URI (base64 encoded)
# - url: upload image to OSS and return plain URL
GENAI_IMAGE_FORMAT=base64
HTTP server
SERVER_ADDRESS=0.0.0.0
SERVER_PORT=8080
MCP endpoint will listen on:
http://SERVER_ADDRESS:SERVER_PORT/mcp
OSS / S3 configuration (optional, required when GENAI_IMAGE_FORMAT=url)
# For AWS S3: leave OSS_ENDPOINT empty or set to s3.amazonaws.com
# For Aliyun OSS: set to oss-cn-hangzhou.aliyuncs.com or your region
# For Tencent COS: set to cos.ap-guangzhou.myqcloud.com
# For MinIO: set to your MinIO endpoint
OSS_ENDPOINT=
OSS_REGION=us-east-1
OSS_ACCESS_KEY=your_access_key_here
OSS_SECRET_KEY=your_secret_key_here
OSS_BUCKET=your_bucket_name
When GENAI_IMAGE_FORMAT=url:
- For Aliyun OSS: make sure
OSS_ENDPOINTis likeoss-cn-beijing.aliyuncs.com- The bucket policy allows read access if you expect the returned URL to be publicly accessible
3. Running the MCP Server
You can run the MCP server in two ways:
-
Clone & build from source
-
Clone this repo and enter the project root
-
Copy
env.exampleto.envand fill in your configuration -
Run:
go build . ./genai-mcp
-
-
Download release binary
-
Download the appropriate binary from the Releases page
-
Place it in a directory of your choice
-
Copy
env.examplefrom this repo (or from the release asset) to.envin the same directory and update configuration -
Run (binary name may vary by platform):
./genai-mcp
-
By default the MCP HTTP endpoint will be:
http://127.0.0.1:8080/mcp
You can connect to this MCP endpoint from any MCP‑compatible client (e.g. Code editors or tools that support the streamable HTTP MCP transport).
4. MCP Tools
The server registers two tools in internal/tools/gemini.go:
-
gemini_generate_image- Input:
prompt(string, required): text prompt describing the image
- Output:
- When
GENAI_IMAGE_FORMAT=base64: adata:image/...;base64,...string - When
GENAI_IMAGE_FORMAT=url: an OSS/S3 URL generated by the server
- When
- Input:
-
gemini_edit_image- Input:
prompt(string, required): how to edit the imageimage_url(string, required): original image URL or data URI
- Output:
- Same format as above (
base64orurl), depending on configuration
- Same format as above (
- Input:
When GENAI_IMAGE_FORMAT=url:
- Generated / edited images are:
- Downloaded (if Gemini returns a URL), or decoded (if it returns inline data)
- Re‑uploaded to OSS / S3
- Stored under key pattern:
images/yyyy-MM-dd/{uuid_timestamp_random}.ext
5. Contact
-
WeChat: Scan the QR code below to add as a friend

-
Discord: Username
adamydwang
Star History
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.