Layer.ai MCP Server
Enables users to generate and manage 2D game assets like sprites, characters, and backgrounds directly from their development environment using the Layer.ai platform. It supports asset creation with transparency, prompt optimization, and automatic saving of generated files to local project directories.
README
Layer.ai MCP Server
A Model Context Protocol (MCP) server for generating game assets using Layer.ai's AI platform. Generate sprites, characters, backgrounds, and other 2D assets directly from your development environment.
Made with AI - Use with caution
Features
- Asset Generation: Generate 2D game assets using Layer.ai Forge
- Prompt Optimization: Optimize prompts with Layer.ai Prompt Genie
- Usage Tracking: Monitor usage against free tier limits (600 assets)
- Workspace Management: Export and manage workspace data
- Asset Refinement: Refine and modify existing assets
- Auto-Save: Automatically save generated assets to your project
- Error Handling: Robust error handling with automatic retries
- Quota Protection: Prevents exceeding your free tier limit
Installation
Prerequisites
- Python 3.10+ (required for MCP compatibility)
- Git for cloning the repository
- Layer.ai account and API token
Quick Install (Recommended)
# Clone the repository
git clone https://github.com/bahadirbklg/layer-ai-mcp-server.git
cd layer-ai-mcp-server
# Run the installation script
chmod +x install.sh
./install.sh
Manual Installation
# Clone the repository
git clone https://github.com/bahadirbklg/layer-ai-mcp-server.git
cd layer-ai-mcp-server
# Create virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install --upgrade pip
pip install -r requirements.txt
# Create assets directory
mkdir -p assets
# Set up credentials
python layer-mcp-server/setup.py
Installation Options
- Production:
pip install -r requirements.min.txt(core dependencies only) - Development:
pip install -r requirements.dev.txt(includes testing and linting tools) - Full:
pip install -r requirements.txt(recommended for most users)
Verify Installation
Test your installation to make sure everything is working:
# Run the installation test
python3 verify-install.py
This will check:
- Python version compatibility (3.10+)
- All required dependencies are installed
- Project files are in place
- Main server can be imported successfully
Configuration
Environment Variables
Create a .env file or set environment variables:
# Required: Your Layer.ai API token
LAYER_API_TOKEN=pat_your_token_here
# Optional: API base URL (defaults to https://api.layer.ai)
LAYER_API_BASE_URL=https://api.layer.ai
# Optional: Usage tracking file (defaults to .layer_usage.json)
LAYER_USAGE_FILE=.layer_usage.json
# Optional: Default save directory (defaults to ./assets)
LAYER_DEFAULT_SAVE_DIR=./assets
# Optional: Default workspace ID
LAYER_WORKSPACE_ID=your_workspace_id
Getting Your API Token
- Sign up at Layer.ai
- Go to your account settings
- Generate a new API token (starts with
pat_) - Copy the token to your
.envfile
MCP Client Configuration
For Kiro IDE
Add to your MCP client configuration:
{
"mcpServers": {
"layer-ai-comprehensive": {
"command": "python",
"args": ["layer-mcp-server/server.py"],
"env": {
"LAYER_API_TOKEN": "pat_your_token_here",
"LAYER_WORKSPACE_ID": "your_workspace_id"
},
"disabled": false,
"timeout": 180,
"autoApprove": [
"create_asset", "remove_background", "describe_image",
"generate_prompt", "get_workspace_info"
]
}
}
}
For Claude Desktop
Add to your Claude Desktop MCP configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"layer-ai": {
"command": "python",
"args": ["path/to/layer-mcp-server/server.py"],
"env": {
"LAYER_API_TOKEN": "pat_your_token_here",
"LAYER_WORKSPACE_ID": "your_workspace_id"
}
}
}
}
Usage
Available Tools
1. create_asset - Generate Assets
Generate sprites, characters, backgrounds, and other assets.
Parameters:
prompt(required): Description of the asset to generategeneration_type(optional): CREATE, UPSCALE, etc.width/height(optional): Output dimensions (default: 512x512)quality(optional): LOW, MEDIUM, HIGH (default: HIGH)transparency(optional): Enable transparent backgroundssave_path(optional): Local path to save the asset
Example:
{
"prompt": "A cute pixel art character for a platformer game",
"generation_type": "CREATE",
"width": 512,
"height": 512,
"transparency": true,
"save_path": "./sprites/player_character.png"
}
2. get_workspace_info - Check Status
Get information about your Layer.ai workspace and available features.
3. remove_background - Background Removal (In Development)
Remove backgrounds from existing images using AI.
4. describe_image - Image Analysis (In Development)
Get AI-generated descriptions of images.
5. generate_prompt - Prompt Optimization (In Development)
Optimize your prompts using Layer.ai's Prompt Genie.
Usage Examples
Generate a Game Sprite
# Create a transparent character sprite
create_asset(
prompt="fantasy warrior character, pixel art, 64x64, RPG game",
generation_type="CREATE",
width=64,
height=64,
transparency=True,
save_path="./assets/warrior_sprite.png"
)
Create a Tileable Texture
# Generate seamless stone texture
create_asset(
prompt="medieval stone brick wall, seamless texture",
generation_type="CREATE",
width=256,
height=256,
tileability=True,
save_path="./assets/stone_texture.png"
)
Project Structure
layer-ai-mcp-server/
├── layer-mcp-server/
│ ├── server.py # Main MCP server
│ ├── auth.py # Authentication & token management
│ ├── setup.py # Interactive credential setup
│ ├── api-docs.md # API documentation
│ ├── mcp-config.md # MCP configuration guide
│ ├── security.md # Security documentation
│ └── pyproject.toml # Package configuration
├── assets/ # Generated assets (auto-created)
├── README.md # Main documentation
├── .gitignore # Git ignore patterns
├── requirements.txt # Core dependencies
├── requirements.min.txt # Minimal dependencies
├── requirements.dev.txt # Development dependencies
├── install.sh # Installation script
├── verify-install.py # Installation verification
├── setup.py # Package setup
└── LICENSE # MIT License
Issues & Bug Tracking
Open Issues
High Priority
- [BUG-001] Timeout issues with complex asset generation (>60s)
- Status: RESOLVED (Fixed with 180s timeout in MCP config)
- Solution: Added
"timeout": 180to MCP server configuration - Date: 2025-08-15
Medium Priority
-
[FEATURE-001] Background removal feature not implemented
- Status: IN PROGRESS
- Description:
remove_backgroundtool returns "implementation in progress" - Date: 2025-08-15
-
[FEATURE-002] Image description feature not implemented
- Status: IN PROGRESS
- Description:
describe_imagetool returns "implementation in progress" - Date: 2025-08-15
-
[FEATURE-003] Prompt generation feature not implemented
- Status: IN PROGRESS
- Description:
generate_prompttool returns "implementation in progress" - Date: 2025-08-15
Known Limitations
- Free Tier Limits: 600 assets per month on free tier
- File Size Limits: Large assets (>10MB) may have slower processing
- Network Dependency: Requires stable internet connection for Layer.ai API
- Python Version: Requires Python 3.10+ for full compatibility
Feature Requests
- 3D Asset Generation: Support for generating 3D models and textures
- Animation Support: Generate sprite animations and sequences
- Style Transfer: Apply artistic styles to existing assets
- Bulk Operations: Process multiple assets simultaneously
- Asset Versioning: Track and manage different versions of assets
Troubleshooting
Common Issues
"Invalid API token"
- Check your
.envfile has the correctLAYER_API_TOKEN - Ensure the token starts with
pat_ - Verify the token is valid in your Layer.ai account
"Quota exceeded"
- Check usage with
get_workspace_infotool - You've reached the 600 asset limit for free tier
- Consider upgrading your Layer.ai plan
"Network errors"
- Check your internet connection
- Verify Layer.ai API is accessible
- The server automatically retries failed requests
"MCP connection issues"
- Ensure you're running the server correctly
- Check MCP client configuration
- Review server logs for detailed error messages
"Timeout errors"
- Increase timeout in MCP configuration:
"timeout": 180 - Complex assets may take 30-60 seconds to generate
- Check network stability for long-running operations
"Installation errors"
- Python version: Ensure you have Python 3.10+ (
python3 --version) - Virtual environment: Use a virtual environment to avoid conflicts
- Permissions: On Linux/macOS, you may need
chmod +x install.sh - Dependencies: Try
pip install --upgrade pipbefore installing requirements - MCP compatibility: Some older Python versions may have MCP compatibility issues
"Import errors"
- Missing dependencies: Run
pip install -r requirements.txtagain - Virtual environment: Make sure your virtual environment is activated
- Path issues: Ensure you're running from the correct directory
- Token manager: If token_manager import fails, run the setup script
Issue Reporting Template
When reporting new issues, please use this format:
**[TYPE-###]** Brief description
- **Status**: NEW/IN PROGRESS/RESOLVED
- **Priority**: High/Medium/Low
- **Description**: Detailed description of the issue
- **Steps to Reproduce**:
1. Step one
2. Step two
3. Expected vs actual result
- **Environment**:
- OS: [Windows/macOS/Linux]
- Python version: [3.x.x]
- MCP Client: [Claude Desktop/Other]
- **Date**: YYYY-MM-DD
Issue Types:
BUG- Something is brokenFEATURE- New functionality neededENHANCEMENT- Improvement to existing featureDOCS- Documentation issuePERFORMANCE- Performance problem
Security
This project uses secure credential management:
- AES-256 Encryption: API tokens encrypted at rest
- PBKDF2 Key Derivation: Secure key generation
- File Permissions: Restricted access (600)
- No Version Control Exposure: Credentials never committed
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Submit a pull request
Links
Made with AI - Use with caution
Start generating amazing assets for your projects with Layer.ai!
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。