使用说明
Gemini Image MCP Server
一个MCP(模型上下文协议)服务器,使用谷歌的Gemini模型提供AI图像生成工具。支持单张和批量图像生成、多个参考图像、WebP转换和直接WordPress上传。
特性
- 两个质量等级 --Pro(Gemini 3 Pro图像预览,最高4K)和快速(Gemini 2.5 Flash图像,最大1K)
- 参考图像 --每代最多14个参考图像(Pro模式)
- 批量生成 --将多个图像排队,查看,然后在一次运行中生成
- WebP转换 --将PNG/JPG转换为WebP以进行web优化
- WordPress上传 --将WebP图片直接上传到WordPress媒体库
- 可配置的 --所有路径、限制和延迟均通过
config.json
提供的工具
| 工具 | 说明 |
|---|---|
generate_image |
立即生成单个图像 |
add_to_batch |
将图像排队以进行批量生成 |
remove_from_batch |
按索引或文件名从队列中删除 |
view_batch_queue |
查看排队的图像 |
run_batch |
生成所有排队的图像 |
convert_to_webp |
将生成的图像转换为WebP |
upload_to_wordpress |
将WebP图片上传到WordPress |
get_generated_webp_images |
获取WebP图像的base64数据 |
快速开始
1.克隆和配置
git clone https://github.com/YOUR_USERNAME/gemini-image-mcp.git
cd gemini-image-mcp
# Create config from example
cp config.json.example config.json
cp .env.example .env
2.设置API密钥
编辑 .env:
GEMINI_API_KEY=your-gemini-api-key-here
3.编辑config.json
更新路径 config.json 以匹配您的系统。这 images_dir 路径支持 ~ 扩张。
4.安装依赖项
pip install requests
WebP转换还需要 紫外线 枕头(由紫外线自动处理)。
5.添加到您的MCP客户端
克劳德代码(~/.claude/settings.json)
{
"mcpServers": {
"gemini-custom": {
"command": "python3",
"args": ["/path/to/gemini-image-mcp/src/gemini_image_server.py"],
"env": {
"GEMINI_API_KEY": "your-key-here"
}
}
}
}
或者作为systemd服务运行
看 docs/systemd-service.example 对于模板。
项目结构
gemini-image-mcp/
├── src/
│ ├── gemini_image_server.py # Main MCP server
│ ├── batch_manager.py # Batch queue management
│ └── batch_generate.py # Batch image generation
├── scripts/
│ └── webp-convert.py # PNG/JPG to WebP converter
├── skills/
│ ├── gemini-image-generation-SKILL.md # Claude skill file
│ └── example-brand-image-guidelines-SKILL.md # Brand template skill
├── docs/
│ └── systemd-service.example # Systemd service template
├── config.json.example # Configuration template
├── .env.example # Environment variable template
├── .gitignore
├── LICENSE
└── README.md
配置
config.json 领域:
| 字段 | 描述 | 默认值 |
|---|---|---|
images_dir |
图像的基本输出目录 | ~/Pictures/ai-generated-images |
batch_subdir |
批量输出子目录 | batch |
queue_filename |
批处理队列文件名 | batch_queue.json |
batch_manager_script |
批处理管理器路径 | ./src/batch_manager.py |
batch_generate_script |
批处理生成器路径 | ./src/batch_generate.py |
webp_convert_script |
WebP转换器的路径 | ./scripts/webp-convert.py |
max_reference_images |
每代最大参考图像数 | 14 |
api_delay_seconds |
批处理API调用之间的延迟 | 3 |
克劳德技能
这 skills/ 目录包含Claude Code技能文件:
- 双子座图像生成-SKILL.md --使用图像生成工具、快速工程、工作流程和故障排除的综合指南
- 示例-品牌图像指南-SKILL.md --创建品牌特定图像生成指南的模板
将这些复制到您的Claude Code技能目录中,让Claude详细了解如何使用此服务器。
质量等级
| 专业 | 快速 | |
|---|---|---|
| 型号 | Gemini 3 Pro图像预览 | Gemini 2.5 Flash图像 |
| 最大分辨率 | 4K(4096px) | 1K(1024px) |
| 参考图像 | 最多14张 | 不支持 |
| 文本渲染 | 良好 | 复杂文本效果差 |
| 最适合 | 生产内容 | 快速测试、迭代 |
许可证
麻省理工学院