Nano Banana Pro MCP服务器
 
一 MCP(模型上下文协议) 服务器带来 谷歌双子座2.0 Flash 将原生图像生成功能直接集成到Claude Code和其他MCP兼容的AI助手中。
使用自然语言生成、编辑和合成图像,所有这些都无需离开您的编码环境。
特性
- 生成图像:根据文本提示创建高质量图像(高达4K分辨率)
- 编辑图像:使用文本指令修改现有图像
- 继续编辑:迭代优化上次生成的图像
- 合成图像:将多达14幅参考图像组合成新的构图
- 谷歌搜索暂停:根据实时信息生成图像
- 多宽高比:支持1:1、16:9、9:16、4:3、3:4等
- 高分辨率:以1K、2K或4K分辨率输出
先决条件
- Docker桌面已安装并正在运行
- Gemini API密钥来自 谷歌AI工作室
快速开始
1.构建Docker镜像
cd nano-banana-pro-mcp
docker build -t nano-banana-pro-mcp .2.创建输出目录
mkdir -p output input3.添加到克劳德代码
使用以下方法之一将MCP服务器添加到Claude Code:
选项A:使用claude mcp add(推荐)
claude mcp add nano-banana-pro \
--transport stdio \
-- docker run -i --rm \
-e GEMINI_API_KEY=$GEMINI_API_KEY \
-v $(pwd)/output:/output \
-v $(pwd)/input:/input:ro \
nano-banana-pro-mcp选项B:手动配置
添加到您的Claude Code MCP配置文件中(~/.claude/claude_desktop_config.json 或类似):
{
"mcpServers": {
"nano-banana-pro": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "GEMINI_API_KEY",
"-v", "/path/to/output:/output",
"-v", "/path/to/input:/input:ro",
"nano-banana-pro-mcp"
],
"env": {
"GEMINI_API_KEY": "your-api-key-here"
}
}
}
}可用工具
generate_image
从文本提示生成新图像。
参数:
prompt(必填):要创建的图像的文本描述aspectRatio(可选):1:1、2:3、3:2、3:4、4:3、4:5、5:4、9:16、16:9、21:9resolution(可选):1K、2K或4KuseGoogleSearch(可选):启用实时信息接地
例子:
Generate a professional hero image for a tech startup website, showing a
modern office with developers collaborating, 16:9 aspect ratio, 2K resolutionedit_image
使用文本指令编辑现有图像。
参数:
imagePath(必填):图像文件的路径prompt(必填):修改说明referenceImages(可选):参考图像路径数组aspectRatio(可选):输出纵横比resolution(可选):输出分辨率
例子:
Edit /input/logo.png - Change the background color to gradient blue and
add a subtle glow effect around the textcontinue_editing
继续编辑上次生成/编辑的图像。
参数:
prompt(必填):附加修改说明referenceImages(可选):用于风格转换的参考图像等。aspectRatio(可选):输出纵横比resolution(可选):输出分辨率
例子:
Make the colors more vibrant and add a subtle drop shadowcompose_images
将多幅图像组合成一幅新的构图。
参数:
images(必填):图像路径阵列(最多14个)prompt(必填):如何组合图像aspectRatio(可选):输出纵横比resolution(可选):输出分辨率
例子:
Compose these product photos into a professional catalog layout
with consistent lighting and white backgroundget_last_image_info
获取有关上次生成的图像的信息。
get_configuration_status
检查API密钥是否已配置。
最佳结果提示
- 具有描述性你的提示越详细,结果就越好
- 使用摄影术语:对于逼真的图像,请提及相机角度、镜头类型、照明
- 迭代:使用
continue_editing逐步优化图像 - 参考图像:最多使用14个参考图像,以实现字符一致性或风格转换
- 谷歌搜索:启用实时数据,如天气、新闻或时事
输出位置
生成的图像保存到 /output 目录(从装载 ./output 在您的主机上)。
故障排除
“未设置GEMINI_API_KEY”
确保您的API密钥已在您的环境中设置:
export GEMINI_API_KEY="your-key-here"图像未显示
检查 ./output 您主机上的目录。确保卷装载正确。
Docker权限问题
在Linux上,您可能需要运行:
sudo chown -R $USER:$USER output发展
要在没有Docker的情况下在本地运行:
npm install
npm run build
GEMINI_API_KEY=your-key OUTPUT_DIR=./output npm start贡献
欢迎投稿!请随时提交拉取请求。
许可证
麻省理工学院
