cocos_add_component
Attach components to Cocos Creator nodes by specifying type names and properties, enabling game development automation without manual coding.
Instructions
Attach any cc component by its full type name (e.g. 'cc.RigidBody2D').
props values are auto-wrapped: list[3]->Vec3, int->id ref, etc.
For resource refs pass {"uuid": ""}.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"scene_path": "<scene_path>",
"node_id": "<node_id>",
"type_name": "<type_name>"
},
"name": "cocos_add_component"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scene_path | Yes | ||
| node_id | Yes | ||
| type_name | Yes | ||
| props | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |