More work on MCP core infrastructure

This commit is contained in:
2026-03-14 01:52:09 -04:00
parent e33bfefec7
commit a29eba3e4d
2 changed files with 26 additions and 8 deletions

View File

@@ -39,12 +39,26 @@ void MCPFetcher::PrintDocs()
}
void MCPFetcher::SetObj(UObject* InObj) { UMCPServer::AddTouchedObject(InObj); Obj = InObj; ResultPin = nullptr; }
void MCPFetcher::SetPin(UEdGraphPin* InPin) { ResultPin = InPin; Obj = nullptr; }
void MCPFetcher::SetObj(UObject* InObj)
{
UMCPServer::AddTouchedObject(InObj);
Obj = InObj;
ResultPin = nullptr;
}
void MCPFetcher::SetPin(UEdGraphPin* InPin)
{
ResultPin = InPin;
Obj = nullptr;
}
MCPFetcher& MCPFetcher::SetError()
{
bError = true;
Obj = nullptr;
ResultPin = nullptr;
OriginalAsset = nullptr;
Editor = nullptr;
return *this;
}
@@ -60,8 +74,6 @@ MCPFetcher& MCPFetcher::TypeMismatch(const TCHAR* Walker, const TCHAR* Expected)
return *this;
}
MCPFetcher& MCPFetcher::Walk(const FString& Path)
{
if (bError) return *this;
@@ -102,6 +114,8 @@ MCPFetcher& MCPFetcher::Walk(const FString& Path)
MCPFetcher& MCPFetcher::Asset(const FString& PackagePath)
{
if (bError) return *this;
SetObj(LoadObject<UObject>(nullptr, *PackagePath));
if (!Obj)
{
@@ -118,7 +132,6 @@ MCPFetcher& MCPFetcher::Asset(const FString& PackagePath)
UMCPServer::Printf(TEXT("ERROR: Could not open editor for '%s'\n"), *PackagePath);
return SetError();
}
Editor = Sub->FindEditorForAsset(OriginalAsset, false);
if (!Editor)
{

View File

@@ -30,8 +30,8 @@ struct FWalker;
// If any step fails, the MCPFetcher will print an error
// message that can be seen by the MCP's caller. It will
// also set an error flag. Once the error flag is set, all
// further ops become no-ops. At that point, attempting a
// Cast will return nullptr.
// further ops become no-ops. After that point, fetching
// any data will return nullptr.
//
class MCPFetcher
@@ -62,7 +62,7 @@ public:
//
MCPFetcher& ToBlueprint();
MCPFetcher& ToGraph();
// Return true if there haven't been any errors.
// Note that errors always automatically generate
// output to MCPServer::Printf.
@@ -92,6 +92,11 @@ public:
// loaded, returns nullptr. Does not generate errors.
//
UObject* GetAsset() const { return OriginalAsset; }
// Get the asset from where it all began: the first
// step in the walk path, as a specified type. Errors
// if it cannot cast to the specified type.
//
template<class T> T* CastAsset()
{
if (!CheckAssetIsA(T::StaticClass())) return nullptr;