Skip to content

UE 5.7.3 - Crash inspecting material function + potential fix #225

@chrispository

Description

@chrispository

What happened?

Asked Claude Code to use the Unreal MCP to inspect a material function.

What did you expect to happen?

I expected to hear about the material function.

Unreal Engine Version

UE 5.7

MCP Client

Other

Environment Information

  • OS: Windows 11
  • Node.js Version: 22.12.0
  • MCP Server Version: 0.5.18

Steps to Reproduce

  1. Open any UE project with the McpAutomationBridge plugin
  2. Use the MCP inspect tool with inspect_object or get_material_details on a MaterialFunction asset path
  3. Editor crashes immediately

Relevant Logs

Additional Context

Claude figured out the fix though. I would assume this is related to the 2 other "Crash when inspecting ___" issues on GitHub. Here's the copy paste from the terminal. I'm not comfortable submitting a PR as I have zero clue what else it could affect. Everything is working perfectly for me now though, now that Claude has applied the below fix:

● The search found one more unsafe cast. I'll cover both things:


GitHub Issue: Crash in HandleInspectAction when inspecting non-Actor UObjects

Bug Description:

Calling inspect_object (or get_material_details, etc.) on a non-AActor asset (e.g., a UMaterialFunction, UDataTable,
UMaterialParameterCollection) crashes the editor with an assertion failure:

Assertion failed: Ret->IsA(T::StaticClass())
[File:...\UObject\Class.h] [Line: 4481]

Root Cause:

In McpAutomationBridge_EnvironmentHandlers.cpp at line 1340, the inspect handler retrieves tags like this:

for (const FName &Tag : TargetObject->GetClass()->GetDefaultObject()->Tags) {

This code runs on any UObject that was successfully resolved — not just actors. GetDefaultObject() performs a checked cast to AActor, which asserts/crashes when the object's class doesn't derive from AActor.

Additionally, even for actors, this was reading tags from the Class Default Object rather than the actual actor instance, so it would have returned incorrect results.

Fix:

// Before (crashes on non-AActor objects, also reads wrong tags):
TArray<TSharedPtr> TagsArray;
for (const FName &Tag : TargetObject->GetClass()->GetDefaultObject()->Tags) {
TagsArray.Add(MakeShared(Tag.ToString()));
}
Resp->SetArrayField(TEXT("tags"), TagsArray);

// After (safe, reads actual instance tags):
TArray<TSharedPtr> TagsArray;
if (AActor *TagActor = Cast(TargetObject)) {
for (const FName &Tag : TagActor->Tags) {
TagsArray.Add(MakeShared(Tag.ToString()));
}
}
Resp->SetArrayField(TEXT("tags"), TagsArray);

Reproduction steps:

  1. Open any UE project with the McpAutomationBridge plugin
  2. Use the MCP inspect tool with inspect_object or get_material_details on a MaterialFunction asset path
  3. Editor crashes immediately

Additional unsafe cast found

In McpAutomationBridgeHelpers.h lines 2207 and 2213, FindScsNodeByName() uses reinterpret_cast<USCS_Node*>(ElemObj) on
a generic UObject* without any type verification. This should use Cast<USCS_Node>(ElemObj) instead. It's less likely to trigger in practice (the SCS AllNodes array should only contain USCS_Node objects), but it's still unsafe by Unreal conventions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingduplicateThis issue or pull request already exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions