Skip to main content
Glama
playcanvas

PlayCanvas Editor MCP Server

Official
by playcanvas

add_components

Attach custom components like audio, camera, collision, or light to a specified entity in PlayCanvas Editor to enhance its functionality and behavior in real-time 3D applications.

Instructions

Add components to an entity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
componentsYesA dictionary that contains the components of the entity and their data.
idYesAn entity ID.

Implementation Reference

  • WebSocket server handler implementing the add components logic: retrieves entity, adds each component using entity.addComponent(name, data), logs, and returns updated entity JSON.
    wsc.method('entities:components:add', (id, components) => {
        const entity = api.entities.get(id);
        if (!entity) {
            return { error: 'Entity not found' };
        }
        Object.entries(components).forEach(([name, data]) => {
            entity.addComponent(name, data);
        });
        log(`Added components(${Object.keys(components).join(', ')}) to entity(${id})`);
        return { data: entity.json() };
    });
  • MCP tool registration for 'add_components', defining input schema and proxy handler to WebSocket 'entities:components:add'.
    mcp.tool(
        'add_components',
        'Add components to an entity',
        {
            id: EntityIdSchema,
            components: ComponentsSchema
        },
        ({ id, components }) => {
            return wss.call('entities:components:add', id, components);
        }
    );
  • Zod schema defining the structure of components (audiolistener, camera, etc.) that can be added to an entity.
    export const ComponentsSchema = z.object({
        audiolistener: AudioListenerSchema.optional(),
        camera: CameraSchema.optional(),
        collision: CollisionSchema.optional(),
        element: ElementSchema.optional(),
        light: LightSchema.optional(),
        render: RenderSchema.optional(),
        rigidbody: RigidBodySchema.optional(),
        screen: ScreenSchema.optional(),
        script: ScriptSchema.optional(),
        sound: SoundSchema.optional()
    }).describe('A dictionary that contains the components of the entity and their data.');
  • Zod schema for the entity ID parameter, validating as UUID string.
    export const EntityIdSchema = z.string().uuid().describe('An entity ID.');
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. 'Add components to an entity' implies a mutation operation but provides no information about permissions required, whether this overwrites existing components, what happens on failure, or what the return value might be. For a complex mutation tool with nested parameters, this is a significant gap in behavioral context.

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 a single, efficient sentence with zero wasted words. It's appropriately sized for a tool name that's already descriptive ('add_components'), though this conciseness comes at the cost of completeness. Every word earns its place in conveying the core action.

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

Completeness2/5

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

Given the complexity (2 parameters with deeply nested objects, no annotations, no output schema), the description is inadequate. It doesn't address the tool's behavior, error conditions, relationship to sibling tools, or what constitutes valid component data. For a mutation tool that can add multiple complex component types, more context is needed to help an agent use it correctly.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents both parameters (id and components) thoroughly. The description adds no parameter-specific information beyond what's in the schema. It doesn't explain the relationship between components or provide usage examples. Baseline 3 is appropriate when the schema does all the parameter documentation work.

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

Purpose3/5

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

The description 'Add components to an entity' states the basic action (add) and target (components to entity), but is vague about scope and differentiation. It doesn't specify what types of components can be added or how this differs from sibling tools like 'add_script_component_script' or 'modify_entities'. The purpose is clear at a high level but lacks specificity.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. There are multiple sibling tools that modify entities (modify_entities, add_script_component_script, remove_components), but the description doesn't indicate when this specific 'add_components' operation is appropriate versus those other tools. No prerequisites, constraints, or alternatives are mentioned.

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

Related 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