# Unity Asset Store MCP

![Beta](https://img.shields.io/badge/status-beta-yellow)

MCP server for browsing, downloading, extracting, and converting Unity Asset Store packages. Works with Claude Code and other MCP-compatible AI agents.

## Install

```bash
# Clone and install dependencies
git clone <repo-url> && cd UnityStoreMCP
bun install
```

### Optional: conversion dependencies

- **FBX to glTF**: `brew install fbx2gltf` (macOS) or install [FBX2glTF](https://github.com/facebookincubator/FBX2glTF)
- **TGA/PSD to PNG**: uses macOS `sips` by default, or `ffmpeg` as fallback

## Setup

Add to your MCP client config (e.g. `~/.claude/settings.json`):

```json
{
  "mcpServers": {
    "unity-store": {
      "command": "bun",
      "args": ["run", "/path/to/UnityStoreMCP/src/index.ts"]
    }
  }
}
```

## Authentication

The server authenticates using cookies from `assetstore.unity.com`:

1. Log into https://assetstore.unity.com in your browser
2. Open DevTools (F12) → Network tab
3. Copy the full `Cookie` header value from any request
4. Use `configure-auth` with `method: "session_token"` and paste the cookie string

The server exchanges these cookies for the internal tokens needed for downloads.

## Tools

| Tool | Description |
|------|-------------|
| `configure-auth` | Authenticate with Unity Asset Store |
| `search-assets` | Search the store by query |
| `get-asset-details` | Get details for specific asset IDs |
| `list-my-assets` | List your purchased/owned assets |
| `download-asset` | Download a `.unitypackage` by ID |
| `list-local-packages` | List Unity Editor cached packages |
| `inspect-package` | Preview package contents without extracting |
| `extract-package` | Extract `.unitypackage` to disk |
| `convert-assets` | Convert Unity assets to Three.js formats (FBX→glTF, materials, textures) |
| `list-extracted` | List extracted/converted directories |
| `browse-files` | Browse files in asset directories |

## Data Directory

Downloaded, extracted, and converted assets are stored in `~/.unity-mcp/`. Override with `UNITY_MCP_DATA_DIR` environment variable.

## Package Decryption

Unity Asset Store packages are served as AES-256-CBC encrypted blobs. The `download-asset` tool handles this automatically:

1. Fetches the download URL and a 96-character hex decryption key from Unity's Kharma API
2. Downloads the encrypted file via streaming (supports files >2GB)
3. Splits the key: first 32 bytes → AES key, last 16 bytes → IV
4. Decrypts with `openssl` and outputs a standard `.unitypackage` (gzip tar)
