MCP资产生成服务器
一种模型上下文协议(MCP)服务器,用于生成各种类型的资产,包括用于游戏开发的图像、视频、音频和3D模型。
特性
- 图像生成:支持多个提供商(OpenAI DALL-E、Google Gemini、Fal.ai)
- 视频生成:即将推出
- 音频生成:即将推出
- 3D模型生成:使用FAL.ai Trellis和Hunyuan3D 2.0生成3D模型
- 游戏开发重点:针对创建游戏资产进行了优化
安装
# Clone the repository
git clone
cd mcp-game-asset-gen
# Install dependencies
npm install
# Build the project
npm run build发展
# Run in development mode with hot reload
npm run dev
# Run tests
npm test
# Run tests with UI
npm run test:ui
# Type checking
npm run typecheck
# Linting
npm run lint用法
服务器通过MCP协议为资产生成提供工具和提示。
可用工具
图像生成
openai_generate_image:使用OpenAI的图像生成API生成图像
- 参数: - prompt (必填):要生成的图像的详细描述 - outputPath (必填):应保存生成图像的路径 - inputImagePath (可选):编辑/更改输入图像的路径 - size (可选):图像尺寸(“1024x1024”、“1792x1024”、“1024x1792”) - quality (可选):图像质量级别(“标准”、“高清”) - style (可选):图像风格偏好(“生动”、“自然”) - n (可选):要生成的图像数量(1-10)
gemini_generate_image:使用谷歌的Gemini原生图像生成功能生成图像(支持2.5 Flash和3 Pro型号)
- 参数: - prompt (必填):要生成的图像的描述 - outputPath (必填):应保存生成图像的路径 - inputImagePaths (可选):输入图像的路径数组,用于变化/组合 - model (可选):要使用的Gemini模型('Gemini-2.5-flash-image','Gemini-3-pro-image-review',默认值:Gemini-3-pro-image-review)
falai_generate_image:使用FAL.ai的Qwen图像生成模型生成高质量图像
- 参数: - prompt (必填):图像生成的详细提示 - outputPath (必填):应保存生成图像的路径 - image_size (可选):图像大小预设(“方形”、“正方形”、“肖像_4_3'、“肖像_16_9'、“景观_4_3”、“景观_16_9”) - num_inference_steps (可选):推理步骤数(1-50) - guidance_scale (可选):如何密切关注提示(1-20)
falai_edit_image:使用FAL.ai的Qwen图像编辑模型编辑图像
- 参数: - prompt (必填):描述所需编辑的详细提示 - inputImagePath (必填):要编辑的输入图像的路径 - outputPath (必填):编辑图像应保存的路径 - image_size (可选):图像大小预设 - num_inference_steps (可选):推理步骤数(1-50) - guidance_scale (可选):如何密切关注提示(1-20)
游戏资产生成
generate_character_sheet:根据文本描述或参考图像生成字符表
- 参数: - characterDescription (必填):角色的详细描述 - outputPath (必填):字符表应保存的路径 - referenceImagePaths (可选):参考图像路径数组(角色、服装等) - model (可选):用于生成的模型(“penai”、“gemini”、“falai”,默认:gemini-使用gemini-3-pro-image-preview) - style (可选):角色表的艺术风格(例如,动漫、写实、卡通) - includeExpressions (可选):包含多种面部表情 - includePoses (可选):包括多个姿势/角度
generate_character_variation:通过组合参考图像生成字符变体
- 参数: - prompt (必填):要创建的变体的描述 - outputPath (必填):应保存变量的路径 - referenceImagePaths (必填):要组合的参考图像路径数组 - model (可选):用于生成的模型(“penai”、“gemini”、“falai”,默认:gemini-使用gemini-3-pro-image-preview)
generate_pixel_art_character:为复古游戏生成具有特定尺寸的像素艺术角色
- 参数: - characterDescription (必填):像素艺术字符的描述 - outputPath (必填):像素艺术应保存的路径 - pixelDimensions (必填):目标像素尺寸(“8x8”、“16x16”、“32x32”、“48x48”、“64x64”、“96x96”) - spriteSheet (可选):生成带有动画的精灵表 - model (可选):要使用的模型(默认值:falai) - colors (可选):调色板大小(4-256色) - transparentBackground (可选):为游戏精灵生成具有透明背景的像素艺术 - backgroundColor (可选):使背景颜色透明(“白色”、“黑色”、“自动”,默认:白色)
generate_texture:为3D环境和材质生成无缝纹理
- 参数: - textureDescription (必填):纹理描述(例如草地、砖墙、木板、精灵对象) - outputPath (必填):纹理应保存的路径 - textureSize (可选):纹理分辨率('512x512'、'1024x1024'、'2048x2048',默认值:1024x1024) - seamless (可选):生成无缝/可平铺纹理 - model (可选):要使用的模型(默认值:falai) - materialType (可选):纹理贴图的类型(“差异”、“法线”、“粗糙度”、“位移”) - transparentBackground (可选):为精灵/贴花生成具有透明背景的纹理 - backgroundColor (可选):使背景颜色透明(“白色”、“黑色”、“自动”,默认:白色) - transparencyTolerance (可选):透明度的颜色变化容差(0-255,默认值:30)
generate_object_sheet:为3D建模生成多视点参考表
- 参数: - objectDescription (必填):3D对象的描述 - outputBasePath (必填):输出文件的基本路径(将附加_front.png、\_side.png等) - viewpoints (可选):要生成的视点(“前”、“后”、“左”、“右”、“上”、“下”、“透视”) - model (可选):要使用的模型(默认:gemini-使用gemini-3-pro-image-preview) - style (可选):艺术风格(如技术图纸、概念艺术)
3D模型生成
image_to_3d:使用具有自动参考图像生成功能的高级AI模型从图像生成3D模型
- 参数: - outputPath (必填):应保存生成的3D模型的路径(.glb或.gltf) - prompt (可选):要生成的3D模型的描述(用于自动生成参考图像) - inputImagePaths (可选):输入图像或base64 URI的路径数组。如果没有提供,将自动生成参考图像 - model (可选):3D生成模型('hunyuan3d'、'grist'、'hunyuanworld',默认:hunyuan3d) - variant (可选):型号变体(“单”、“多”、“单涡轮”、“多级涡轮”,默认:自动选择) - format (可选):输出格式('glb','gltf',默认:glb用于网络/游戏兼容性) - textured_mesh (可选):生成纹理网格(仅限Hunyuan3D,成本为3倍,默认值为true) - autoGenerateReferences (可选):如果没有提供输入图像,则从提示中自动生成参考图像(默认值:true) - referenceModel (可选):用于自动生成参考图像的模型(“penai”、“gemini”、“falai”,默认:gemini-使用gemini-3-pro-image-preview) - referenceViews (可选):为参考图像生成的视图(默认值:\[“正面”、“背面”、“顶部”\]) - cleanupReferences (可选):在3D生成后清理自动生成的参考图像(默认值:true)
可用提示
asset_generation:为游戏开发生成各种类型的资产
- 参数: - asset_type (必填):资产类型(“图像”、“视频”、“音频”、“3d”) - style (可选):艺术风格或主题
配置
您需要为各种提供程序配置API密钥:
# Environment variables
export OPENAI_API_KEY="your-openai-key"
export GEMINI_API_KEY="your-gemini-key"
export FAL_AI_API_KEY="your-fal-key"工具筛选(可选)
为了减少上下文使用,您可以限制可用的工具:
# Only expose specific tools
export ALLOWED_TOOLS="openai_generate_image,gemini_generate_image,generate_texture"
# Available tools:
# - openai_generate_image
# - gemini_generate_image
# - falai_generate_image
# - falai_edit_image
# - generate_character_sheet
# - generate_character_variation
# - generate_pixel_art_character (with transparent background support)
# - generate_texture (with transparent background support for sprites/decals)
# - generate_object_sheet
# - image_to_3d (unified 3D generation with automatic reference images)
## Transparent Background Generation
The server supports generating images with transparent backgrounds, perfect for game sprites and decals. This uses a two-step process with native JavaScript:
1. Generate the image with a solid white/black background
2. Convert the solid background to transparent alpha using native JavaScript processing
### Features
- **Native JavaScript**: No external dependencies required
- **Auto-detection**: Automatically detects white or black backgrounds
- **Adjustable tolerance**: Control how much color variation to allow
- **PNG support**: Works with PNG images for transparency
### Examples
Generate transparent sprite texture
generate_texture \ --textureDescription "magic fireball effect" \ --outputPath "fireball_sprite.png" \ --transparentBackground true \ --backgroundColor "black" \ --materialType "diffuse"
Generate pixel art character with transparent background
generate_pixel_art_character \ --characterDescription "knight with sword" \ --outputPath "knight_sprite.png" \ --pixelDimensions "32x32" \ --transparentBackground true \ --colors 16
Generate 3D model with automatic reference images
image_to_3d \ --prompt "fantasy sword with ornate handle" \ --outputPath "sword_model.glb" \ --model "hunyuan3d" \ --autoGenerateReferences true
Generate character sheet with multiple poses
generate_character_sheet \ --characterDescription "female warrior with armor" \ --outputPath "warrior_sheet.png" \ --model "gemini" \ --style "realistic fantasy" \ --includeExpressions true \ --includePoses true
Project Structure
mcp游戏资产生成/
├── src/
│ ├── index.ts#主服务器文件
│ └── server.test.ts#测试
├── package.json
姓名:
├── vitest.config.ts
└── README.md
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run the test suite
- Submit a pull request
License
MIT
