# execute_script

Execute JavaScript in scene context

Agent View of the PolicyLayer registry record for `execute_script`. HTML page: https://policylayer.com/tools/caravanglory-cocos-mcp-server/execute-script

## Facts

- Tool: `execute_script`
- Server: Cocos (`caravanglory/cocos-mcp-server`) — https://policylayer.com/tools/caravanglory-cocos-mcp-server.md
- Homepage: https://github.com/caravanglory/cocos-mcp-server
- Risk category: Execute (High risk)
- Registry record: grade F, identity unverified
- Server rate-limited: no
- Parameters: 0
- Recommended policy verdict: Rate-limited

## Example call (MCP tools/call, JSON-RPC 2.0)

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "execute_script",
    "arguments": {}
  }
}
```

## Why execute_script is rated High

This tool allows running arbitrary JavaScript code within the editor's scene context, which can access and modify the entire game project state, assets, nodes, components, and potentially invoke other editor APIs.

From the tool's own definition: "Tool name 'execute_script' and description 'Execute JavaScript in scene context' directly indicate arbitrary code execution within the Cocos Creator editor environment."

## Use case

AI agents invoke execute_script to trigger actions in Cocos. What it does depends on the arguments the agent supplies, and its effects often reach beyond the immediate call: builds kicked off, notifications sent, workflows started.

## Recommended policy (PolicyLayer)

Verdict: **Rate-limited**. Enforced by the PolicyLayer MCP gateway (https://policylayer.com/mcp-gateway) before a call reaches Cocos:

```json
{
  "version": "1",
  "default": "deny",
  "tools": {
    "execute_script": {
      "limits": [
        {
          "counter": "execute_script_rate",
          "window": "minute",
          "max": 10,
          "scope": "grant"
        }
      ]
    }
  }
}
```

## Other tools on Cocos (156)

- `batch_delete_assets` — Destructive — https://policylayer.com/tools/caravanglory-cocos-mcp-server/batch-delete-assets.md
- `clear_all_reference_images` — Destructive — https://policylayer.com/tools/caravanglory-cocos-mcp-server/clear-all-reference-images.md
- `clear_broadcast_log` — Destructive — https://policylayer.com/tools/caravanglory-cocos-mcp-server/clear-broadcast-log.md
- `clear_console` — Destructive — https://policylayer.com/tools/caravanglory-cocos-mcp-server/clear-console.md
- `delete_asset` — Destructive — https://policylayer.com/tools/caravanglory-cocos-mcp-server/delete-asset.md
- `delete_node` — Destructive — https://policylayer.com/tools/caravanglory-cocos-mcp-server/delete-node.md
- `remove_component` — Destructive — https://policylayer.com/tools/caravanglory-cocos-mcp-server/remove-component.md
- `remove_reference_image` — Destructive — https://policylayer.com/tools/caravanglory-cocos-mcp-server/remove-reference-image.md
- `revert_prefab` — Destructive — https://policylayer.com/tools/caravanglory-cocos-mcp-server/revert-prefab.md
- `align_view_with_node` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/align-view-with-node.md
- `build_project` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/build-project.md
- `change_gizmo_tool` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/change-gizmo-tool.md
- `change_view_mode_2d_3d` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/change-view-mode-2d-3d.md
- `execute_component_method` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/execute-component-method.md
- `execute_scene_script` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/execute-scene-script.md
- `focus_camera_on_nodes` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/focus-camera-on-nodes.md
- `listen_broadcast` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/listen-broadcast.md
- `open_asset_external` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/open-asset-external.md
- `open_preferences_settings` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/open-preferences-settings.md
- `refresh_assets` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/refresh-assets.md
- `refresh_reference_image` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/refresh-reference-image.md
- `reimport_asset` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/reimport-asset.md
- `run_project` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/run-project.md
- `scene_snapshot_abort` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/scene-snapshot-abort.md
- `soft_reload_scene` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/soft-reload-scene.md
- `start_preview_server` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/start-preview-server.md
- `stop_listening` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/stop-listening.md
- `stop_preview_server` — Execute — https://policylayer.com/tools/caravanglory-cocos-mcp-server/stop-preview-server.md
- `format_mcp_request` — Other — https://policylayer.com/tools/caravanglory-cocos-mcp-server/format-mcp-request.md
- `safe_string_value` — Other — https://policylayer.com/tools/caravanglory-cocos-mcp-server/safe-string-value.md
- …and 126 more: https://policylayer.com/tools/caravanglory-cocos-mcp-server.md

## For agents

This record is a snapshot. Live verdicts and the full registry:

- Check every server in your MCP config at once: `npx -y policylayer stack`
- Vet a server before you add it: install the mcp-precheck skill — `npx skills add https://policylayer.com` (skill text: https://policylayer.com/skill.md)
- Query the registry over MCP: endpoint `https://api.policylayer.com/mcp` — tools `check_mcp_server`, `check_mcp_stack`, `check_tool`, `search_registry`, `get_change_events`

---

Source: the PolicyLayer MCP registry — one continuously verified record per MCP server. Full record: https://policylayer.com/registry?q=caravanglory-cocos-mcp-server · API: https://policylayer.com/registry/api · Policy library: https://policylayer.com/policies/caravanglory-cocos-mcp-server
