cocos-mcp-v2-ui
Provides tools for UI design automation in Cocos Creator 2.x, enabling creation, manipulation, and management of nodes, components, assets, prefabs, and scenes programmatically.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
cocos-mcp-v2-ui
MCP server (UI-design tools) for Cocos Creator 2.x (verified on 2.4.11), 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 the 3.8.x cocos-mcp-server. 2.x differs fundamentally:
the scene bridge is the callback-based Editor.Scene.callSceneScript, node size/anchor
live on the node (no UITransform), 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.Scene.callSceneScript
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.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's old Node.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.
Related MCP server: cocos-mcp-server
Install
Symlink (or copy) this folder into the project's
packages/:ln -s /Users/nguyennt/Documents/MCP/cocos-mcp-v2-ui \ /Users/nguyennt/Documents/Cocos/testMCP/packages/cocos-mcp-v2-uiInstall the bridge deps once:
cd bridge && npm install.Open the project in Cocos Creator 2.4.x. The package auto-starts the server on port 8585 (
autoStart: true). Panel: menu Extension → Cocos MCP v2 UI.
Connect to Claude Code
claude mcp add cocos-ui --transport stdio -- \
node /Users/nguyennt/Documents/MCP/cocos-mcp-v2-ui/bridge/bin/cocos-ui-bridge.js --port 8585Verify: /mcp in Claude lists cocos-ui connected and the 32 tools. The editor must be
running with a scene open for scene tools to work (otherwise they return No active scene).
Tools (32)
Category | Tools |
ping |
|
scene |
|
node |
|
component |
|
asset |
|
prefab |
|
referenceImage |
|
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).capture_node: render a node/Canvas to a PNG on disk so the agent can see and self-correct.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 now preserves node size.
MCP tool name = <category>_<method> (e.g. node_create_node,
referenceImage_add_reference_image).
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 (2.x specifics)
capture_nodeframing (edit-mode) — in the editor (not Play), only a screen-aligned camera renders to an off-screen texture; a custom orthographic projection comes back blank. Socapture_noderenders through the scene's game camera at the scene's design resolution. It captures correctly when the UI is authored at that design resolution; a node much larger than the design resolution is framed to the design-res region (not the whole node). Tip: set the scene's design resolution to your screen size (e.g. 1080×2400) for full-screen captures.One render component per node (2.x) —
cc.Sprite,cc.Graphics,cc.Label,cc.RichTextall derive fromcc.RenderComponentand are mutually exclusive on a node. So a node can't have bothdraw_rounded_rect(Graphics) andapply_gradient/spriteFrame(Sprite). This is an engine rule, not a tool bug —add_componentreports the exact conflict, andapply_gradientauto-applies to a child node when the target already has a render component.Reference image is simulated — Cocos 2.x has no native reference-image gizmo. 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 may not refresh instantly after mutations made through the cc runtime — the live scene/canvas does update; reselect a node or reload the scene to refresh the panels. Not a tool failure.
No main-process hot-reload in 2.4.x: editing
main.js/core//tools//scene/during development requires a full editor restart (Developer → Reload 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). Passing a texture uuid is handled as a best-effort wrap but does not persist on save.Verified editor IPC (2.4.11): save
scene:stash-and-save, openscene:open-by-uuid, asset query/importasset-db:query-uuid-by-url/asset-db:import-assets, prefab createscene:create-prefab(url, serialized-content) via the_Scene.PrefabUtilsrecipe.
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.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
Design canvas for agents: create, edit, render and export Figma-shaped designs over MCP.
Control Unreal Engine to browse assets, import content, and manage levels and sequences. Automate…
Remote MCP server for AI.TV creators — delegate account operations to your AI agent over MCP.
Build editable 3D scenes, direct characters and cameras, and export AI video references with MCP.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to control Cocos Creator game development directly within the engine, providing tools for node manipulation, asset management, scene operations, and AI-powered image generation.-
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to directly control the Cocos Creator 3.8.x editor via MCP protocol, providing over 130 tools for scene, node, component, asset, and project operations.45-
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to directly control the Cocos Creator game editor via MCP protocol, supporting scene management, node manipulation, component attachment, and asset management.3-
- FlicenseNot 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.1-