Skip to main content
Glama
README.md
# Scenario Asset MCP Server

A Model Context Protocol (MCP) server for Unity game asset generation using Scenario.gg AI, designed for seamless integration with MCP clients like Claude Desktop, smithery-playground, and other MCP-compatible tools.

## ๐ŸŽฎ What This Does

This MCP server provides **10 comprehensive tools** for generating Unity-ready game assets:

- **Characters**: Heroes, NPCs, enemies with multiple art styles
- **Environments**: Backgrounds, landscapes, interiors, skyboxes  
- **Props & Objects**: Weapons, collectibles, furniture, vehicles
- **UI Elements**: Buttons, panels, frames with 9-slice support
- **Textures**: PBR materials, seamless textures, surface maps
- **Icons**: UI icons, logos, symbols with multiple sizes
- **Asset Management**: Search, retrieve, and manage generated assets

## โœจ Key Features

- **๐Ÿ”Œ MCP Protocol Compliant**: Works with any MCP client
- **๐ŸŽจ Unity-Optimized**: PNG+Alpha, proper import settings, organized folders
- **โšก Performance Focused**: WebGL/Mobile optimized, <300ms response times
- **๐Ÿ›ก๏ธ Production Ready**: Rate limiting, security headers, error handling
- **๐Ÿ“ฑ Multi-Platform**: Supports various art styles and target platforms
- **๐Ÿ”„ Batch Processing**: Generate multiple variations in one request

## ๐Ÿš€ Quick Start

### Prerequisites

