Cocos V3 Ui
БесплатноНе проверенAn MCP server that lets Claude Code drive the Cocos Creator 3.8.x editor to build UI, enabling translation of Figma designs into Cocos scenes by creating nodes,
Описание
An MCP server that lets Claude Code drive the Cocos Creator 3.8.x editor to build UI, enabling translation of Figma designs into Cocos scenes by creating nodes, components, sprites, and prefabs.
README
MCP server (UI-design tools) for Cocos Creator 3.8.x, built as an editor package. It lets an MCP client (Claude Code) drive the editor to build UI — ideal for translating a Figma design into a Cocos scene: read the design with the Figma MCP, then create nodes/components/sprites/prefabs here.
Ported (not mechanically) from a 2.x cocos-mcp-v2-ui. 3.x differs fundamentally:
the scene bridge is the Promise-based Editor.Message.request('scene','execute-scene-script'),
node size/anchor/opacity/color live on components (cc.UITransform / cc.UIOpacity /
the render component — not on the node as in 2.x), and the package is plain CommonJS.
Architecture
Claude Code ──stdio(MCP)──▶ bridge/ ──HTTP /rpc──▶ editor package (main proc)
(system Node, core/server + registry + tools
@modelcontextprotocol) │
▼ Editor.Message.request
('scene','execute-scene-script')
scene.js (scene proc, cc.* live)
- Editor package (
main.js,core/,tools/,scene.js,scene/) runs inside Cocos Creator.main.jsstarts an HTTP server (core/server.js) exposingGET /health,POST /rpc {tool,args},GET /tools, and a statelessPOST /mcp. The server is loopback-only and rejects browser-originated requests (noOriginheader, loopbackHostonly) so a web page cannot drive the editor (seeisLocalRequest). - Bridge (
bridge/) is a separate Node process Claude spawns. It speaks the MCP protocol over stdio (via the official SDK) and proxiestools/list+tools/callto the editor's HTTP/tools+/rpc. Keeping MCP-spec compliance out of the editor process. - Single-responsibility / DRY: tool modules are thin (schema + delegate). Everything
crossing into the scene goes through one
core/scene-bridge.js#callScene; onecore/response.jsshape; scene-side has oneresolveNode, oneserialize, oneapplyTransform. Each mutating tool records an editorsnapshot(undo + dirty flag).
Install
- Symlink (or copy) this folder into the project's
extensions/(orpackages/):ln -s /Users/nguyennt/Documents/MCP/cocos-mcp-v3-ui \ <your-cocos-3.x-project>/extensions/cocos-mcp-v3-ui - Install the bridge deps once:
cd bridge && npm install. - Open the project in Cocos Creator 3.8.x. The package auto-starts the server on
port 8585 (
autoStart: true). Panel: menu Extension → Cocos MCP v3 UI → Open Panel.
Connect to Claude Code
claude mcp add cocos-ui --transport stdio -- \
node /Users/nguyennt/Documents/MCP/cocos-mcp-v3-ui/bridge/bin/cocos-ui-bridge.js --port 8585
Verify: /mcp in Claude lists cocos-ui connected and the 36 tools. The editor must be
running with a scene open for scene tools to work (otherwise they return No active scene).
Tools (36)
| Category | Tools |
|---|---|
| ping (1) | ping |
| scene (5) | get_current_scene, get_scene_hierarchy, open_scene, save_scene, capture_node |
| node (10) | create_node, get_node_info, find_nodes, set_node_transform, set_node_property, set_node_properties_batch, create_node_tree, set_sibling_index, delete_node, duplicate_node |
| component (13) | add_component, set_component_property, get_components, remove_component, set_component_reference, add_click_event, add_components_batch, set_component_references_batch, add_click_events_batch, set_label_style, apply_widget, draw_rounded_rect, apply_gradient |
| asset (2) | import_asset, query_asset_uuid |
| prefab (2) | create_prefab, instantiate_prefab |
| referenceImage (3) | add_reference_image, set_reference_image_data, remove_reference_image |
MCP tool name = <category>_<method> (e.g. node_create_node,
referenceImage_add_reference_image). A category must not contain an underscore — dispatch
splits on the FIRST underscore.
Highlights (added per build-experience feedback)
coloris forgiving:set_component_property/set_node_property/tree specs accept{r,g,b,a},[r,g,b,a], or a hex string ("#161718").create_node_tree: build an entire node + component + property subtree in ONE call (returns uuids).draw_rounded_rect: native rounded backgrounds/borders viacc.Graphics— no texture hacks.apply_gradient: bakes a rounded gradient PNG and binds it as a spriteFrame — real gradient buttons/badges (cc.Graphicsfill is solid-only).set_component_reference+add_click_event: wireScrollView.content,Widget.target, button handlers, etc.- Enum names: enum props accept names (
type:"VERTICAL",sizeMode:"CUSTOM") as well as numbers. import_assetauto-creates the destination folder, auto-rasterizes SVG-content files, and fails loudly instead of silently importing nothing. spriteFrame assignment preserves node size.
Figma → Cocos workflow
- Read the design with the Figma MCP (positions, sizes, colors, text).
scene_get_scene_hierarchy→ find theCanvasuuid.- (optional) export a screenshot from Figma →
asset_import_asset→referenceImage_add_reference_image { spriteFrameUuid }to trace it. node_create_nodeper element →component_add_component(cc.Sprite/cc.Label/cc.Button/cc.Widget/cc.Layout) →component_set_component_property(string, fontSize, color, spriteFrame) →node_set_node_transformto place/size.- For images:
asset_import_assetreturnsspriteFrameUuid— pass that toset_component_property property:"spriteFrame"(it persists; the texture uuid does not). - Reusable bits:
prefab_create_prefab→prefab_instantiate_prefab. scene_save_scene.
Notes & limitations (3.x specifics)
capture_node(edit-mode) — 3.x has no immediate-modecamera.render(node), so we render through a temporary off-screencc.Camera+cc.RenderTextureframed on the node's world bounds, force a frame, thenreadPixels()(falls back to borrowing the scene camera). The scene side returns base64 RGBA (bottom-up); the main side flips + PNG-encodes to disk and returns the path. Works in edit mode at the node's own aspect;maxSizecaps the longest side (default 720). You can also verify by DATA withget_scene_hierarchy/get_components.- One render component per node (3.8.x) —
cc.Sprite,cc.Graphics,cc.Label,cc.RichTextall derive fromcc.UIRendererand remain mutually exclusive on a node (verified: addingcc.Spritenext tocc.Graphicsthrows a conflict error). So a node can't have bothdraw_rounded_rect(Graphics) andapply_gradient/spriteFrame(Sprite) —apply_gradientauto-routes to a childgradient_bgnode when the target already has a render component, andadd_componentsurfaces the engine's conflict message. - Reference image is simulated — Cocos has a native reference-image gizmo, but to keep the
workflow we add a low-opacity
Spritenode__ReferenceImage__behind the UI. Remove it before shipping (remove_reference_image); it is a real scene node. - Editor Hierarchy/Inspector refresh on the next reselect/reload after raw-runtime
mutations. Each mutating tool records a
snapshot(so undo works and the scene is marked dirty); the live scene/canvas updates immediately. - No main-process hot-reload: editing
main.js/core//tools//scene/during development requires a full editor restart (Developer → Reload Extensions/Editor). At runtime this is irrelevant — the server starts on project open. - spriteFrame: importing a PNG yields a texture and a
sprite-framesub-asset. Bind the sub-asset uuid (returned asspriteFrameUuid). In 3.x these sub-assets have stable uuid suffixes (<uuid>@f9941spriteFrame,<uuid>@6c48atexture);assetdb.importFilesverifies them viaasset-db:query-urlbefore returning. - Verified editor messages (3.8.x): scene
execute-scene-script/save-scene/open-scene/snapshot;asset-db:query-uuid/query-url/import-asset/create-asset/refresh-asset. Prefab create uses the scenecreate-prefabmessage where available, with a manual drag-to-Assets fallback.
Security
The HTTP server binds 127.0.0.1 and only serves loopback requests that carry no Origin
header (i.e. the Node bridge, not a browser). This prevents a malicious web page from POSTing to
http://127.0.0.1:8585/rpc to drive the editor or write files, and the loopback Host check
blocks DNS-rebinding. Do not expose the port beyond localhost.
Tests
- Unit (pure logic — colors, enums, PNG encoder, gradient, SVG sniff; no editor needed):
node test/unit.test.js - Integration (error/edge paths for the scene & component tools; needs the editor running with a
scene open — creates a temp container node and deletes it afterwards):
node test/integration.test.js --port 8585 - See
test/manual-checklist.mdfor the per-tool manual verification steps.
Установка Cocos V3 Ui
У этого сервера нет опубликованного пакета — он собирается из исходников. Открой репозиторий и следуй инструкции в README.
▸ github.com/nguyennt02/cocos-mcp-v3-uiFAQ
Cocos V3 Ui MCP бесплатный?
Да, Cocos V3 Ui MCP бесплатный — установка в пару кликов через Unyly без оплаты.
Нужен ли API-ключ для Cocos V3 Ui?
Нет, Cocos V3 Ui работает без API-ключей и переменных окружения.
Cocos V3 Ui — hosted или self-hosted?
Self-hosted: сервер запускается локально на твоей машине командой из раздела установки.
Как установить Cocos V3 Ui в Claude Desktop, Claude Code или Cursor?
Открой Cocos V3 Ui на unyly.org, выбери вкладку своего клиента (Claude Desktop, Claude Code, Cursor) и нажми Install — конфиг сгенерируется автоматически, без правки JSON.
Похожие MCP
GitHub
PRs, issues, code search, CI status
автор: GitHubFilesystem
Secure file operations with configurable access controls.
Memory
Knowledge graph-based persistent memory system.
Template MCP Server
A CLI tool to create a new Model Context Protocol server project with TypeScript support, dual transport options, and an extensible structure
автор: mcpdotdirectCompare Cocos V3 Ui with
Не уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории development
