cocos-mcp-v3-ui
Provides tools for building and manipulating UI in Cocos Creator 3.x scenes, including node creation/transformation, component management (Sprite, Label, Button, Widget, Layout, Graphics), asset importing, prefab creation, scene operations, and reference images.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@cocos-mcp-v3-uicreate a button with rounded corners and gradient"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
cocos-mcp-v3-ui
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).
Related MCP server: cocos-mcp-server
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-uiInstall 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 8585Verify: /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) |
|
scene (5) |
|
node (10) |
|
component (13) |
|
asset (2) |
|
prefab (2) |
|
referenceImage (3) |
|
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.jsIntegration (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 8585See
test/manual-checklist.mdfor the per-tool manual verification steps.
This server cannot be deployed
Maintenance
Related MCP Connectors
The Figma MCP server brings Figma design context directly into your AI workflow.
Augments MCP Server - A comprehensive framework documentation provider for Claude Code
Build, run and publish 3D games in the Zero engine from Claude Code, Cursor or Codex, over MCP.
Hosted X Ads MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Related MCP Servers
- AlicenseCqualityCmaintenanceA comprehensive MCP server that enables Claude to read, create, edit, and generate code from Figma designs. Supports design tokens, code generation to multiple frameworks, and accessibility checks.1004MIT
- AlicenseNot gradedqualityDmaintenanceA comprehensive MCP server plugin for Cocos Creator 3.8+ that enables AI assistants to control the editor via standardized protocol, offering 50 tools for scene, node, component, prefab, asset, project, and debugging operations.12 npm1MIT
- AlicenseNot gradedqualityDmaintenanceA comprehensive MCP server for Cocos Creator 3.8+ that enables AI assistants to interact with the editor via 50+ tools for scene, node, component, prefab, asset, and project management.12 npm1MIT
- AlicenseNot gradedqualityCmaintenanceAn MCP server plugin for Cocos Creator 3.8+ that enables AI assistants to interact with and control the editor through a standardized protocol.12 npm1MIT