2.3 KiB
2.3 KiB
UMCPHandler_RenameAsset Refactoring Notes
What Changed
- Switched to plain-text output. The handler now overrides
Handle(... FStringBuilderBase&)instead of the JSON version. The output is minimal: just the new path on success, or a clear error message on failure. - Removed UE_LOG calls. Two UE_LOG calls were removed. Errors are reported via the output device.
- Removed the empty
if (bSuccess) {}block. This was dead code. - Used
MCPUtils::SplitAssetPathinstead of hand-rolled path splitting withFindLastChar. This is more consistent and handles edge cases (like empty asset names) that the original code did not. - Added
AllContent()to the MCPAssets query so it can find assets outside/Game/if needed. - Trimmed unused includes. Removed includes for headers that were not needed (BlueprintEditorUtils, SavePackage, PackageName, AssetRegistryModule, FileHelpers, Engine/Blueprint.h).
- Improved parameter descriptions with examples to help the LLM caller understand the expected format.
What's Good
- The handler is simple and focused — it does one thing well.
- MCPAssets is used correctly:
Exact()match,ENone()+ETwo()error conditions, with errors routed directly to the output device. - The logic for "just a name with no slash means rename in place" is preserved and useful.
What Might Need More Work
- No FormatName/Identifies usage. This handler doesn't look up objects by display name — it works with exact package paths, which is the correct thing for asset rename. FormatName/Identifies are not applicable here since we're dealing with package paths, not display names of nodes/pins/graphs.
- No batch support. The handler renames one asset at a time. Batch renaming could be useful, but it's a less common operation than batch pin connections, so this may not be worth the added complexity.
- Error detail from RenameAssets is lost.
IAssetTools::RenameAssetsreturns a bool but doesn't provide a detailed reason for failure. The error message is necessarily generic. I'm not sure if there's a way to get more detail from Unreal's rename API. - No validation of NewAssetName. We don't check for illegal characters in the new name before calling RenameAssets. Unreal will reject bad names, but a more specific error message could be helpful.