图像生成MCP服务器

一款基于Google Gemini API的MCP服务器,为AI代理提供图像生成、编辑和分析功能。

  • by easy-to-use-ai
  • TypeScript
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 easy-to-use-ai/nano-banana-pro-mcp

使用说明

纳米香蕉亲mcp

🔥 Now supports Nano Banana 2 (gemini-3.1-flash-image-preview) — Google's latest and most capable image generation model


一 MCP(模型上下文协议) 为人工智能代理(Claude、Gemini、Codex等)提供以下功能的服务器 生成、编辑和分析图像 通过谷歌的Gemini图像生成API。

为什么选择Nano Banana 2?

纳米香蕉2 (gemini-3.1-flash-image-preview)是谷歌最新的图像生成模型,与前代相比有了重大改进:

  • 更高的保真度 --更清晰的细节、更好的照明/纹理、反光表面和动态场景
  • 更好的指导 --更准确地解释复杂的提示和作文
  • 原生文本渲染 --在图像中生成可读文本,实现了重大飞跃
  • 速度提高2倍,价格降低50% -API提供约2s/image,高达350+图像/分钟,价格为0.067/图像(1K)
  • 14宽高比 --新型超宽 8:1, 4:1 超高 1:8, 1:4 用于横幅、全景图、信息图表
  • 512像素至4K分辨率 --新的低分辨率 512px 快速迭代选项 1K, 2K, 4K
  • 谷歌搜索停飞 --实时网络搜索准确的信息图表、天气、产品和时事
  • 增强一致性 --在一代中最多可维护5个字符和14个对象
  • 思维方式 --复杂组合的可选深度推理和精确文本渲染

此MCP服务器默认为Nano Banana 2,使您的AI代理可以开箱即用地访问谷歌最好的图像生成功能。


支持的型号

型号 别名 亮点
gemini-3.1-flash-image-preview 纳米香蕉2 ⭐ 最新&推荐。最佳质量、文本渲染、快速
gemini-3-pro-image-preview Nano Banana Pro 复杂场景的最高质量
gemini-2.5-flash-preview-05-20 纳米香蕉 速度和质量平衡
gemini-2.0-flash-exp -- 广泛可用的回退

快速开始

1.获取免费的API密钥

从获取Gemini API密钥 谷歌人工智能工作室 --它是免费的。

2.安装

选择您的平台:

Claude Code CLI
claude mcp add nano-banana-pro --env GEMINI_API_KEY=your_api_key_here -- npx @easyuseai/nano-banana-pro-mcp
Cursor

添加到光标MCP设置(.cursor/mcp.json):

{
  "mcpServers": {
    "nano-banana-pro": {
      "command": "npx",
      "args": ["@easyuseai/nano-banana-pro-mcp"],
      "env": {
        "GEMINI_API_KEY": "your_api_key_here"
      }
    }
  }
}
Claude Desktop

添加到您的配置文件中:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • 视窗: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "nano-banana-pro": {
      "command": "npx",
      "args": ["@easyuseai/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": ["@easyuseai/nano-banana-pro-mcp"],
      "env": {
        "GEMINI_API_KEY": "your_api_key_here"
      }
    }
  }
}
Gemini CLI

创建或编辑 ~/.gemini/settings.json:

{
  "mcpServers": {
    "nano-banana-pro": {
      "command": "npx",
      "args": ["@easyuseai/nano-banana-pro-mcp"],
      "env": {
        "GEMINI_API_KEY": "your_api_key_here"
      }
    }
  }
}

3.使用它

只需让你的AI代理生成图像,它就会自动使用MCP工具。

Generate a hero image of a sunset over Santorini, 16:9 aspect ratio, 4K

Generate an 8:1 ultra-wide banner of a modern cityscape in the style of 清明上河图

Generate today's weather infographic for Tokyo with Google Search enabled

Edit this photo: add a dramatic sky and warm color grading

Describe what's in this screenshot

工具

generate_image

根据文本描述生成图像。可选择提供参考图像以进行样式/内容指导。

