Provides tools for generating images from text prompts and editing existing images using Google Gemini's image generation APIs, with support for both official Gemini API and Gemini-compatible third-party gateways.
Supports uploading generated and edited images to MinIO object storage, returning accessible URLs for the stored images.
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.comGENAI_API_KEYis a Google Gemini API key
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 dmxapiAs long as the endpoint implements the
google.golang.org/genaicompatible Gemini API, no code changes are needed
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
HTTP server
MCP endpoint will listen on:
OSS / S3 configuration (optional, required when
When GENAI_IMAGE_FORMAT=url:
For Aliyun OSS: make sure
OSS_ENDPOINTis likeoss-cn-beijing.aliyuncs.comThe 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 configurationRun:
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 configurationRun (binary name may vary by platform):
./genai-mcp
By default the MCP HTTP endpoint will be:
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_imageInput:
prompt(string, required): text prompt describing the image
Output:
When
GENAI_IMAGE_FORMAT=base64: adata:image/...;base64,...stringWhen
GENAI_IMAGE_FORMAT=url: an OSS/S3 URL generated by the server
gemini_edit_imageInput:
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
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