### Start Preview Server Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Starts the preview server for the Cocos Creator project. ```APIDOC ## POST /project_start_preview_server ### Description Starts the preview server for the Cocos Creator project. ### Method POST ### Endpoint /project_start_preview_server ### Parameters #### Request Body - **tool** (string) - Required - Must be "project_start_preview_server" - **arguments** (object) - Required - **port** (number) - Optional - The port for the preview server. Defaults to 7456. ### Request Example ```json { "tool": "project_start_preview_server", "arguments": { "port": 8080 } } ``` ### Response #### Success Response (200) (No specific success response details provided in the source text, assuming a success indicator) #### Response Example (No example provided in the source text) ``` -------------------------------- ### Start Preview Server Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Starts the preview server for the Cocos Creator project. An optional port number can be specified; otherwise, it defaults to 7456. This is used for live previewing of the project. ```json { "tool": "project_start_preview_server", "arguments": { "port": 8080 } } ``` -------------------------------- ### Tool Call Format Example Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Demonstrates the standard JSON-RPC 2.0 format for calling tools within Cocos Creator. ```json { "jsonrpc": "2.0", "method": "tools/call", "params": { "name": "tool_name", "arguments": { // Tool parameters } }, "id": 1 } ``` -------------------------------- ### Asset Path Format Example Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Illustrates the `db://` prefixed asset URL format used by Cocos Creator for referencing assets like scenes, prefabs, scripts, and textures. ```json // Scenes: db://assets/scenes/GameScene.scene // Prefabs: db://assets/prefabs/Player.prefab // Scripts: db://assets/scripts/GameManager.ts // Textures: db://assets/textures/player.png ``` -------------------------------- ### Get Project Settings Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Retrieves project settings for a specified category. The 'category' parameter is optional and can be 'general', 'physics', 'render', or 'assets', defaulting to 'general'. ```json { "tool": "project_get_project_settings", "arguments": { "category": "physics" } } ``` -------------------------------- ### List Available Tools Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt Retrieves a list of all available tools, their categories, descriptions, and curl examples. ```APIDOC ## GET /api/tools ### Description List all available tools with categories, descriptions, and curl examples. ### Method GET ### Endpoint /api/tools ### Parameters (No parameters required) ### Request Example ```bash curl http://127.0.0.1:3000/api/tools ``` ### Response #### Success Response (200) - **tools** (array) - An array of tool objects, each containing category, description, and examples. #### Response Example ```json { "tools": [ { "category": "Debug", "name": "debug_get_project_logs", "description": "Read project logs from temp/logs/project.log file with filtering.", "examples": { "curl": "..." } } // ... other tools ] } ``` ``` -------------------------------- ### Start Cocos Creator MCP Server (TypeScript) Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt Configures and starts the MCP HTTP server within Cocos Creator. It defines settings like port, auto-start behavior, debug logging, and maximum connections. The server is accessible via a specified HTTP endpoint and provides a health check. ```typescript interface MCPServerSettings { port: number; // HTTP server port (default: 3000) autoStart: boolean; // Auto-start when editor opens debugLogging: boolean; // Enable detailed logging maxConnections: number; // Max concurrent connections } // Start server programmatically const server = new MCPServer({ port: 3000, autoStart: true, debugLogging: false, maxConnections: 10 }); await server.start(); // Server available at: http://127.0.0.1:3000/mcp // Health check at: http://127.0.0.1:3000/health ``` -------------------------------- ### UUID Retrieval Methods Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Provides examples of common methods used to retrieve UUIDs for nodes, scenes, and prefabs. ```json // Use node_get_all_nodes to get all node UUIDs // Use node_find_node_by_name to find node UUIDs by name // Use scene_get_current_scene to get scene UUID // Use prefab_get_prefab_list to get prefab information ``` -------------------------------- ### Get Build Settings Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Retrieves the current build settings configured for the Cocos Creator project. This command does not require any parameters. ```json { "tool": "project_get_build_settings", "arguments": {} } ``` -------------------------------- ### Project Management Tools Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Tools for managing project preferences and recent projects. ```APIDOC ## POST /preferences_clear_recent_projects ### Description Clears the list of recently opened projects. ### Method POST ### Endpoint /preferences_clear_recent_projects ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **tool** (string) - Required - The name of the tool to call. - **arguments** (object) - Required - An empty object for this tool. ### Request Example ```json { "tool": "preferences_clear_recent_projects", "arguments": {} } ``` ### Response #### Success Response (200) - **result** (object) - An empty object indicating success. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": {} } ``` ``` -------------------------------- ### Preferences Tools API Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Provides endpoints for managing editor preferences. ```APIDOC ## GET /preferences/get ### Description Retrieves editor preferences. ### Method GET ### Endpoint /preferences/get ### Query Parameters - **key** (string, optional) - The specific preference key to retrieve. ### Response #### Success Response (200) - **value** (any) - The value of the requested preference key, or all preferences if no key is specified. #### Response Example { "value": "dark" } ``` ```APIDOC ## POST /preferences/set ### Description Sets an editor preference. ### Method POST ### Endpoint /preferences/set ### Parameters #### Request Body - **key** (string, required) - The preference key to set. - **value** (any, required) - The preference value to set. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the preference was set successfully. #### Response Example { "success": true } ``` ```APIDOC ## GET /preferences/global/get ### Description Retrieves global editor preferences. ### Method GET ### Endpoint /preferences/global/get ### Query Parameters - **key** (string, optional) - The specific global preference key to retrieve. ### Response #### Success Response (200) - **value** (any) - The value of the requested global preference key, or all global preferences if no key is specified. #### Response Example { "value": true } ``` ```APIDOC ## POST /preferences/global/set ### Description Sets a global editor preference. ### Method POST ### Endpoint /preferences/global/set ### Parameters #### Request Body - **key** (string, required) - The global preference key to set. - **value** (any, required) - The global preference value to set. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the global preference was set successfully. #### Response Example { "success": true } ``` ```APIDOC ## GET /preferences/recent/projects ### Description Retrieves a list of recently opened projects. ### Method GET ### Endpoint /preferences/recent/projects ### Parameters #### Request Body None ### Response #### Success Response (200) - **projects** (array) - An array of strings, each representing a recently opened project path. #### Response Example { "projects": [ "/path/to/project1", "/path/to/project2" ] } ``` -------------------------------- ### Tool Call Error Handling Example Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Shows the JSON structure returned when a tool call fails, including error code, message, and detailed data. ```json { "jsonrpc": "2.0", "id": 1, "error": { "code": -32000, "message": "Tool execution failed", "data": { "error": "Detailed error message" } } } ``` -------------------------------- ### Get Editor Information Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt Retrieves information about the Cocos Creator editor and its environment. This tool takes no arguments and provides details about the current editor setup. ```json { "tool": "debug_get_editor_info", "arguments": {} } ``` -------------------------------- ### Project Build Settings Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Retrieves the current build settings configured for the project. ```APIDOC ## POST /project_get_build_settings ### Description Retrieves the current build settings configured for the project. ### Method POST ### Endpoint /project_get_build_settings ### Parameters #### Request Body - **tool** (string) - Required - Must be "project_get_build_settings" - **arguments** (object) - Required - No arguments needed. ### Request Example ```json { "tool": "project_get_build_settings", "arguments": {} } ``` ### Response #### Success Response (200) (No specific success response details provided in the source text, assuming build settings are returned) #### Response Example (No example provided in the source text) ``` -------------------------------- ### Get Assets by Type and Folder Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Fetches a list of assets based on their type and within a specified folder. Supports filtering by 'all', 'scene', 'prefab', 'script', 'texture', 'material', 'mesh', 'audio', and 'animation'. Defaults to all types and the root assets folder. ```json { "tool": "project_get_assets", "arguments": { "type": "texture", "folder": "db://assets/textures" } } ``` -------------------------------- ### Get Project Logs Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Retrieves logs from the project's log file ('temp/logs/project.log'). Allows specifying the number of lines, filtering by a keyword, and filtering by log level (ERROR, WARN, INFO, DEBUG, TRACE, ALL). ```json { "tool": "debug_get_project_logs", "arguments": { "lines": 200, "filterKeyword": "prefab", "logLevel": "INFO" } } ``` -------------------------------- ### Get Project Log File Info Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Provides information about the project's log file, including its size, last modified time, line count, and file path. This tool requires no parameters. ```json { "tool": "debug_get_log_file_info", "arguments": {} } ``` -------------------------------- ### Open Build Panel Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Opens the build panel within the Cocos Creator editor. ```APIDOC ## POST /project_open_build_panel ### Description Opens the build panel within the Cocos Creator editor. ### Method POST ### Endpoint /project_open_build_panel ### Parameters #### Request Body - **tool** (string) - Required - Must be "project_open_build_panel" - **arguments** (object) - Required - No arguments needed. ### Request Example ```json { "tool": "project_open_build_panel", "arguments": {} } ``` ### Response #### Success Response (200) (No specific success response details provided in the source text, assuming a success indicator) #### Response Example (No example provided in the source text) ``` -------------------------------- ### Project Assets Query Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Retrieves a list of assets from the project, with optional filtering by type and folder. ```APIDOC ## POST /project_get_assets ### Description Retrieves a list of assets from the project, with optional filtering by type and folder. ### Method POST ### Endpoint /project_get_assets ### Parameters #### Request Body - **tool** (string) - Required - Must be "project_get_assets" - **arguments** (object) - Required - **type** (string) - Optional - Asset type filter. Options: `all`, `scene`, `prefab`, `script`, `texture`, `material`, `mesh`, `audio`, `animation`. Defaults to `all`. - **folder** (string) - Optional - Search folder. Defaults to `db://assets`. ### Request Example ```json { "tool": "project_get_assets", "arguments": { "type": "texture", "folder": "db://assets/textures" } } ``` ### Response #### Success Response (200) (No specific success response details provided in the source text, assuming a list of assets is returned) #### Response Example (No example provided in the source text) ``` -------------------------------- ### Preferences: Get Preferences Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt Retrieves editor preferences by a specified key. ```APIDOC ## POST preferences_get_preferences ### Description Get editor preferences by key. ### Method POST ### Endpoint /api/preferences/get_preferences ### Parameters #### Request Body - **key** (string) - Required - The key of the preference to retrieve. ### Request Example ```json { "tool": "preferences_get_preferences", "arguments": { "key": "editor.theme" } } ``` ### Response #### Success Response (200) - **result** (any) - The value of the requested preference. - **success** (boolean) - Indicates if the operation was successful. - **tool** (string) - The name of the tool that was executed. #### Response Example ```json { "success": true, "tool": "preferences_get_preferences", "result": "dark" } ``` ``` -------------------------------- ### Debug: Get Editor Info Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt Retrieves information about the Cocos Creator editor and its environment. ```APIDOC ## POST debug_get_editor_info ### Description Get editor and environment information. ### Method POST ### Endpoint /api/debug/get_editor_info ### Parameters #### Request Body (No arguments required) ### Request Example ```json { "tool": "debug_get_editor_info", "arguments": {} } ``` ### Response #### Success Response (200) - **result** (object) - Contains editor and environment information. - **success** (boolean) - Indicates if the operation was successful. - **tool** (string) - The name of the tool that was executed. #### Response Example ```json { "success": true, "tool": "debug_get_editor_info", "result": { "version": "3.8.0", "platform": "win32", "editorPath": "C:\\CocosCreator\\3.8.0\\CocosCreator.exe" } } ``` ``` -------------------------------- ### Project Asset Creation Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Creates a new asset file or folder within the project's assets. ```APIDOC ## POST /project_create_asset ### Description Creates a new asset file or folder within the project's assets. ### Method POST ### Endpoint /project_create_asset ### Parameters #### Request Body - **tool** (string) - Required - Must be "project_create_asset" - **arguments** (object) - Required - **url** (string) - Required - The URL of the asset to create (e.g., "db://assets/scripts/NewScript.ts"). - **content** (string) - Optional - The content of the file. If null, a folder will be created. - **overwrite** (boolean) - Optional - Whether to overwrite an existing file. Defaults to `false`. ### Request Example ```json { "tool": "project_create_asset", "arguments": { "url": "db://assets/scripts/NewScript.ts", "content": "// New TypeScript script\n", "overwrite": false } } ``` ### Response #### Success Response (200) (No specific success response details provided in the source text, assuming a success indicator) #### Response Example (No example provided in the source text) ``` -------------------------------- ### Get Project UUID Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Retrieves the unique identifier (UUID) for the current project. No parameters are required. ```json { "tool": "server_get_project_uuid", "arguments": {} } ``` -------------------------------- ### Get Project Name Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Retrieves the name of the currently active project. This function requires no arguments. ```json { "tool": "server_get_project_name", "arguments": {} } ``` -------------------------------- ### Tool Calling Example Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/README.EN.md Demonstrates the structure for calling a tool within the Cocos Creator MCP Server Plugin. This includes the tool name and its associated arguments. ```APIDOC ## POST /api/tools ### Description This endpoint allows AI assistants to invoke various tools provided by the Cocos Creator MCP Server Plugin. Tools are categorized and have specific arguments for their operations. ### Method POST ### Endpoint /api/tools ### Request Body - **tool** (string) - Required - The name of the tool to be invoked (e.g., "node_lifecycle"). - **arguments** (object) - Required - An object containing the parameters specific to the selected tool. - **action** (string) - Required - The specific action to perform with the tool (e.g., "create"). - **name** (string) - Optional - The name of the entity to operate on (e.g., a node name). - **parentUuid** (string) - Optional - The UUID of the parent entity if applicable. - **nodeType** (string) - Optional - The type of node to create if applicable. ### Request Example ```json { "tool": "node_lifecycle", "arguments": { "action": "create", "name": "MyNode", "parentUuid": "parent-uuid", "nodeType": "2DNode" } } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success or failure of the tool invocation. - **message** (string) - A message providing details about the result. #### Response Example ```json { "status": "success", "message": "Node 'MyNode' created successfully." } ``` ``` -------------------------------- ### Listen for Broadcast Messages Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Starts listening for specific types of broadcast messages. Requires the `messageType` to listen for. ```json { "tool": "broadcast_listen_broadcast", "arguments": { "messageType": "node_created" } } ``` -------------------------------- ### Simplified REST API: List Tools Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt Fetches a list of all available tools from the MCP server via the simplified REST API. This request to '/api/tools' returns categories, descriptions, and curl examples for each tool. ```bash curl http://127.0.0.1:3000/api/tools ``` -------------------------------- ### Get Project Path Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Returns the file system path of the current project. This tool does not take any parameters. ```json { "tool": "server_get_project_path", "arguments": {} } ``` -------------------------------- ### Get Recent Projects Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Retrieves a list of recently opened projects in the editor. This tool does not require any parameters. ```json { "tool": "preferences_get_recent_projects", "arguments": {} } ``` -------------------------------- ### MCP Server Configuration and Connection Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt Configuration options and methods for starting the MCP server within Cocos Creator, and how to connect to it using various client tools. ```APIDOC ## Server Configuration and Connection ### Starting the MCP Server Configure and start the HTTP server within Cocos Creator. ```typescript // Server settings interface interface MCPServerSettings { port: number; // HTTP server port (default: 3000) autoStart: boolean; // Auto-start when editor opens debugLogging: boolean; // Enable detailed logging maxConnections: number; // Max concurrent connections } // Start server programmatically const server = new MCPServer({ port: 3000, autoStart: true, debugLogging: false, maxConnections: 10 }); await server.start(); // Server available at: http://127.0.0.1:3000/mcp // Health check at: http://127.0.0.1:3000/health ``` ### Claude CLI Configuration ```bash claude mcp add --transport http cocos-creator http://127.0.0.1:3000/mcp ``` ### Claude Desktop Configuration ```json { "mcpServers": { "cocos-creator": { "type": "http", "url": "http://127.0.0.1:3000/mcp" } } } ``` ### Cursor/VS Code MCP Configuration ```json { "mcpServers": { "cocos-creator": { "url": "http://localhost:3000/mcp" } } } ``` ``` -------------------------------- ### Get Active Broadcast Listeners Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Retrieves a list of all currently active broadcast listeners. This function does not require any parameters. ```json { "tool": "broadcast_get_active_listeners", "arguments": {} } ``` -------------------------------- ### Get Editor Version Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Fetches the current version information of the Cocos Creator editor. No parameters are needed for this call. ```json { "tool": "server_get_editor_version", "arguments": {} } ``` -------------------------------- ### Get Prefab Information Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt Retrieves detailed information about a prefab, including its dependencies. Requires the prefab's path. ```json { "tool": "prefab_get_prefab_info", "arguments": { "prefabPath": "db://assets/prefabs/Enemy.prefab" } } ``` -------------------------------- ### Build Project Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt Opens the build panel for project compilation. A manual build is still required after opening the panel. Requires the target platform and a boolean for debug mode. ```json { "tool": "project_build_project", "arguments": { "platform": "web-mobile", "debug": false } } ``` -------------------------------- ### Initialize MCP Connection via JSON-RPC 2.0 (Bash) Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt Initiates an MCP connection by sending an 'initialize' request using JSON-RPC 2.0. The response typically includes the supported protocol version and server capabilities. ```bash curl -X POST http://127.0.0.1:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "initialize", "params": {}, "id": 1 }' # Response includes protocol version and capabilities ``` -------------------------------- ### Run Project Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Runs the Cocos Creator project in preview mode. The 'platform' parameter can be specified to target different environments like 'browser', 'simulator', or 'preview', defaulting to 'browser'. ```json { "tool": "project_run_project", "arguments": { "platform": "browser" } } ``` -------------------------------- ### Tool Calling Example for Node Creation Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/README.EN.md This JSON object demonstrates how to call a tool within the Cocos Creator MCP Server Plugin to perform an action. It specifies the tool to be used ('node_lifecycle') and its arguments, including the desired action ('create'), the name of the node ('MyNode'), its parent's UUID, and its type ('2DNode'). This format is used for all tool interactions. ```json { "tool": "node_lifecycle", "arguments": { "action": "create", "name": "MyNode", "parentUuid": "parent-uuid", "nodeType": "2DNode" } } ``` -------------------------------- ### Get Component Information Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Fetches detailed information about a specific component on a node. Requires the node's UUID and the component type. ```json { "tool": "component_get_component_info", "arguments": { "nodeUuid": "node-uuid-here", "componentType": "cc.Sprite" } } ``` -------------------------------- ### Get Broadcast Log Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Retrieves a log of recent broadcast messages. Optional parameters include a limit for the number of messages and a message type filter. ```json { "tool": "broadcast_get_broadcast_log", "arguments": { "limit": 100, "messageType": "scene_change" } } ``` -------------------------------- ### List Available MCP Tools via JSON-RPC 2.0 (Bash) Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt Sends a JSON-RPC 2.0 request to the '/mcp' endpoint to list all available tools. This is useful for discovering the capabilities of the MCP server. ```bash curl -X POST http://127.0.0.1:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "tools/list", "params": {}, "id": 1 }' ``` -------------------------------- ### Get Global Editor Preferences Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Retrieves global editor preferences. Similar to `preferences_get_preferences`, it can accept an optional 'key' to fetch a specific global preference. ```json { "tool": "preferences_get_global_preferences", "arguments": { "key": "global.autoSave" } } ``` -------------------------------- ### Get Performance Statistics Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Fetches current performance statistics of the editor. This tool requires no parameters and provides insights into the editor's performance metrics. ```json { "tool": "debug_get_performance_stats", "arguments": {} } ``` -------------------------------- ### Instantiate Prefab (JSON) Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt Creates an instance of a prefab in the scene. Allows specifying a parent node and position for the new instance. ```json { "tool": "prefab_instantiate_prefab", "arguments": { "prefabPath": "db://assets/prefabs/Enemy.prefab", "parentUuid": "parent-node-uuid", "position": {"x": 100, "y": 200, "z": 0} } } ``` -------------------------------- ### Create Prefab from Node Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt Creates a prefab from an existing node, including all its children and components. Requires the source node's UUID, a save path, and the desired prefab name. ```json { "tool": "prefab_create_prefab", "arguments": { "nodeUuid": "source-node-uuid", "savePath": "db://assets/prefabs/", "prefabName": "MyPrefab" } } ``` -------------------------------- ### Get Prefab List (JSON) Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt Fetches a list of all prefabs within the project, with an option to filter by a specific folder path. Returns prefab details like name, path, and UUID. ```json { "tool": "prefab_get_prefab_list", "arguments": { "folder": "db://assets/prefabs" } } ``` -------------------------------- ### Get Asset Information Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Retrieves information about a specific asset using its path. This is useful for inspecting asset properties before performing other operations. The asset path is typically in the 'db://' format. ```json { "tool": "project_get_asset_info", "arguments": { "assetPath": "db://assets/textures/player.png" } } ``` -------------------------------- ### Simplified REST API: Create Node Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt Creates a new node in the scene using the simplified REST API. ```APIDOC ## POST /api/node/create_node ### Description Create a node in the scene using the simplified REST API. ### Method POST ### Endpoint /api/node/create_node ### Parameters #### Request Body - **name** (string) - Required - The name of the new node. - **parentUuid** (string) - Required - The UUID of the parent node. - **nodeType** (string) - Required - The type of the node (e.g., "2DNode"). ### Request Example ```bash curl -X POST http://127.0.0.1:3000/api/node/create_node \ -H "Content-Type: application/json" \ -d '{ "name": "NewNode", "parentUuid": "parent-uuid", "nodeType": "2DNode" }' ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **tool** (string) - The name of the tool that was executed. - **result** (object) - Contains information about the created node. #### Response Example ```json { "success": true, "tool": "node_create_node", "result": { "uuid": "new-node-uuid", "name": "NewNode" } } ``` ``` -------------------------------- ### Prefab Operations API Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt APIs for managing prefabs within the project, including listing and instantiating them. ```APIDOC ## POST /prefab_get_prefab_list ### Description Retrieves a list of all prefabs in the project, with an option to filter by folder. ### Method POST ### Endpoint /prefab_get_prefab_list ### Parameters #### Query Parameters - **folder** (string) - Optional - The path to the folder to filter prefabs by (e.g., 'db://assets/prefabs'). ### Request Body ```json { "tool": "prefab_get_prefab_list", "arguments": { "folder": "db://assets/prefabs" } } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **data** (array) - An array of prefab objects. - **name** (string) - The name of the prefab. - **path** (string) - The asset path of the prefab. - **uuid** (string) - The unique identifier of the prefab. - **folder** (string) - The folder the prefab resides in. #### Response Example ```json { "success": true, "data": [ {"name": "Enemy", "path": "db://assets/prefabs/Enemy.prefab", "uuid": "...", "folder": "db://assets/prefabs"}, {"name": "Player", "path": "db://assets/prefabs/Player.prefab", "uuid": "...", "folder": "db://assets/prefabs"} ] } ``` ``` ```APIDOC ## POST /prefab_instantiate_prefab ### Description Instantiates a prefab in the scene, with options for specifying a parent node and position. ### Method POST ### Endpoint /prefab_instantiate_prefab ### Parameters #### Query Parameters - **prefabPath** (string) - Required - The asset path of the prefab to instantiate (e.g., 'db://assets/prefabs/Enemy.prefab'). - **parentUuid** (string) - Optional - The UUID of the node to be the parent of the instantiated prefab. - **position** (object) - Optional - The position to place the instantiated prefab at. Should contain 'x', 'y', and 'z' properties. ### Request Body ```json { "tool": "prefab_instantiate_prefab", "arguments": { "prefabPath": "db://assets/prefabs/Enemy.prefab", "parentUuid": "parent-node-uuid", "position": {"x": 100, "y": 200, "z": 0} } } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **data** (object) - Contains information about the instantiated prefab. - **nodeUuid** (string) - The UUID of the newly instantiated node. - **prefabPath** (string) - The path of the prefab that was instantiated. - **message** (string) - A confirmation message. #### Response Example ```json { "success": true, "data": { "nodeUuid": "instantiated-node-uuid", "prefabPath": "db://assets/prefabs/Enemy.prefab", "message": "Prefab instantiation successful" } } ``` ``` -------------------------------- ### Call MCP Tool via JSON-RPC 2.0 (Bash) Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt Demonstrates how to call an MCP tool ('scene_get_current_scene') using a standard JSON-RPC 2.0 request over HTTP POST to the '/mcp' endpoint. It includes the request format and an example response. ```bash curl -X POST http://127.0.0.1:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "tools/call", "params": { "name": "scene_get_current_scene", "arguments": {} }, "id": 1 }' # Response: # { # "jsonrpc": "2.0", # "id": 1, # "result": { # "content": [{ # "type": "text", # "text": "{\"success\":true,\"data\":{\"name\":\"Main\",\"uuid\":\"abc123\",\"nodeCount\":15}}" # }] # } # } ``` -------------------------------- ### Get Node Tree Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Retrieves a detailed tree structure of nodes in the scene for debugging purposes. Optionally accepts a root node UUID and a maximum depth for the tree traversal. Defaults to the scene root and a depth of 10. ```json { "tool": "debug_get_node_tree", "arguments": { "rootUuid": "root-node-uuid", "maxDepth": 5 } } ``` -------------------------------- ### Get Project Information Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt Retrieves general information about the current Cocos project, including its name, path, UUID, and Cocos editor version. No arguments are required. ```json { "tool": "project_get_project_info", "arguments": {} } ``` -------------------------------- ### Get Current Scene Information (MCP) Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Retrieves information about the currently active scene in Cocos Creator. This tool requires no parameters and returns details such as the scene's name, UUID, type, active status, and the total number of nodes within it. ```JSON { "tool": "scene_get_current_scene", "arguments": {} } ``` -------------------------------- ### Simplified REST API: Get Current Scene Source: https://context7.com/daxianlee/cocos-mcp-server/llms.txt Retrieves the current scene information using the simplified REST API. ```APIDOC ## POST /api/scene/get_current_scene ### Description Get the current scene using the simplified REST API. ### Method POST ### Endpoint /api/scene/get_current_scene ### Parameters #### Request Body (No arguments required) ### Request Example ```bash curl -X POST http://127.0.0.1:3000/api/scene/get_current_scene \ -H "Content-Type: application/json" \ -d '{}' ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **tool** (string) - The name of the tool that was executed. - **result** (object) - Contains the current scene data. #### Response Example ```json { "success": true, "tool": "scene_get_current_scene", "result": { "uuid": "scene-uuid", "name": "MyScene" } } ``` ``` -------------------------------- ### Project Asset Save Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Saves the content of a specified asset. ```APIDOC ## POST /project_save_asset ### Description Saves the content of a specified asset. ### Method POST ### Endpoint /project_save_asset ### Parameters #### Request Body - **tool** (string) - Required - Must be "project_save_asset" - **arguments** (object) - Required - **url** (string) - Required - The URL of the asset to save (e.g., "db://assets/scripts/GameManager.ts"). - **content** (string) - Required - The new content for the asset. ### Request Example ```json { "tool": "project_save_asset", "arguments": { "url": "db://assets/scripts/GameManager.ts", "content": "// Updated script content\n" } } ``` ### Response #### Success Response (200) (No specific success response details provided in the source text, assuming a success indicator) #### Response Example (No example provided in the source text) ``` -------------------------------- ### Project Asset Delete Source: https://github.com/daxianlee/cocos-mcp-server/blob/main/FEATURE_GUIDE_EN.md Deletes a specified asset from the project. ```APIDOC ## POST /project_delete_asset ### Description Deletes a specified asset from the project. ### Method POST ### Endpoint /project_delete_asset ### Parameters #### Request Body - **tool** (string) - Required - Must be "project_delete_asset" - **arguments** (object) - Required - **url** (string) - Required - The URL of the asset to delete (e.g., "db://assets/textures/unused.png"). ### Request Example ```json { "tool": "project_delete_asset", "arguments": { "url": "db://assets/textures/unused.png" } } ``` ### Response #### Success Response (200) (No specific success response details provided in the source text, assuming a success indicator) #### Response Example (No example provided in the source text) ```