
用于 Cursor 的 MCP 服务器, 使用 Google Nano Banana Pro 生成、存储和再利用图像( 比 Antigravity 的图像工具更好)
概览
一个MCP(Model Context Protocol)服务器被优化用于网络开发,使AI助手能够使用Google的双子座API来生成并编辑图像. 在将 MCP 服务器添加到 Cursor 后, 只需提示 AI 为您生成或编辑图像 - 代理将完成其余的任务 。 - 生成具有外观比预设(英雄、正方形、肖像、地貌、横幅、移动)和分辨率的图像 - 用自然语言编辑您工作空间中已有的图像 - - 为常见的网络开发使用例设计的预设 - 作为 MCP 资源访问生成的图像 - - 直接访问 HTTP 图像的快取服务器 - Node.js 18+ - 一个谷歌双子座 API 密钥,可以访问图像生成 使用 MCP 检查器测试并调试您的服务器 : 此会: 1. 构建类型脚本代码 2. 在您的浏览器 3 中启动 MCP 检查器 。 允许您测试工具、查看资源和调试请求/响应 请在运行检查员前将您的.env文件与 GEMINI API KEY 建立起来.
概述(AI 翻译)
一个MCP(Model Context Protocol)服务器被优化用于网络开发,使AI助手能够使用Google的双子座API来生成并编辑图像.
在将 MCP 服务器添加到 Cursor 后, 只需提示 AI 为您生成或编辑图像 - 代理将完成其余的任务 。
□ 特性
- 图像生成 - 生成图像,其外观比预设(英雄、正方形、肖像、地貌、横幅、移动等)和分辨率可达4K
- 图像编辑 - 用自然语言编辑您工作空间中存在的图像
- Web-Optimized - 为常见的网络开发案例设计的预设
- ** MCP 资源** - 作为 MCP 资源访问生成的图像
- Statistic File Server - 直接访问图像的快取服务器
□ 先决条件
- 节点.js 18+
- 谷歌双子座 API 密钥,可访问图像生成
□ 安装
□ 配置
环境变量
·变量 · 要求 · 默认 · · 说明
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GEMINI_API_KEY ==== ========================================================================================================================================================================================================== (=========================================
QQ GEMINI_IMAGE_MODEL 第QQ [T2] [T2] 双子座图像模型要使用. 使用"基米尼-2"(Gemini-2).
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Gemini Image MCP
An MCP (Model Context Protocol) server optimized for web development that enables AI assistants to generate and edit images using Google’s Gemini API.
After adding the MCP server to Cursor, just prompt the AI to generate or edit images for you - the agent will do the rest.
Features
- Image Generation - Generate images with aspect ratio presets (hero, square, portrait, landscape, banner, mobile) and resolutions up to 4K
- Image Editing - Edit existing images in your workspace with natural language
- Web-Optimized - Presets designed for common web development use cases
- MCP Resources - Access generated images as MCP resources
- Static File Server - Express server for direct HTTP access to images
Prerequisites
- Node.js 18+
- A Google Gemini API key with access to image generation
Installation
git clone https://github.com/yourusername/gemini-image-mcp.git
cd gemini-image-mcp
npm install
npm run build
Configuration
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
GEMINI_API_KEY |
Yes | - | Your Google Gemini API key |
GEMINI_IMAGE_MODEL |
No | gemini-3-pro-image-preview |
Gemini image model to use. Use gemini-2.5-flash-image for the GA model. |
PORT |
No | 3001 |
Port for the Express static file server |
Cursor
Add to your ~/.cursor/mcp.json:
{
"mcpServers": {
"gemini-image": {
"command": "node",
"args": ["/path/to/gemini-image-mcp/dist/server.js"],
"env": {
"GEMINI_API_KEY": "your-api-key-here"
}
}
}
}
Antigravity
Add to your MCP server configuration:
{
"gemini-image": {
"command": "node",
"args": ["/path/to/gemini-image-mcp/dist/server.js"],
"env": {
"GEMINI_API_KEY": "your-api-key-here"
}
}
}
Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"gemini-image": {
"command": "node",
"args": ["/path/to/gemini-image-mcp/dist/server.js"],
"env": {
"GEMINI_API_KEY": "your-api-key-here"
}
}
}
}
Testing with MCP Inspector
Use the MCP Inspector to test and debug your server:
npm run inspect
This will:
- Build the TypeScript code
- Launch the MCP Inspector in your browser
- Allow you to test tools, view resources, and debug requests/responses
Make sure your .env file is set up with GEMINI_API_KEY before running the inspector.
Tools
generate_image
Generate an image from a text prompt, optionally using reference images to guide the style or composition. The AI must determine the correct output path in your project before calling this tool.
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"gemini-image": {
"command": "node",
"args": ["/path/to/gemini-image-mcp/dist/server.js"],
"env": {
"GEMINI_API_KEY": "your-api-key-here"
}
}
}
}