editor_get_asset_references
Find assets that reference a specified asset in Unreal Engine to track dependencies and manage project structure.
Instructions
Get references for an asset
Example output: [{'name': '/Game/Materials/M_Character.M_Character', 'class': 'Material'}, {'name': '/Game/Blueprints/BP_Player.BP_Player', 'class': 'Blueprint'}]
Returns list of assets that reference the specified asset.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| asset_path | Yes |
Implementation Reference
- server/index.ts:210-226 (registration)Registers the MCP tool 'editor_get_asset_references' including name, description, input schema { asset_path: z.string() }, and thin wrapper handler that executes the Python command via tryRunCommand.server.tool( "editor_get_asset_references", "Get references for an asset\n\nExample output: [{'name': '/Game/Materials/M_Character.M_Character', 'class': 'Material'}, {'name': '/Game/Blueprints/BP_Player.BP_Player', 'class': 'Blueprint'}]\n\nReturns list of assets that reference the specified asset.", { asset_path: z.string() }, async ({ asset_path }) => { const result = await tryRunCommand(editorTools.UEGetAssetReferences(asset_path)) return { content: [ { type: "text", text: result, }, ], } }, )
- server/editor/tools.ts:15-16 (helper)Helper function that templates the Python script ue_get_asset_references.py with the asset_path parameter and returns the command string for execution.export const UEGetAssetReferences = (asset_path: string) => Template(read("./scripts/ue_get_asset_references.py"), { asset_path })
- The Python handler script that implements the core logic: uses Unreal AssetRegistry to find referencers of the given asset_path, extracts class and name, and outputs JSON list of referencing assets.from typing import List, Dict import unreal import json def get_asset_references(asset_path: str) -> List[Dict[str, str]]: asset_registry = unreal.AssetRegistryHelpers.get_asset_registry() asset_data = asset_registry.get_asset_by_object_path(asset_path) referencing_assets = asset_registry.get_referencers( asset_data.package_name, unreal.AssetRegistryDependencyOptions() ) asset_paths = [] for referencer in referencing_assets: assets = asset_registry.get_assets_by_package_name(referencer) for asset in assets: [asset_class, asset_name] = asset.get_full_name().split(" ", 1) asset_paths.append({"name": asset_name, "class": asset_class}) return asset_paths def main(): references = get_asset_references("${asset_path}") print(json.dumps(references)) if __name__ == "__main__": main()