Skip to main content
Glama
playcanvas

PlayCanvas Editor MCP Server

Official
by playcanvas

reparent_entity

Change the parent of an entity in PlayCanvas Editor, allowing reorganization of 3D scene hierarchies while optionally preserving its transform for accurate positioning.

Instructions

Reparent an entity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesAn entity ID.
indexNo
parentYes
preserveTransformNo

Implementation Reference

  • MCP tool registration for 'reparent_entity', defining the input schema and a handler that forwards the request to the websocket server via wss.call('entities:reparent', options). This is the primary implementation of the MCP tool.
    mcp.tool( 'reparent_entity', 'Reparent an entity', { id: EntityIdSchema, parent: EntityIdSchema, index: z.number().optional(), preserveTransform: z.boolean().optional() }, (options) => { return wss.call('entities:reparent', options); } );
  • Core handler logic for reparenting entities using the PlayCanvas Editor API (api.entities.get and entity.reparent). Called by the MCP tool handler via websocket.
    wsc.method('entities:reparent', (options) => { const entity = api.entities.get(options.id); if (!entity) { return { error: 'Entity not found' }; } const parent = api.entities.get(options.parent); if (!parent) { return { error: 'Parent entity not found' }; } entity.reparent(parent, options.index, { preserveTransform: options.preserveTransform }); log(`Reparented entity(${options.id}) to entity(${options.parent})`); return { data: entity.json() }; });
  • Zod schema definition for EntityId used in the reparent_entity tool input (for both 'id' and 'parent' fields).
    export const EntityIdSchema = z.string().uuid().describe('An entity ID.');
  • Input schema for the reparent_entity tool, specifying parameters id, parent, index, and preserveTransform.
    { id: EntityIdSchema, parent: EntityIdSchema, index: z.number().optional(), preserveTransform: z.boolean().optional() }, (options) => { return wss.call('entities:reparent', options); } );

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