Provides access to Google Gemini models (defaulting to Gemini 3 Pro Image Preview) through the OpenRouter API, supporting chat completions with both text and image input capabilities.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@NanoBanana MCP ServerList all the available models from OpenRouter"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
NanoBanana MCP Server
一个封装 OpenRouter API 的 MCP (Model Context Protocol) 服务器,可供 Claude Code CLI、Claude Desktop 等 MCP 客户端使用。
功能特性
🚀 通过 MCP 协议访问 OpenRouter API
🤖 默认使用 Google Gemini 3 Pro Image Preview 模型
💬 支持聊天补全(Chat Completion)
📋 支持列出所有可用模型
🖼️ 支持文本和图像输入
📦 安装
方式 1: 通过 uvx(推荐)
使用 uvx 直接从 GitHub 运行,无需克隆仓库:
在 Claude Code CLI 中配置
编辑 Claude Code 配置文件并添加:
在 Claude Desktop 中配置
使用相同的配置格式。
方式 2: 克隆仓库(用于开发)
在 Claude Code CLI 中配置
在 Claude Desktop 中配置
使用相同的配置格式。
🔑 获取 OpenRouter API Key
⚠️ 必需步骤:
访问 OpenRouter
注册/登录账号
在 API Keys 页面 创建新的 API Key
复制您的 API Key(格式:
sk-or-v1-...)在 Claude Desktop 配置的
env部分填入
配置说明
API URL: https://openrouter.ai/api/v1
默认模型: google/gemini-3-pro-image-preview
配置文件位置:
Claude Code CLI:
Windows:
%APPDATA%\Claude Code\config.jsonmacOS:
~/Library/Application Support/Claude Code/config.jsonLinux:
~/.config/claude-code/config.json
Claude Desktop:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
⚠️ 重要:
将
sk-or-v1-your-actual-key-here替换为您的实际 API Key如果使用方式 2,将
/path/to/nano_banana替换为实际路径配置完成后重启 Claude Code CLI 或 Claude Desktop
🎨 使用方法
在 Claude Code CLI 中使用
配置完成后,在终端中启动 Claude Code,直接描述您的需求:
Claude 会自动:
理解您的需求
生成详细的提示词
调用 MCP 图像生成工具
返回 2 张高质量图片(base64 格式)
在 Claude Desktop 中使用
使用方式与 Claude Code CLI 相同,直接用自然语言描述需求即可。
直接测试(开发用)
可以使用 MCP Inspector 进行测试:
可用工具
1. chat_completion
发送聊天补全请求到 OpenRouter API。
参数:
messages(必需): 消息数组,每个消息包含role和contentrole: "user", "assistant", 或 "system"content: 消息内容(文本或图像 URL)
model(可选): 使用的模型,默认为google/gemini-3-pro-image-previewtemperature(可选): 采样温度 (0-2),默认为 1max_tokens(可选): 生成的最大 token 数stream(可选): 是否流式返回,默认为 false
示例:
2. list_models
列出 OpenRouter API 上所有可用的模型。
参数: 无
可用资源
nano-banana://config
返回 NanoBanana MCP Server 的配置信息,包括 API URL 和默认模型。
架构说明
开发说明
项目结构
修改配置
如需修改 API Key 或默认模型,请编辑 mcp_server.py 中的以下常量:
添加新工具
在 mcp_server.py 中:
在
list_tools()函数中添加新工具的定义在
call_tool()函数中添加工具调用逻辑实现具体的工具函数
故障排除
问题:Claude Desktop 无法连接到 MCP 服务器
解决方案:
检查 Python 是否在系统 PATH 中
确认
mcp_server.py的路径正确查看 Claude Desktop 的日志文件
尝试手动运行
python mcp_server.py检查是否有错误
问题:API 请求失败
解决方案:
检查 API Key 是否有效
确认网络连接正常
查看 OpenRouter API 状态页面
检查是否超出 API 配额
问题:依赖安装失败
解决方案:
许可证
MIT License
贡献
欢迎提交 Issue 和 Pull Request!