cocos_add_script
Add TypeScript scripts with metadata to Cocos Creator projects, generating required files and UUIDs for scene integration.
Instructions
Write a TypeScript script + its meta into the project.
rel_path can be either:
bare name like 'GameManager' -> writes assets/scripts/GameManager.ts
full path like 'assets/scripts/sub/Foo.ts'
Returns {path, rel_path, uuid}. The uuid is the standard 36-char form; use cocos_compress_uuid to get the 23-char form needed in scene files.
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": {
"project_path": "<project_path>",
"rel_path": "<rel_path>",
"source": "<source>"
},
"name": "cocos_add_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_path | Yes | ||
| rel_path | Yes | ||
| source | Yes |