Skip to main content
Glama

cocos_instantiate_prefab

Clone a prefab file into a Cocos Creator scene as a child node, allowing customization of position, scale, and name for the new instance.

Instructions

Drop a .prefab file into the scene as a child node — returns root id.

Reads the .prefab JSON, deep-copies its node tree (root + children + components), shifts every internal id reference, gives every cloned object a fresh _id, refreshes each cc.PrefabInfo.fileId so multiple instances of the same prefab don't alias, and parents the new root under parent_id.

Treats the prefab as unlinked (a one-shot copy). If you later edit the .prefab, instances already dropped into the scene will NOT update — re-instantiate to pick up the changes.

Pass any of name / pos_x / pos_y / pos_z / scale to override the root's defaults (otherwise the prefab's own values stay).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scene_pathYes
parent_idYes
prefab_pathYes
nameNo
pos_xNo
pos_yNo
pos_zNo
scaleNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It does an excellent job describing the internal process (reads JSON, deep-copies node tree, shifts IDs, refreshes fileId, parents under parent_id), the unlinked nature of the instantiation, and the update behavior. However, it doesn't mention error conditions, performance implications, or authentication requirements, keeping it from a perfect score.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly structured and front-loaded: the first sentence states the core purpose and return value, followed by implementation details, behavioral constraints, and parameter guidance. Every sentence earns its place with no wasted words, and technical details are presented in a logical flow.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (8 parameters, mutation operation, no annotations) and the presence of an output schema (which handles return values), the description is remarkably complete. It covers purpose, behavior, parameter semantics, usage constraints, and implementation details. The only minor gap is lack of error handling information, but the output schema likely covers return format.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description must fully compensate, which it does excellently. It explains the purpose of the 3 required parameters (scene_path, parent_id, prefab_path are implied through context), and explicitly documents the 5 optional parameters (name, pos_x, pos_y, pos_z, scale) with clear semantics about overriding root defaults. The description adds significant value beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Drop a .prefab file into the scene as a child node') and resource (.prefab file), distinguishing it from sibling tools like 'cocos_create_prefab' (which creates prefabs) or 'cocos_create_node' (which creates individual nodes). The opening sentence provides immediate clarity about the tool's core function.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states when to use this tool ('Treats the prefab as **unlinked** (a one-shot copy)') and when not to use it ('If you later edit the .prefab, instances already dropped into the scene will NOT update — re-instantiate to pick up the changes'). It also provides clear alternatives by implication (re-instantiate for updates rather than expecting automatic updates).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

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/chenShengBiao/cocos-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server