使用说明
纳米香蕉亲mcp
MCP服务器,使克劳德等人工智能代理能够使用谷歌的Gemini图像生成模型(包括Nano Banana Pro-Gemini-3-Pro-image-preview)生成图像。
注: 我认为谷歌反重力可以使用纳米香蕉生成图像很酷,所以我偷了这个想法。
示例
以下是Claude Code使用MCP为旅行登录页面生成英雄图像:
美丽的结果:
安装
克劳德代码CLI
claude mcp add nano-banana-pro --env GEMINI_API_KEY=your_api_key_here -- npx @rafarafarafa/nano-banana-pro-mcp
替换 your_api_key_here 使用您的实际Gemini API密钥。
克劳德桌面版
添加到您的Claude Desktop配置文件中:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
视窗: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"nano-banana-pro": {
"command": "npx",
"args": ["@rafarafarafa/nano-banana-pro-mcp"],
"env": {
"GEMINI_API_KEY": "your_api_key_here"
}
}
}
}
Codex CLI
创建或编辑 .mcp.json 在您的项目目录中(或 ~/.mcp.json 全局配置):
{
"mcpServers": {
"nano-banana-pro": {
"command": "npx",
"args": ["@rafarafarafa/nano-banana-pro-mcp"],
"env": {
"GEMINI_API_KEY": "your_api_key_here"
}
}
}
}
双子星命令行工具
创建或编辑 ~/.gemini/settings.json:
{
"mcpServers": {
"nano-banana-pro": {
"command": "npx",
"args": ["@rafarafarafa/nano-banana-pro-mcp"],
"env": {
"GEMINI_API_KEY": "your_api_key_here"
}
}
}
}
获取API密钥
从获取免费Gemini API密钥 谷歌AI工作室.
可用工具
generate_image
从文本提示生成图像。可选地提供参考图像以指导样式或内容。
参数:
prompt(必填):要生成的图像的描述model(可选):要使用的Gemini模型(默认值:gemini-3-pro-image-preview)gemini-3-pro-image-preview-Nano Banana Pro(最高品质)gemini-2.5-flash-preview-05-20-纳米香蕉(快)gemini-2.0-flash-exp-广泛可用的回退
aspectRatio(可选):"1:1"|"3:4"|"4:3"|"9:16"|"16:9"imageSize(可选):"1K"|"2K"|"4K"(仅适用于图像特定型号)images(可选):用于指导生成的参考图像数组- 每张图片:
{ data: "base64...", mimeType: "image/png" }
- 每张图片:
outputPath(可选):保存生成图像的文件路径(例如。,/path/to/image.png)
示例提示:
Generate an image of a sunset over mountains
Generate a logo in the style of this reference image [with image attached]
Generate a hero image and save it to ./assets/hero.png
edit_image
根据指示编辑一个或多个图像。
参数:
prompt(必填):如何编辑图像的说明images(必填):要编辑的图像数组- 每张图片:
{ data: "base64...", mimeType: "image/png" }
- 每张图片:
model(可选):要使用的Gemini模型(默认值:gemini-3-pro-image-preview)outputPath(可选):保存编辑图像的文件路径(例如。,/path/to/image.png)
示例提示:
Add sunglasses to this photo
Remove the background from this image
Combine these two images into one scene
describe_image
分析并描述一个或多个图像。仅返回文本(不生成图像)。
参数:
images(必填):要分析的图像数组- 每张图片:
{ data: "base64...", mimeType: "image/png" }
- 每张图片:
prompt(可选):自定义分析提示(默认:一般描述)model(可选):要使用的Gemini模型(默认值:gemini-3-pro-image-preview)
示例提示:
[default] Describe this image in detail
What objects are in this image?
How many people are in this photo?
What's the dominant color in this image?
发展
设置
npm install
npm run build
测试
npm test # Run unit tests
npm run test:watch # Run tests in watch mode
npm run typecheck # Type check without emitting
手动测试
# Generate a real image and save to test-output.png
GEMINI_API_KEY=your_key npm run test:manual "a cute cat wearing sunglasses"
MCP检验员测试
npx @modelcontextprotocol/inspector node dist/index.js
然后设置 GEMINI_API_KEY 在检查员的环境中,并致电 generate_image 工具。
许可证
麻省理工学院
