Cocos4 MCP Server AI
Provides tools for creating Cocos4 projects, managing scenes, nodes, components, prefabs, assets, builds, and generating TypeScript scripts for game development.
Click on "Install 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., "@Cocos4 MCP Server AIcreate a new platformer game project"
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.
Cocos4 MCP Server AI
An AI-native scaffold and enhanced Model Context Protocol (MCP) server for building games with Cocos4 using AI coding agents such as Codex, Claude Code, and other MCP-compatible clients.
Cocos4 is a fully open-source (MIT), headless-first game engine — a rare fit for AI agents, since the entire editing pipeline can run from a CLI without a GUI. Its CLI (cocos-cli) already ships a built-in MCP server exposing ~50 low-level tools for scene, node, component, prefab, asset, and build operations. This project builds on top of that, rather than duplicating it:
Proxies all native Cocos4 MCP tools transparently, so this project stays in sync as
cocos-clievolves — no hand-maintained tool schemas to drift out of date.Adds high-level scaffolding tools that the native server doesn't provide: project bootstrapping, TypeScript component/manager code generation, and ready-to-use gameplay templates (platformer, top-down shooter, match-3, endless runner, turn-based RPG, UI app).
Ships a CLI (
cocos4-ai) to bootstrap AI-ready projects with MCP client config already wired up.
Why this exists
Cocos4 went fully open source in January 2026 (MIT license, all commercial clauses removed). Its CLI is still in early alpha, and the native MCP server is powerful but low-level — an AI agent has to know exact tool names, path conventions (Canvas/Node1/cc.Sprite vs Canvas/Node1), and multi-step sequences (create scene → open scene → create node → add component → set property → save scene) to get anything done.
This project is the missing layer between "raw engine primitives" and "an AI agent that can build a whole game from a prompt": project templates, codegen, and a single unified MCP endpoint that Codex (or any MCP client) can point at.
Related MCP server: Cocos MCP Server
Architecture
┌─────────────────────┐
│ Codex / Claude / │
│ any MCP client │
└──────────┬───────────┘
│ stdio (MCP)
┌──────────▼───────────┐
│ cocos4-ai server │ ← this project
│ ┌─────────────────┐ │
│ │ High-level tools │ │ project init, codegen, templates
│ └─────────────────┘ │
│ ┌─────────────────┐ │
│ │ Native proxy │──┼──► streamable-HTTP (MCP) ──► cocos start-mcp-server
│ └─────────────────┘ │ (50 native tools:
└───────────────────────┘ scene-*, assets-*,
builder-*, file-*,
system-*)The server uses the MCP SDK's low-level Server class (not the high-level McpServer helper) so it can merge tools/list responses from two sources — the native Cocos4 CLI MCP server and this project's own tools — and route tools/call requests to whichever one owns the tool name.
Requirements
Node.js ≥ 22
Cocos4 CLI installed and available on
PATHascocos
Installation
git clone git@github.com:usernema/cocos4-mcp-server-AI.git
cd cocos4-mcp-server-AI
npm install
npm run build
npm link # makes `cocos4-ai` available globallyUsage
1. Bootstrap a new project
cocos4-ai init my-game --type 3dThis creates the Cocos4 project via cocos create and writes an MCP client config (.mcp/config.json) so any MCP-compatible agent can connect immediately.
2. Point your AI agent at the server
For Codex, Claude Code, or any MCP client, add to its MCP config:
{
"mcpServers": {
"cocos4-ai": {
"command": "cocos4-ai",
"args": ["serve", "--project", "./my-game"]
}
}
}3. Let the agent build the game
Once connected, the agent has access to:
cocos4_verify_installation,cocos4_create_project,cocos4_connect,cocos4_run_cli_command— environment and project lifecyclecocos4_list_templates,cocos4_apply_template— bootstrap common gameplay patternscocos4_generate_component,cocos4_generate_manager— generate typed TypeScript scripts~50 native tools proxied from
cocos start-mcp-server, oncecocos4_connectis called:scene-*— create/open/save/close scenes, query and mutate the node treescene-create-node-by-type,scene-update-node,scene-delete-nodescene-add-component,scene-set-component-property,scene-query-componentcreate-prefab-from-node,apply-prefab-changes,revert-prefabassets-*— asset CRUD, metadata, import/reimportbuilder-build,builder-run,builder-make— compile and launch buildsfile-insert-text,file-replace-text,file-query-text— precise script editingsystem-query-logs— read CLI logs for debugging
The agent should always call a *-query-* tool before mutating anything, to fetch exact node paths/UUIDs rather than guessing them (the native server enforces this — see scene-query-node vs scene-query-component distinctions in each tool's description).
CLI reference
cocos4-ai check # verify cocos-cli is installed
cocos4-ai init <name> [--type 2d|3d] # bootstrap a new AI-ready project
cocos4-ai serve --project <path> # start the MCP server (stdio transport)
[--native-port <port>] # port for the native Cocos MCP server (default 9527)
[--no-auto-start] # don't auto-connect to a native server on boot
[--debug] # verbose logging to stderrAvailable templates
ID | Description |
| Side-scrolling platformer: movement, jumping, |
| Top-down shooter: WASD movement, aiming, firing |
| Grid-based match-3: swap logic, match detection |
| Auto-runner: jump physics, obstacle avoidance |
| Turn-based combat: turn order, attack resolution |
| Multi-screen UI navigation with history stack |
Development
npm run dev # tsc --watch
npm run build # compile TypeScript
npm test # run tests (vitest)Project status
This is an early-stage project built to accompany an application to OpenAI's Codex for Open Source program. Cocos4 itself is in active development (CLI at 0.0.1-alpha.x as of writing) — expect native tool names/schemas to evolve, which is exactly why this project proxies rather than duplicates them.
Contributions and issue reports welcome.
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/usernema/cocos4-mcp-server-AI'
If you have feedback or need assistance with the MCP directory API, please join our Discord server