- [Cloudflare Workers account](https://workers.cloudflare.com/)
- [Scenario.gg API account](https://scenario.com/)
- [Supabase account](https://supabase.com/) (for asset storage)
- [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/install-and-update/)

### 1. Clone and Setup

```bash
git clone https://github.com/yourusername/scenario-asset-mcp.git
cd scenario-asset-mcp
```

### 2. Install Dependencies

```bash
npm install
# or
yarn install
```

### 3. Configure Environment

```bash
# Copy example environment file
cp wrangler.toml.example wrangler.toml

# Set your secrets
wrangler secret put SCENARIO_API_KEY
wrangler secret put SCENARIO_API_SECRET
wrangler secret put SUPABASE_URL
wrangler secret put SUPABASE_ANON_KEY
wrangler secret put SUPABASE_SERVICE_ROLE_KEY
```

### 4. Deploy

```bash
wrangler deploy
```

Your MCP server will be available at: `https://your-worker-name.your-subdomain.workers.dev`

## ๐Ÿ”ง Configuration

### Required Secrets

Set these using `wrangler secret put <SECRET_NAME>`:

| Secret | Description | Example |
|--------|-------------|---------|
| `SCENARIO_API_KEY` | Your Scenario.gg API key | `sk_live_...` |
| `SCENARIO_API_SECRET` | Your Scenario.gg API secret | `sk_secret_...` |
| `SUPABASE_URL` | Your Supabase project URL | `https://xyz.supabase.co` |
| `SUPABASE_ANON_KEY` | Supabase anonymous key | `eyJ...` |
| `SUPABASE_SERVICE_ROLE_KEY` | Supabase service role key | `eyJ...` |

### Optional Configuration

Edit `wrangler.toml` to customize:

```toml
[vars]
ENVIRONMENT = "production"
LOG_LEVEL = "info"
MAX_CONCURRENT_REQUESTS = "20"
RATE_LIMIT_MAX_REQUESTS = "100"
RATE_LIMIT_WINDOW_MS = "60000"
```

## ๐Ÿ› ๏ธ Available Tools

### Asset Generation Tools

#### `generate_characters`
Generate character sprites for your Unity game.

```json
{
  "name": "generate_characters",
  "arguments": {
    "prompt": "medieval knight with silver armor",
    "character_type": "hero",
    "art_style": "cartoon",
    "num_variations": 2,
    "tags": ["fantasy", "armor"]
  }
}
```

#### `generate_environments`
Create backgrounds and environment assets.

```json
{
  "name": "generate_environments", 
  "arguments": {
    "prompt": "desert oasis with palm trees",
    "environment_type": "background",
    "art_style": "realistic",
    "time_of_day": "sunset",
    "resolution": "wide"
  }
}
```

#### `generate_props_objects`
Generate game objects like weapons, collectibles, furniture.

```json
{
  "name": "generate_props_objects",
  "arguments": {
    "prompt": "golden sword with gemstones",
    "object_type": "weapon",
    "rarity": "legendary",
    "transparency": true
  }
}
```

#### `generate_ui_system`
Create UI elements with 9-slice support.

```json
{
  "name": "generate_ui_system",
  "arguments": {
    "prompt": "futuristic blue button with glow",
    "ui_type": "button",
    "ui_style": "sci-fi",
    "state_variants": true,
    "nine_slice": true
  }
}
```

#### `generate_textures_materials`
Generate PBR textures and materials.

```json
{
  "name": "generate_textures_materials",
  "arguments": {
    "prompt": "weathered stone brick wall",
    "texture_type": "complete_pbr",
    "material_type": "stone",
    "seamless": true
  }
}
```

#### `generate_icons_symbols`
Create icons and symbols for UI.

```json
{
  "name": "generate_icons_symbols",
  "arguments": {
    "prompt": "health potion icon with red liquid",
    "icon_type": "ui_icon",
    "icon_style": "filled",
    "size_variants": true
  }
}
```

### Asset Management Tools

#### `search_assets`
Search previously generated assets.

```json
{
  "name": "search_assets",
  "arguments": {
    "type": "character",
    "tags": ["fantasy"],
    "limit": 10
  }
}
```

#### `get_asset_details`
Get detailed information about an asset.

```json
{
  "name": "get_asset_details",
  "arguments": {
    "asset_id": "uuid-here"
  }
}
```

#### `list_scenario_models`
List available AI models.

```json
{
  "name": "list_scenario_models",
  "arguments": {}
}
```

#### `delete_asset`
Delete an asset (use with caution).

```json
{
  "name": "delete_asset",
  "arguments": {
    "asset_id": "uuid-here",
    "confirm": true
  }
}
```

## ๐Ÿ”Œ MCP Client Integration

### Claude Desktop

Add to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "scenario-assets": {
      "command": "npx",
      "args": [
        "@modelcontextprotocol/server-fetch",
        "https://your-worker.workers.dev/mcp"
      ]
    }
  }
}
```

### Smithery Playground

Connect directly using the server URL:
```
https://your-worker.workers.dev/mcp
```

### Other MCP Clients

Use the standard MCP endpoints:
- **MCP Protocol**: `POST /mcp`
- **Server Discovery**: `GET /`
- **Health Check**: `GET /health`
- **Streaming**: `GET /mcp/stream`

## ๐Ÿ—๏ธ Architecture

### Technology Stack

- **Runtime**: Cloudflare Workers (Edge computing)
- **Protocol**: MCP (Model Context Protocol) JSON-RPC 2.0
- **AI Generation**: Scenario.gg API
- **Storage**: Supabase (PostgreSQL + File Storage)
- **Format**: Unity-optimized PNG+Alpha assets

### Request Flow

```
MCP Client โ†’ Cloudflare Worker โ†’ Scenario API โ†’ Asset Generation
                โ†“
         Supabase Storage โ† Unity Import โ† Asset Processing
```

### Performance Features

- **Edge Computing**: Global CDN with <50ms latency
- **Concurrent Processing**: Up to 20 parallel requests
- **Smart Caching**: Asset metadata and model listings
- **Rate Limiting**: 100 requests/minute per client
- **Timeout Management**: 30s default, 120s for generation

## ๐Ÿงช Testing

### Local Development

```bash
# Install dependencies
npm install

# Start local development server
wrangler dev

# Test endpoints
curl http://localhost:8787/health
```

### Testing MCP Protocol

```bash
# Test initialization
curl -X POST http://localhost:8787/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{}},"id":1}'

# Test tools list
curl -X POST http://localhost:8787/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"tools/list","id":2}'
```

### Unity Integration Testing

1. Generate test assets using the MCP tools
2. Import into Unity project
3. Verify PNG+Alpha format and transparency
4. Test sprite pivot points and physics shapes
5. Validate performance on target platform

## ๐Ÿ“š Documentation

### API Reference

- [MCP Protocol Specification](https://modelcontextprotocol.io/)
- [Scenario.gg API Docs](https://docs.scenario.com/)
- [Cloudflare Workers Docs](https://developers.cloudflare.com/workers/)

### Unity Integration

- [Unity Sprite Import Settings](https://docs.unity3d.com/Manual/class-TextureImporter.html)
- [Unity 9-Slice Sprites](https://docs.unity3d.com/Manual/9SliceSprites.html)
- [Unity Asset Workflow](https://docs.unity3d.com/Manual/AssetWorkflow.html)

## ๐Ÿค Contributing

1. Fork the repository
2. Create a feature branch: `git checkout -b feature/amazing-feature`
3. Commit changes: `git commit -m 'Add amazing feature'`
4. Push to branch: `git push origin feature/amazing-feature`
5. Open a Pull Request

### Development Guidelines

- Follow the existing code style
- Add tests for new features
- Update documentation
- Ensure Unity compatibility
- Test with multiple MCP clients

## ๐Ÿ“ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## ๐Ÿ†˜ Support

- **Issues**: [GitHub Issues](https://github.com/yourusername/scenario-asset-mcp/issues)
- **Discussions**: [GitHub Discussions](https://github.com/yourusername/scenario-asset-mcp/discussions)
- **Documentation**: [Wiki](https://github.com/yourusername/scenario-asset-mcp/wiki)

## ๐Ÿ™ Acknowledgments

- [Model Context Protocol](https://modelcontextprotocol.io/) for the excellent protocol specification
- [Scenario.gg](https://scenario.com/) for the powerful AI generation API
- [Cloudflare Workers](https://workers.cloudflare.com/) for the serverless platform
- [Unity Technologies](https://unity.com/) for the game engine integration

## ๐Ÿš€ Roadmap

- [ ] Resource system for asset templates
- [ ] Prompt system for common generation patterns
- [ ] Batch generation workflows
- [ ] Unity Editor plugin
- [ ] Asset versioning and history
- [ ] Collaborative asset sharing
- [ ] Custom model training integration

---

**Made with โค๏ธ for Unity game developers using AI-powered asset generation**