使用说明
🍌 纳米香蕉MCP
一种模型上下文协议(MCP)服务器,用于使用Google Gemini的图像生成模型生成和编辑图像。
特性
- 图像生成 -根据文本提示生成图像
- 图像编辑 -使用文本指令编辑现有图像
- 多种型号 -在快速(Flash)和优质(Pro)型号之间进行选择
- 纵横比 -支持10种不同的宽高比
- 高分辨率 -Pro型号输出高达4K
设置
1.安装依赖项
npm install
2.配置API密钥
创建一个 .env 项目根目录中的文件:
GOOGLE_API_KEY=your_google_api_key_here
从获取API密钥 谷歌AI工作室.
3.建造
npm run build
4.配置MCP客户端
添加到您的MCP客户端配置中(例如,Claude Desktop、VS Code):
{
"mcpServers": {
"nano-banana": {
"command": "node",
"args": ["path/to/nano-banana-mcp/dist/index.js"]
}
}
}
工具
generate_image
从文本提示生成图像。
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
prompt |
string | ✅ | - | 图片的详细英文描述 |
filename |
string | ✅ | - | 输出文件名(例如。, image.png) |
relativePath |
string | ✅ | - | 保存图像的文件夹 |
model |
string | ❌ | gemini-2.5-flash-image |
要使用的模型 |
aspectRatio |
string | ❌ | 1:1 |
图像纵横比 |
imageSize |
string | ❌ | 1K |
分辨率(仅限Pro型号) |
edit_image
使用文本提示编辑现有图像。
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
prompt |
string | ✅ | - | 更改内容的描述 |
inputImagePath |
string | ✅ | - | 输入图像的路径 |
filename |
string | ✅ | - | 输出文件名 |
relativePath |
string | ✅ | - | 保存图像的文件夹 |
model |
string | ❌ | gemini-2.5-flash-image |
要使用的模型 |
aspectRatio |
string | ❌ | 1:1 |
输出纵横比 |
imageSize |
string | ❌ | 1K |
分辨率(仅限Pro型号) |
模型
| 型号 | 速度 | 最大输入图像 | 最大分辨率 | 最适合 |
|---|---|---|---|---|
gemini-2.5-flash-image |
⚡ 快速 | 3 | 1024px | 快速迭代,草稿 |
gemini-3-pro-image-preview |
🎨 质量 | 14 | 4K | 最终资产,复杂场景 |
纵横比
| 比率 | 用例 |
|---|---|
1:1 |
社交媒体帖子、头像 |
16:9 |
YouTube缩略图、演示文稿 |
9:16 |
instagram/fold故事 |
4:3 |
传统照片 |
3:2 |
经典摄影 |
21:9 |
超宽影院 |
2:3, 3:4, 4:5, 5:4 |
各种肖像/风景 |
图像尺寸(仅限专业型号)
| 大小 | 分辨率 |
|---|---|
1K |
1024px |
2K |
2048像素 |
4K |
4096px |
使用示例
使用不同的模型
快速生成(Flash):
Generate an image of a mountain landscape at sunset
- filename: mountain.png
- relativePath: images
- model: gemini-2.5-flash-image
高品质(Pro):
Generate a detailed architectural visualization of a modern house
- filename: house.png
- relativePath: images
- model: gemini-3-pro-image-preview
使用纵横比
广场(社交媒体帖子):
Generate a logo for a coffee shop called "Bean There"
- filename: logo.png
- relativePath: branding
- aspectRatio: 1:1
风景(YouTube缩略图):
Generate an eye-catching thumbnail for a cooking video
- filename: thumbnail.png
- relativePath: youtube
- aspectRatio: 16:9
肖像(Instagram故事):
Generate a motivational quote background with mountains
- filename: story.png
- relativePath: social
- aspectRatio: 9:16
电影(超宽横幅):
Generate a sci-fi cityscape panorama
- filename: banner.png
- relativePath: website
- aspectRatio: 21:9
使用图像尺寸(仅限专业型号)
标准(1K):
Generate a blog post illustration
- filename: blog.png
- relativePath: content
- model: gemini-3-pro-image-preview
- imageSize: 1K
高分辨率(2K):
Generate a detailed infographic about climate change
- filename: infographic.png
- relativePath: content
- model: gemini-3-pro-image-preview
- imageSize: 2K
超高分辨率(4K):
Generate a print-ready poster for a music festival
- filename: poster.png
- relativePath: print
- model: gemini-3-pro-image-preview
- imageSize: 4K
- aspectRatio: 2:3
组合选项
专业产品拍摄:
Generate a studio photograph of a luxury watch on black velvet
- filename: watch.png
- relativePath: products
- model: gemini-3-pro-image-preview
- aspectRatio: 4:3
- imageSize: 4K
社交媒体活动:
Generate a vibrant summer sale announcement graphic
- filename: sale.png
- relativePath: marketing
- model: gemini-2.5-flash-image
- aspectRatio: 1:1
图像编辑示例
添加元素:
Add a rainbow in the sky
- inputImagePath: images/landscape.png
- filename: landscape-rainbow.png
- relativePath: images
删除元素:
Remove the person from the background
- inputImagePath: photos/beach.jpg
- filename: beach-clean.png
- relativePath: photos
风格转换:
Transform this photo into a watercolor painting
- inputImagePath: photos/portrait.jpg
- filename: portrait-watercolor.png
- relativePath: art
- model: gemini-3-pro-image-preview
更改背景:
Replace the background with a professional office setting
- inputImagePath: photos/headshot.jpg
- filename: headshot-office.png
- relativePath: photos
- aspectRatio: 1:1
提示提示
以获得最佳效果
- 具体 -详细描述场景:灯光、颜色、风格、构图
- 使用摄影术语 -“广角拍摄”、“柔和照明”、“散景背景”
- 指定样式 -“照片级真实感”、“水彩”、“3D渲染”、“动漫风格”
- 包含上下文 -“科技创业网站”、“儿童图书插图”
示例提示
照片级真实感:
A photorealistic close-up portrait of a coffee cup on a wooden table,
morning sunlight streaming through a window, soft bokeh background,
warm color palette, shot with a 50mm lens
风格化:
A kawaii-style sticker of a happy golden retriever puppy,
pastel colors, thick black outlines, transparent background,
cute anime aesthetic
产品拍摄:
A high-resolution studio product photograph of a minimalist
white sneaker on a gradient gray background, three-point
lighting setup, ultra-sharp focus, commercial photography style
用于图像编辑
Add a red hat to the person in the image
Change the background to a sunset beach scene
Remove the text from the image and fill with matching background
Transform this sketch into a photorealistic image
许可证
麻省理工学院