参数 必填 说明
prompt ✅ 要生成的图像的文本描述
model Gemini模型(默认值: gemini-3.1-flash-image-preview)
aspectRatio 1:1 · 3:2 · 2:3 · 3:4 · 4:3 · 4:5 · 5:4 · 9:16 · 16:9 · 21:9 · 4:1 · 1:4 · 8:1 · 1:8
imageSize 512px · 1K · 2K · 4K
images 参考图像 [{ data, mimeType }] (最多10个对象+4个人参考文献)
outputPath 保存图像的文件路径
useGoogleSearch 为固定生成启用实时网络搜索(默认值: false)
personGeneration ALLOW_ALL · ALLOW_ADULT · ALLOW_NONE
thinkingConfig { thinkingLevel, includeThoughts } 用于复杂场景

edit_image

根据指示编辑一个或多个现有图像。

参数 必填 说明
prompt ✅ 编辑说明
images ✅ 要编辑的图像 [{ data, mimeType }]
model Gemini模型(默认值: gemini-3.1-flash-image-preview)
outputPath 保存结果的文件路径
personGeneration ALLOW_ALL · ALLOW_ADULT · ALLOW_NONE

describe_image

分析和描述图像。仅返回文本。

参数 必填 说明
images ✅ 要分析的图像 [{ data, mimeType }]
prompt 自定义分析提示
model Gemini模型(默认值: gemini-3.1-flash-image-preview)

提示模板

服务器包括 17个内置提示模板 通过Nano Banana 2的新功能展示最佳实践和创意工作流程。AI代理可以通过MCP提示协议发现和使用这些。

使用Claude Desktop或任何兼容MCP的客户端,您可以选择一个提示模板并填写参数:

Use the "scroll_painting_panorama" prompt:
  city: Hangzhou
  variant: ghibli
  resolution: 4K

1. ultra_wide_panorama --超宽城市全景

8:1专属比例·网站横幅、户外广告、墙画

2. weather_infographic --实时天气信息图

谷歌搜索基础·准确的实时数据可视化

3. ecommerce_banner --电子商务产品横幅

4:1独家比例·产品促销、电子邮件活动

4. product_detail_long --垂直产品详细信息页面

1:4独家比例+思考·移动产品页面、Instagram故事

5. scroll_painting_panorama --中国卷轴画全景

8:1 ratio + Thinking · 清明上河图 style modern cityscapes

6. resize_and_enhance --调整和增强图像大小

14种灵活的比率·跨平台调整内容

7. character_multi_scene --角色一致性多场景

增强一致性·故事板、虚拟影响者内容

8. knowledge_card --搜索基础知识卡

谷歌搜索+思考·教育内容、物种简介

9. comic_storyboard --漫画/故事板面板

思考+一致性·网络漫画、宣传片

10. brand_logo_system --品牌标志和视觉识别

4K+思维·标志设计、品牌标识表

11. whiteboard_infographic --白板贴纸信息图

标记绘制的图表·文章插图、教程、解释者

12. minimalist_cover --极简主义负空间封面

仅2-3种颜色·笔记本封面、书籍封面、品牌文具

13. vertical_comic_strip --垂直连环画(9:16)

9:16比例+思考·网络卡通、社交媒体故事、手机漫画

14. ecommerce_product_suite --电子商务产品形象套件

多镜头工作流程·英雄、生活方式和功能调出图像

15. blindbox_miniature_store --品牌盲盒迷你店

3D Q版+思考·品牌社交媒体、商品概念

16. timeline_illustration --超长时间线插图

8:1或1:8的比例+思考·历史、产品演变、里程碑

17. city_food_culture_card --城市×美食×文化融合卡

3D立体+思维·旅游推广、城市IP、文化内容


发展

npm install          # Install dependencies
npm run build        # Compile TypeScript
npm test             # Run unit tests
npm run test:watch   # Tests in watch mode
npm run typecheck    # Type check only

手动测试

GEMINI_API_KEY=your_key npm run test:manual "a cute cat wearing sunglasses"

MCP检查员

npx @modelcontextprotocol/inspector node dist/index.js

许可证

麻省理工学院