Generate 2D game assets using Layer.ai's AI platform
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
Tools (2)
create_assetGenerate sprites, characters, backgrounds, and other assets.get_workspace_infoGet information about the current workspace.Environment Variables
LAYER_API_TOKENrequiredYour Layer.ai API tokenLAYER_API_BASE_URLAPI base URLLAYER_USAGE_FILEUsage tracking file pathLAYER_DEFAULT_SAVE_DIRDefault directory to save generated assetsLAYER_WORKSPACE_IDDefault workspace IDConfiguration
{"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"}}}}