
Cocos Creator 2.4.x 的 MCP 桥接器——通过捆绑的 Python FastMCP 服务器将 MCP 客户端(Claude/光标)连接到编辑器。cocos-mcp-3x 的移植版本。
概览
一个编辑器扩展,将LLM(Claude桌面/光标或任何MCP客户端)连接到编辑器,让模型检查并驱动你的游戏项目:读写节点、处理资源和场景、读取控制台以及执行脚本。 这是 cocos-mcp-3x(Creator 3.8.x 版本)的 2.4.x 移植版本:,仅在扩展端调用的 2.4 编辑器 API 上有所不同。插件是——Python MCP 服务器捆绑在 ./server 上——扩展为 。 基于Cocos Creator 2.4.15开发和验证;面向整个2.4.x系列(包括2.4.9)。 - Python 端是 WebSocket;Cocos 扩展是 ,通过面板上的 Connect 按钮拨入。- 每个工具调用都会向扩展(main.js)发送一个 JSON 信封,扩展按命令名调度:资产操作使用 Editor.assetdb;节点/场景图操作会转发到场景脚本场景。
概述(AI 翻译)
英语 ·中文
一个编辑器扩展,将LLM(Claude桌面/光标或任何MCP客户端)连接到 Cocos Creator 2.4.x编辑器,让模型检查并驱动你的游戏项目:读写 节点,操作资源和场景,读取控制台,执行脚本。
这是cocos-mcp-3x(Creator 3.8.x版本)的2.4.x移植版:相同
Python MCP 服务器和 WebSocket 协议,仅在 2.4 编辑器 API 和扩展端有所不同
调用。该插件是自包含的——Python MCP服务器捆绑在./server——并且
扩展没有NPM依赖,也没有构建步骤。
基于 Cocos Creator 2.4.15 开发并验证;面向整个 2.4.x 系列(包括 2.4.9)。
它是如何运作的
- Python 端是 WebSocket server;Cocos 扩展是客户端并拨号入 通过面板上的连接按钮。
- 每个工具调用都会向扩展(
main.js)发送一个JSON信封,扩展通过命令进行调度 名称:资产操作使用Editor.assetdb;节点/场景图操作被转发到 场景脚本scene.js(通过场景中的cc引擎变异活图
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
cocos-mcp-2x
English · 中文
An editor extension that connects an LLM (Claude Desktop / Cursor or any MCP client) to the Cocos Creator 2.4.x editor, letting the model inspect and drive your game project: read/write nodes, operate on assets and scenes, read the console, and execute scripts.
This is the 2.4.x port of cocos-mcp-3x (the Creator 3.8.x version): the same
Python MCP server and WebSocket protocol, differing only in the 2.4 editor APIs the extension side
calls. The plugin is self-contained — the Python MCP server is bundled at ./server — and the
extension has no npm dependencies and no build step.
Developed and verified against Cocos Creator 2.4.15; targets the whole 2.4.x line (incl. 2.4.9).
How it works
MCP client (Claude / Cursor)
│ stdio / http
▼
Python FastMCP server ── server/src/main.py
│ WebSocket bridge 127.0.0.1:6020/cocosmcp
▼
Cocos Creator extension ── main.js (connects in as the WS client)
│
├─ Editor.assetdb / Editor.Ipc assets, scene open/save
└─ Editor.Scene.callSceneScript ──► scene.js (scene process, holds the cc engine runtime)
- The Python side is the WebSocket server; the Cocos extension is the client and dials in via the Connect button on the panel.
- Each tool call sends a JSON envelope to the extension (
main.js), which dispatches by command name: asset operations useEditor.assetdb; node/scene-graph operations are forwarded to the scene scriptscene.js(which mutates the live graph through theccengine in the scene process), then replies{id, success, data|error}.
Differences from the 3.x version
| Concern | cocos-mcp-3x (3.8.x) | cocos-mcp-2x (2.4.x) |
|---|---|---|
| Asset API | Editor.Message.request('asset-db', …) (Promise) |
Editor.assetdb.* (callbacks) |
| Scene-graph ops | Editor.Message.request('scene', …) |
Editor.Scene.callSceneScript() → scene.js |
| Console capture | hook console.* |
hook the Editor.log/warn/error family |
| Extension entry | exports.methods (3.x) |
module.exports = { load, unload, messages } (2.4) |
| Scene files | .scene |
.fire |
Tools provided
| Tool | Purpose |
|---|---|
get_project_info |
Project path, assets root, editor version, scene list, available bridge commands |
manage_scene |
List / open / save / current scene (Cocos 2.x .fire) |
manage_node |
Inspect or modify nodes in the current scene (mostly by uuid) |
manage_asset |
Inspect and manipulate assets under assets/ via the asset-db |
read_console |
Read / clear the log buffer (500-entry ring) — includes both editor logs and the running game’s own logs from the browser preview |
execute_script |
Execute arbitrary JS in the editor main context (Editor.*) or scene context (cc) |
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →