Mcp阿尔法香蕉
](https://www.npmjs.com/package/@tasopen/mcp-alphabanana) 
英语| 日本语
mcp-alphabanana是一个模型上下文协议(mcp)服务器,用于使用Google Gemini生成图像资源。它是为需要快速图像生成、透明输出、参考图像引导和灵活交付格式的MCP兼容客户端和代理工作流而构建的。
关键词:MCP服务器、模型上下文协议、Gemini AI、图像生成、FastMCP
关键能力:
- 跨Flash和Pro层的超快速Gemini图像生成
- 用于web和游戏管道的透明PNG/WebP资产输出
- 使用本地参考图像文件进行多图像风格指导
- 用于代理工作流的灵活文件、base64或组合输出
快速开始
使用npx运行MCP服务器:
npx -y @tasopen/mcp-alphabanana或者将其添加到MCP配置中:
{
"mcp": {
"servers": {
"alphabanana": {
"command": "npx",
"args": ["-y", "@tasopen/mcp-alphabanana"],
"env": {
"GEMINI_API_KEY": "${env:GEMINI_API_KEY}"
}
}
}
}
}集 GEMINI_API_KEY 在启动服务器之前。
对于克劳德桌面, 下载 mcp-alphabanana-latest.mcpb,然后从Claude桌面设置中将其添加为扩展。对于Windows,建议添加“FileSystem”扩展名以更好地处理本地文件。\ ](https://github.com/tasopen/mcp-alphabanana/releases/latest/download/mcp-alphabanana-latest.mcpb)
克劳德登记处
Claude注册表/MCPB包元数据在中定义 manifest.json 并附带静态512x512图标 images/mcp-alphabanana.png.
本土的 sharp 运行时包被声明为可选依赖项,因此 .mcpb 安装程序可以在每个支持的平台上解析正确的预构建二进制文件,而不依赖于安装后挂钩。
- 稳定的MCPB URL:
https://github.com/tasopen/mcp-alphabanana/releases/latest/download/mcp-alphabanana-latest.mcpb - 版本化MCPB URL模式:
https://github.com/tasopen/mcp-alphabanana/releases/download/vVERSION/mcp-alphabanana-VERSION.mcpb - 技术支持:
MCP服务器
该存储库提供了一个MCP服务器,使AI代理能够使用Google Gemini生成图像。
它可以与MCP兼容的客户端一起使用,例如:
- 克劳德桌面
- VS代码MCP
- 光标
建于 FastMCP 3 简化的代码库和灵活的输出选项。
Glama MCP服务器徽章:\
可用工具
generate_image
使用Google Gemini生成具有可选透明度、本地参考图像、基础和推理元数据的图像。
对于Claude Desktop,请选择 outputType=file 对于中型或大型图像。 base64 和 combine 响应会消耗Claude上下文,并可能达到客户端的大小限制。在Windows上,使用FileSystem扩展选择可写绝对值 outputPath 以及任何当地 referenceImages 路径。
关键参数:
prompt(string):要生成的图像的描述model:Flash3.1,Flash2.5,Pro3,flash,prooutputWidth和outputHeight:正常模式下请求的最终图像大小(像素)noresize+aspectRatio+output_resolution:返回Gemini原生大小,不调整大小output_resolution:0.5K,1K,2K,4Koutput_format:png,jpg,webpoutputType:file,base64,combineoutputPath:需要时outputType是file或combinetransparent:启用透明的PNG/WebP后处理referenceImages:本地参考图像文件的可选数组grounding_type和thinking_mode:先进的Gemini 3.1控制
模型选择
| 输入模型ID | 内部模型ID | 描述 |
|---|---|---|
Flash3.1 | gemini-3.1-flash-image-preview | 超快,支持思考/接地。 |
Flash2.5 | gemini-2.5-flash-image | 传统Flash。高稳定性。成本低。 |
Pro3 | gemini-3.0-pro-image-preview | 高保真Pro型号。 |
flash | gemini-3.1-flash-image-preview | 用于向后兼容性的别名。 |
pro | gemini-3.0-pro-image-preview | 用于向后兼容性的别名。 |
参数
完整的参数参考 generate_image 工具。
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
prompt | 字符串 | *必需的* | 要生成的图像的描述 |
outputFileName | 字符串 | *必需的* | 输出文件名(如果缺少扩展名,则自动添加) |
outputType | enum | combine | file, base64,或 combine |
model | enum | Flash3.1 | 型号: Flash3.1, Flash2.5, Pro3, flash, pro |
output_resolution | enum | 自动 | 0.5K, 1K, 2K, 4K;需要时 noresize=true |
noresize | 布尔值 | false | 跳过生成后调整大小并返回Gemini原生维度 |
aspectRatio | enum | 可选 | 当 noresize=true;例如。 1:1, 16:9, 4:5 |
outputWidth | integer | 必填,除非 noresize=true | 最终输出宽度(像素) |
outputHeight | integer | 必填,除非 noresize=true | 最终输出高度(像素) |
output_format | enum | png | png, jpg, webp |
outputPath | string | 必需 file / combine | 绝对输出目录路径 |
transparent | 布尔值 | false | 透明背景(仅PNG/WebP) |
transparentColor | string或null | null | 透明度提取的颜色键覆盖 |
colorTolerance | 整数 | 30 | 透明度颜色匹配公差 |
fringeMode | enum | auto | auto, crisp, hd |
resizeMode | enum | crop | crop, stretch, letterbox, contain |
grounding_type | enum | none | none, text, image, both (仅适用于Flash3.1) |
thinking_mode | enum | minimal | minimal, high (仅适用于Flash3.1) |
include_thoughts | 布尔值 | false | 启用元数据时返回模型推理字段 |
include_metadata | 布尔值 | false | 在JSON输出中包含基础和推理元数据 |
referenceImages | 阵列 | [] | 最多14个本地参考文件(Flash3.1/Pro3),3个用于Flash2.5 |
debug | 布尔值 | false | 保存中间调试工件 |
为什么是阿尔法香蕉?
- 零水印: API名称的干净图像。
- 思考/接地支持: 更高的即时依从性和搜索支持的准确性。
- 生产就绪: 支持web和游戏资产的透明WebP和精确纵横比。
特性
- 超快速图像生成 (双子座3.1闪光灯,0.5K/1K/2K/4K)
- 高级多图像推理 (最多14个参考图像)
- 思考/基础支持 (仅适用于Flash3.1)
- 透明PNG/WebP输出 (彩色键后处理,despill)
- 多种输出格式:文件、base64或两者都有
- 灵活的调整大小模式:裁剪、拉伸、信箱、收纳
- 多个模型层次:Flash3.1、Flash2.5、Pro3、旧别名
输出示例
这些样本输出是用mcp-alphabanana生成的,并存储在 图片/示例.
| 像素艺术资产 | 参考图像游戏场景 | 真实感生成 |
|---|---|---|
配置
配置 GEMINI_API_KEY 在MCP配置中(例如, mcp.json).
示例:
- 从以下位置引用操作系统环境变量
mcp.json:
{
"env": {
"GEMINI_API_KEY": "${env:GEMINI_API_KEY}"
}
}- 直接在中提供密钥
mcp.json:
{
"env": {
"GEMINI_API_KEY": "your_api_key_here"
}
}VS代码集成
添加到您的VS代码设置(.vscode/settings.json 或用户设置),配置服务器 env 在 mcp.json 或通过VS代码MCP设置。
{
"mcp": {
"servers": {
"mcp-alphabanana": {
"command": "npx",
"args": ["-y", "@tasopen/mcp-alphabanana"],
"env": {
"GEMINI_API_KEY": "${env:GEMINI_API_KEY}"
}
}
}
}
}可选: 通过添加以下内容为写入失败设置自定义回退目录 MCP_FALLBACK_OUTPUT 到 env 对象。
用法示例
基础世代
{
"prompt": "A pixel art treasure chest, golden trim, wooden texture",
"model": "Flash3.1",
"outputFileName": "chest",
"outputType": "base64",
"outputWidth": 64,
"outputHeight": 64,
"transparent": true
}不调整大小的原生大小
{
"prompt": "A clean app icon with a banana mascot, flat graphic design",
"model": "Flash3.1",
"outputFileName": "banana-icon-native",
"outputType": "base64",
"noresize": true,
"aspectRatio": "1:1",
"output_resolution": "0.5K",
"output_format": "png"
}此模式返回所需比率和分辨率的Gemini原生像素大小。例如, 1:1 + 0.5K 回报 512x512 无需任何调整大小的过程。
高级(垂直海报和思维)
{
"prompt": "A vertical, photorealistic travel poster advertising Magical Wings Day Tours. A joyful young couple flies high above a breathtaking European countryside at golden hour, holding hands as they soar through a partly cloudy sky. Below them are vineyards, villages, forests, a winding river, and a hilltop medieval castle. The poster uses large, elegant typography with the headline FLY THE COUNTRYSIDE at the top and Magical Wings Day Tours branding near the bottom.",
"model": "Flash3.1",
"output_resolution": "1K",
"outputFileName": "photoreal-travel-poster",
"outputType": "file",
"outputPath": "/path/to/output",
"outputWidth": 848,
"outputHeight": 1264,
"output_format": "jpg",
"thinking_mode": "high",
"include_metadata": true
}接地样本(支持搜索)
{
"prompt": "A modern travel poster featuring today's weather and skyline highlights in Kuala Lumpur",
"model": "Flash3.1",
"outputFileName": "kl_travel_poster",
"outputType": "base64",
"outputWidth": 1024,
"outputHeight": 1024,
"grounding_type": "text",
"thinking_mode": "high",
"include_metadata": true,
"include_thoughts": true
}此示例支持Google搜索基础,并以JSON格式返回基础和推理元数据。
参考图像
{
"prompt": "Use the reference image to create a game screen showing an opened treasure chest filled with coins and treasure, 8-bit dungeon crawler style, after-battle reward scene, dungeon corridor background, four-party status UI at the bottom",
"model": "Flash3.1",
"output_resolution": "0.5K",
"outputFileName": "reference-image-dungeon-loot",
"outputType": "file",
"outputPath": "/path/to/output",
"outputWidth": 600,
"outputHeight": 448,
"output_format": "webp",
"transparent": false,
"referenceImages": [
{
"description": "Treasure chest style reference",
"filePath": "/path/to/references/pixel-art-treasure-chest.png"
}
]
}透明度和输出格式
- 便携式网络图形:全阿尔法,彩色键+数字键
- WebP:全alpha,更好的压缩(Flash3.1+)
- JPEG格式:无透明度(回落到纯色背景)
发展
# Development mode with MCP CLI
npm run dev
# MCP Inspector (Web UI)
npm run inspect
# Build for production
npm run build许可证
麻省理工学院
