Back to MCP directory
publicPublicdnsLocal runtime

mcp-nano-banana

一个基于Google Gemini API的MCP服务器,提供图像生成功能,支持通过文本提示创建图像并自动上传到ImgBB图床。

article

README

🚀 MCP Nano Banana

MCP Nano Banana是一个基于MCP(模型上下文协议)的服务器项目,它借助Google Gemini API来生成图像,为AI模型提供了便捷的图像生成能力。

🚀 快速开始

若要使用此服务器与Claude Desktop或其他应用协同工作,你需要获取Google Gemini API密钥和ImgBB API密钥。

  • 访问 ImgBB API 生成IMGBB API密钥,该密钥用于在线存储和托管图像。
  • 配置相关信息,示例如下:
{
  "mcpServers": {
    "mcp-nano-banana": {
        "command": "uvx",
        "args": [
            "mcp-nano-banana"
        ],
        "env": {
            "GEMINI_API_KEY": "YOUR_API_KEY_HERE",
            "IMGBB_API_KEY": "YOUR_API_KEY_HERE"
        }
    }
  }
}

✨ 主要特性

此服务器实现了模型上下文协议,向兼容的AI模型公开了一个名为 generate_image 的工具。该工具接收文本提示,通过Google Gemini API生成图像,将图像保存到 public/ 目录以便审核,并以Base64编码的字符串形式返回原始图像数据。

📦 安装指南

1. 依赖安装

本项目使用Python,其依赖项在 pyproject.toml 中定义。你可以使用 pip 进行安装:

pip install .
# 或者
uv sync

这将安装 mcpgoogle-generativeai 等所需的包。

2. API密钥配置

你需要Google Gemini API密钥和ImgBB API密钥才能使用此服务器。

  • 访问 ImgBB API 生成IMGBB API密钥,用于在线存储和托管图像。
  • 在项目根目录下创建一个名为 .env 的文件。
  • 按以下格式将API密钥添加到 .env 文件中:
GEMINI_API_KEY="YOUR_API_KEY_HERE"
IMGBB_API_KEY="YOUR_API_KEY_HERE"

💻 使用示例

运行服务器

此服务器设计为由MCP客户端作为子进程运行,或使用 mcp 命令行工具运行。服务器通过 stdio 监听请求。

uvx --from git+https://github.com/GuilhermeAumo/mcp-nano-banana mcp-nano-banana

📚 详细文档

发布新的Pipy版本

若要将此包的新版本发布到PyPI,请按以下步骤操作:

  1. 更新版本号:编辑 pyproject.toml 中的 version 字段,将其更新为新的版本号。
  2. 构建包:运行以下命令,这将在 dist/ 目录下创建 .tar.gz.whl 文件。
uv build
  1. 上传到PyPI
uv publish
  1. 标记版本(可选但推荐):先将更改提交到GitHub,然后执行以下命令:
git tag v<new-version>
git push --tags

注意:你需要拥有PyPI账户,并且必须是该项目的维护者之一。更多详细信息,请参阅 Python打包用户指南

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client