Loading...
Loading...
MCP server plugin for Cocos Creator 3.8+ that enables AI assistants to control the editor through 50 powerful tools for scenes, nodes, components, prefabs, and assets.
npx skill4agent add aradotso/mcp-skills cocos-creator-mcp-serverSkill by ara.so — MCP Skills collection.
# Clone the repository
git clone https://github.com/DaxianLee/cocos-mcp-server.git
# Install in Cocos Creator extensions folder
# Windows: %USERPROFILE%/.CocosCreator/extensions/
# macOS: ~/.CocosCreator/extensions/
# Copy the plugin folder to the extensions directoryclaude_desktop_config.json{
"mcpServers": {
"cocos-creator": {
"type": "http",
"url": "http://127.0.0.1:3000/mcp"
}
}
}claude mcp add --transport http cocos-creator http://127.0.0.1:3000/mcp.cursor/mcp.json{
"mcpServers": {
"cocos-creator": {
"url": "http://localhost:3000/mcp"
}
}
}{
"tool": "category_operation",
"arguments": {
"action": "specific_action",
// ... action-specific parameters
}
}// Tool: scene_management
{
"action": "get_current_scene"
}
// Returns: { uuid: string, name: string, path: string }{
"action": "open_scene",
"sceneUuid": "scene-uuid-here"
}{
"action": "create_scene",
"name": "MyNewScene",
"savePath": "db://assets/scenes/"
}{
"action": "save_scene"
}// Tool: node_lifecycle
{
"action": "create",
"name": "PlayerNode",
"parentUuid": "parent-node-uuid", // Optional, defaults to scene root
"nodeType": "2DNode", // or "3DNode"
"components": [ // Optional pre-installed components
{
"type": "cc.Sprite",
"properties": {
"spriteFrame": "texture-uuid"
}
}
]
}// Tool: node_query
{
"action": "find_by_name",
"name": "Player",
"exactMatch": false // Use pattern matching
}
// Or find all nodes
{
"action": "find_all",
"includeComponents": true
}// Tool: node_lifecycle
{
"action": "delete",
"uuid": "node-uuid-to-delete"
}// Tool: node_transform
{
"action": "set_property",
"uuid": "node-uuid",
"property": "position",
"value": { "x": 100, "y": 200, "z": 0 }
}
// Set rotation
{
"action": "set_property",
"uuid": "node-uuid",
"property": "rotation",
"value": { "x": 0, "y": 0, "z": 45 } // Euler angles
}
// Set scale
{
"action": "set_property",
"uuid": "node-uuid",
"property": "scale",
"value": { "x": 2, "y": 2, "z": 1 }
}// Tool: node_hierarchy
{
"action": "move",
"uuid": "node-uuid",
"newParentUuid": "new-parent-uuid",
"siblingIndex": 0 // Optional position among siblings
}// Tool: component_manage
{
"action": "add",
"nodeUuid": "node-uuid",
"componentType": "cc.Sprite",
"properties": {
"spriteFrame": "texture-uuid",
"sizeMode": 0
}
}
// Common component types:
// cc.Sprite, cc.Label, cc.Button, cc.RichText,
// cc.UITransform, cc.Canvas, cc.Widget,
// cc.BoxCollider2D, cc.RigidBody2D, etc.// Tool: component_script
{
"action": "add_script",
"nodeUuid": "node-uuid",
"scriptName": "PlayerController", // Script file name without .ts
"properties": {
"speed": 100,
"jumpForce": 500
}
}// Tool: component_query
{
"action": "get_components",
"nodeUuid": "node-uuid"
}
// Returns array with type (cid) and properties for each component// Tool: component_manage
// MUST use component's cid (type field), NOT script name!
// First, get component info:
{
"action": "get_components",
"nodeUuid": "node-uuid"
}
// Returns: [{ type: "comp.PlayerController!1234abcd", ... }]
// Then remove using exact type (cid):
{
"action": "remove",
"nodeUuid": "node-uuid",
"componentType": "comp.PlayerController!1234abcd" // Use exact cid
}// Tool: set_component_property
{
"nodeUuid": "node-uuid",
"componentType": "cc.Sprite",
"properties": {
"color": { "r": 255, "g": 0, "b": 0, "a": 255 }
}
}
// For custom scripts, use full cid from get_components
{
"nodeUuid": "node-uuid",
"componentType": "comp.PlayerController!1234abcd",
"properties": {
"health": 100,
"maxSpeed": 200
}
}// Tool: prefab_browse
{
"action": "list",
"folderPath": "db://assets/prefabs/" // Optional
}// Tool: prefab_lifecycle
{
"action": "create",
"nodeUuid": "source-node-uuid",
"savePath": "db://assets/prefabs/MyPrefab.prefab"
}// Tool: prefab_instance
{
"action": "instantiate",
"prefabUuid": "prefab-uuid",
"parentUuid": "parent-node-uuid", // Optional
"position": { "x": 0, "y": 0, "z": 0 } // Optional
}// Tool: prefab_instance
{
"action": "apply",
"nodeUuid": "prefab-instance-uuid"
}// Tool: prefab_instance
{
"action": "revert",
"nodeUuid": "prefab-instance-uuid"
}// Tool: asset_manage
{
"action": "import",
"paths": [
"/path/to/texture.png",
"/path/to/audio.mp3"
]
}// Tool: asset_query
{
"action": "query_by_type",
"type": "cc.Texture2D", // cc.Texture2D, cc.SpriteFrame, cc.Prefab, cc.AudioClip, etc.
"folder": "db://assets/textures/" // Optional
}// Tool: asset_analyze
{
"action": "get_dependencies",
"uuid": "asset-uuid"
}// Tool: asset_operations
{
"action": "delete",
"uuid": "asset-uuid"
}// Tool: project_manage
{
"action": "run",
"preview": true // false for simulator
}// Tool: project_build_system
{
"action": "build",
"platform": "web-mobile", // web-mobile, android, ios, windows, mac
"buildPath": "/path/to/build/output"
}// Tool: project_manage
{
"action": "get_info"
}
// Returns project name, version, path, settings// Tool: debug_console
{
"action": "get_logs",
"filter": "error", // Optional: log, warn, error
"limit": 50 // Optional
}// Tool: debug_console
{
"action": "clear"
}// Tool: debug_logs
{
"action": "search",
"pattern": "Error:",
"maxLines": 100
}// 1. Create node
const createNode = {
tool: "node_lifecycle",
arguments: {
action: "create",
name: "Player",
nodeType: "2DNode"
}
};
// Response includes: { uuid: "player-node-uuid" }
// 2. Add sprite component
const addSprite = {
tool: "component_manage",
arguments: {
action: "add",
nodeUuid: "player-node-uuid",
componentType: "cc.Sprite",
properties: {
spriteFrame: "player-texture-uuid"
}
}
};
// 3. Attach script
const addScript = {
tool: "component_script",
arguments: {
action: "add_script",
nodeUuid: "player-node-uuid",
scriptName: "PlayerController",
properties: {
speed: 300,
health: 100
}
}
};
// 4. Position node
const setPosition = {
tool: "node_transform",
arguments: {
action: "set_property",
uuid: "player-node-uuid",
property: "position",
value: { x: 0, y: 0, z: 0 }
}
};// 1. Find a node to convert
const findNode = {
tool: "node_query",
arguments: {
action: "find_by_name",
name: "Enemy"
}
};
// 2. Create prefab from node
const createPrefab = {
tool: "prefab_lifecycle",
arguments: {
action: "create",
nodeUuid: "enemy-node-uuid",
savePath: "db://assets/prefabs/Enemy.prefab"
}
};
// 3. Instantiate multiple times
const spawn1 = {
tool: "prefab_instance",
arguments: {
action: "instantiate",
prefabUuid: "enemy-prefab-uuid",
position: { x: 100, y: 0, z: 0 }
}
};
const spawn2 = {
tool: "prefab_instance",
arguments: {
action: "instantiate",
prefabUuid: "enemy-prefab-uuid",
position: { x: -100, y: 0, z: 0 }
}
};// 1. Find all enemy nodes
const findEnemies = {
tool: "node_query",
arguments: {
action: "find_by_name",
name: "Enemy",
exactMatch: false // Pattern match
}
};
// Returns: [{ uuid: "enemy1-uuid" }, { uuid: "enemy2-uuid" }, ...]
// 2. Delete all enemies
// For each enemy uuid:
const deleteEnemy = {
tool: "node_lifecycle",
arguments: {
action: "delete",
uuid: "enemy-uuid"
}
};// 1. Create new scene
const newScene = {
tool: "scene_management",
arguments: {
action: "create_scene",
name: "Level1",
savePath: "db://assets/scenes/"
}
};
// 2. Create background node
const background = {
tool: "node_lifecycle",
arguments: {
action: "create",
name: "Background",
nodeType: "2DNode",
components: [{
type: "cc.Sprite",
properties: {
spriteFrame: "bg-texture-uuid"
}
}]
}
};
// 3. Create UI canvas
const canvas = {
tool: "node_lifecycle",
arguments: {
action: "create",
name: "Canvas",
nodeType: "2DNode",
components: [{
type: "cc.Canvas"
}]
}
};
// 4. Save scene
const saveScene = {
tool: "scene_management",
arguments: {
action: "save_scene"
}
};# MCP server endpoint
COCOS_MCP_URL=http://127.0.0.1:3000/mcp
# Project path (if automating multiple projects)
COCOS_PROJECT_PATH=/path/to/projectnetstat -an | grep 3000cidcomponent_query// ✅ CORRECT
// First get component info
{ action: "get_components", nodeUuid: "node-uuid" }
// Returns: [{ type: "comp.MyScript!abc123", ... }]
// Then remove with exact cid
{
action: "remove",
nodeUuid: "node-uuid",
componentType: "comp.MyScript!abc123"
}
// ❌ WRONG - Don't use script name
{
action: "remove",
nodeUuid: "node-uuid",
componentType: "MyScript" // Will fail!
}{"__id__": x}nullcurl http://127.0.0.1:3000/mcpdb://// ✅ CORRECT - Cross-platform
"savePath": "db://assets/prefabs/MyPrefab.prefab"
// ❌ WRONG - Platform-specific
"savePath": "/Users/me/project/assets/prefabs/MyPrefab.prefab"// Listen for custom events
const listen = {
tool: "broadcast_message",
arguments: {
action: "listen",
channel: "game-events"
}
};
// Send custom messages
const broadcast = {
tool: "broadcast_message",
arguments: {
action: "broadcast",
channel: "game-events",
message: { event: "player_died", score: 100 }
}
};// Get editor preferences
const getPrefs = {
tool: "preferences_manage",
arguments: {
action: "get",
key: "editor.grid.snap"
}
};
// Set preferences
const setPrefs = {
tool: "preferences_manage",
arguments: {
action: "set",
key: "editor.grid.snap",
value: true
}
};// Get detailed system info
const systemInfo = {
tool: "debug_system",
arguments: {
action: "get_info"
}
};
// Returns: editor version, OS, memory, performance statssave_scene