Skip to main content
Glama
playcanvas

PlayCanvas Editor MCP Server

Official
by playcanvas

script_parse

Parse scripts after modification to ensure compatibility and functionality in real-time 3D web applications within the PlayCanvas Editor.

Instructions

Parse the script after modification

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
assetIdYes

Implementation Reference

  • Handler for 'assets:script:parse' websocket method: retrieves script asset, parses it using PlayCanvas editor API, returns parsed data or error.
    wsc.method('assets:script:parse', async (id) => {
        const asset = api.assets.get(id);
        if (!asset) {
            return { error: 'Asset not found' };
        }
        // FIXME: This is a hacky way to get the parsed script data. Expose a proper API for this.
        const [error, data] = await new Promise((resolve) => {
            window.editor.call('scripts:parse', asset.observer, (...data) => resolve(data));
        });
        if (error) {
            return { error };
        }
        if (Object.keys(data.scripts).length === 0) {
            return { error: 'Failed to parse script' };
        }
        log(`Parsed asset(${id}) script`);
        return { data };
    });
  • MCP tool registration for 'script_parse': defines schema (assetId: number), description, and handler that delegates to websocket call 'assets:script:parse'.
    mcp.tool(
        'script_parse',
        'Parse the script after modification',
        {
            assetId: z.number()
        },
        ({ assetId }) => {
            return wss.call('assets:script:parse', assetId);
        }
    );
  • Input schema for script_parse tool using Zod: assetId as number.
        assetId: z.number()
    },

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