Skip to main content
Glama
playcanvas

PlayCanvas Editor MCP Server

Official
by playcanvas

attach_script

Idempotent

Attach a script to an entity by creating the script component if missing and adding the named script in one step. Returns updated entity summary.

Instructions

Attach a script to an entity in one step: creates the script component if missing, then adds the named script. This consolidates the common "add script component" + "add script" flow. Returns the updated entity summary. Note: the script must already exist as a parsed script asset (create one with create_assets type="script", set its code with set_script_text, then script_parse). When NOT to use: to write the script's source code (use set_script_text) or to set script attribute values (use modify_entities on components.script.scripts..attributes).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesEntity ID
indexNoExecution order index
attributesNoInitial script attribute values
scriptNameYesRegistered script name to attach
Behavior4/5

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

Beyond annotations (readOnly=false, destructive=false, idempotent=true), the description explains the side-effect behavior: creates the script component when missing, adds the script, and returns an updated entity summary. It also usefully clarifies what this tool does not do, reducing ambiguity about its operational scope.

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?

Three sentences with no filler. The core behavior is front-loaded first, prerequisites second, and exclusions third. Every sentence adds distinct value, and the structure makes the tool easy to scan.

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?

For a mutation tool with no output schema, the description covers the return value (updated entity summary), prerequisite conditions, and explicit alternatives/exclusions. Combined with the provided annotations and schema, an agent has enough information to select and invoke the tool correctly.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3. The description adds semantic context for scriptName by explaining the prerequisite that it must be a registered parsed script asset, not just any name. It also clarifies that attributes are initial values and execution order is controlled by index, though implicitly.

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 states a specific action ('Attach a script to an entity in one step') and precisely explains the behavior: it creates the script component if missing, then adds the named script. It also distinguishes this tool from set_script_text and modify_entities immediately, making its purpose clear relative to siblings.

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 provides explicit 'When NOT to use' guidance, naming set_script_text for source code editing and modify_entities for setting attribute values. It also states the prerequisite that the script must already exist as a parsed asset, giving the agent concrete conditions for when this tool is appropriate.

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/playcanvas/editor-mcp-server'

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