flockbay 0.10.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +56 -0
  2. package/bin/flockbay-mcp.mjs +56 -0
  3. package/bin/flockbay.mjs +78 -0
  4. package/dist/codex/flockbayMcpStdioBridge.cjs +383 -0
  5. package/dist/codex/flockbayMcpStdioBridge.d.cts +2 -0
  6. package/dist/codex/flockbayMcpStdioBridge.d.mts +2 -0
  7. package/dist/codex/flockbayMcpStdioBridge.mjs +381 -0
  8. package/dist/flockbayScreenshotGate-DJX3Is5d.mjs +136 -0
  9. package/dist/flockbayScreenshotGate-DkxU24cR.cjs +138 -0
  10. package/dist/index--o4BPz5o.cjs +10311 -0
  11. package/dist/index-CUp3juDS.mjs +10268 -0
  12. package/dist/index.cjs +43 -0
  13. package/dist/index.d.cts +1 -0
  14. package/dist/index.d.mts +1 -0
  15. package/dist/index.mjs +40 -0
  16. package/dist/lib.cjs +33 -0
  17. package/dist/lib.d.cts +957 -0
  18. package/dist/lib.d.mts +957 -0
  19. package/dist/lib.mjs +23 -0
  20. package/dist/runCodex-D3eT-TvB.cjs +3449 -0
  21. package/dist/runCodex-o6PCbHQ7.mjs +3446 -0
  22. package/dist/runGemini-Bt0oEj_g.mjs +3183 -0
  23. package/dist/runGemini-CBxZp6I7.cjs +3185 -0
  24. package/dist/types-C-jnUdn_.cjs +4498 -0
  25. package/dist/types-DGd6ea2Z.mjs +4450 -0
  26. package/kits/kit.open_world/kit.json +59 -0
  27. package/package.json +130 -0
  28. package/scripts/claude_local_launcher.cjs +73 -0
  29. package/scripts/claude_remote_launcher.cjs +16 -0
  30. package/scripts/claude_version_utils.cjs +391 -0
  31. package/scripts/ripgrep_launcher.cjs +33 -0
  32. package/scripts/session_hook_forwarder.cjs +49 -0
  33. package/scripts/test-codex-abort-history.mjs +77 -0
  34. package/scripts/unpack-tools.cjs +222 -0
  35. package/tools/licenses/difftastic-LICENSE +21 -0
  36. package/tools/licenses/ripgrep-LICENSE +3 -0
  37. package/tools/unreal-mcp/UPSTREAM_VERSION.md +8 -0
  38. package/tools/unreal-mcp/upstream/Docs/README.md +8 -0
  39. package/tools/unreal-mcp/upstream/Docs/Tools/README.md +7 -0
  40. package/tools/unreal-mcp/upstream/Docs/Tools/actor_tools.md +184 -0
  41. package/tools/unreal-mcp/upstream/Docs/Tools/blueprint_tools.md +268 -0
  42. package/tools/unreal-mcp/upstream/Docs/Tools/editor_tools.md +104 -0
  43. package/tools/unreal-mcp/upstream/Docs/Tools/node_tools.md +274 -0
  44. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Config/FilterPlugin.ini +8 -0
  45. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/Private/Commands/UnrealMCPBlueprintCommands.cpp +1160 -0
  46. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/Private/Commands/UnrealMCPBlueprintNodeCommands.cpp +924 -0
  47. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/Private/Commands/UnrealMCPCommonUtils.cpp +709 -0
  48. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/Private/Commands/UnrealMCPEditorCommands.cpp +896 -0
  49. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/Private/Commands/UnrealMCPProjectCommands.cpp +72 -0
  50. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/Private/Commands/UnrealMCPUMGCommands.cpp +544 -0
  51. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/Private/MCPServerRunnable.cpp +321 -0
  52. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/Private/UnrealMCPBridge.cpp +419 -0
  53. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/Private/UnrealMCPModule.cpp +21 -0
  54. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/Public/Commands/UnrealMCPBlueprintCommands.h +34 -0
  55. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/Public/Commands/UnrealMCPBlueprintNodeCommands.h +27 -0
  56. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/Public/Commands/UnrealMCPCommonUtils.h +59 -0
  57. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/Public/Commands/UnrealMCPEditorCommands.h +40 -0
  58. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/Public/Commands/UnrealMCPProjectCommands.h +20 -0
  59. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/Public/Commands/UnrealMCPUMGCommands.h +82 -0
  60. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/Public/MCPServerRunnable.h +34 -0
  61. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/Public/UnrealMCPBridge.h +64 -0
  62. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/Public/UnrealMCPModule.h +22 -0
  63. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/Source/UnrealMCP/UnrealMCP.Build.cs +78 -0
  64. package/tools/unreal-mcp/upstream/MCPGameProject/Plugins/UnrealMCP/UnrealMCP.uplugin +36 -0
  65. package/tools/unreal-mcp/upstream/Python/README.md +40 -0
  66. package/tools/unreal-mcp/upstream/Python/pyproject.toml +22 -0
  67. package/tools/unreal-mcp/upstream/Python/scripts/actors/test_cube.py +203 -0
  68. package/tools/unreal-mcp/upstream/Python/scripts/blueprints/test_create_and_spawn_blueprints_with_different_components.py +497 -0
  69. package/tools/unreal-mcp/upstream/Python/scripts/blueprints/test_create_and_spawn_cube_blueprint.py +194 -0
  70. package/tools/unreal-mcp/upstream/Python/scripts/node/test_component_reference.py +267 -0
  71. package/tools/unreal-mcp/upstream/Python/scripts/node/test_create_bird_blueprint_with_input_and_camera.py +618 -0
  72. package/tools/unreal-mcp/upstream/Python/scripts/node/test_input_mapping.py +366 -0
  73. package/tools/unreal-mcp/upstream/Python/scripts/node/test_physics_variables.py +390 -0
  74. package/tools/unreal-mcp/upstream/Python/tools/blueprint_tools.py +420 -0
  75. package/tools/unreal-mcp/upstream/Python/tools/editor_tools.py +369 -0
  76. package/tools/unreal-mcp/upstream/Python/tools/node_tools.py +430 -0
  77. package/tools/unreal-mcp/upstream/Python/tools/project_tools.py +64 -0
  78. package/tools/unreal-mcp/upstream/Python/tools/umg_tools.py +333 -0
  79. package/tools/unreal-mcp/upstream/Python/unreal_mcp_server.py +398 -0
  80. package/tools/unreal-mcp/upstream/Python/uv.lock +521 -0
@@ -0,0 +1,419 @@
1
+ #include "UnrealMCPBridge.h"
2
+ #include "MCPServerRunnable.h"
3
+ #include "Sockets.h"
4
+ #include "SocketSubsystem.h"
5
+ #include "HAL/RunnableThread.h"
6
+ #include "Interfaces/IPv4/IPv4Address.h"
7
+ #include "Interfaces/IPv4/IPv4Endpoint.h"
8
+ #include "Dom/JsonObject.h"
9
+ #include "Dom/JsonValue.h"
10
+ #include "Serialization/JsonSerializer.h"
11
+ #include "Serialization/JsonReader.h"
12
+ #include "Serialization/JsonWriter.h"
13
+ #include "Engine/StaticMeshActor.h"
14
+ #include "Engine/DirectionalLight.h"
15
+ #include "Engine/PointLight.h"
16
+ #include "Engine/SpotLight.h"
17
+ #include "Camera/CameraActor.h"
18
+ #include "EditorAssetLibrary.h"
19
+ #include "AssetRegistry/AssetRegistryModule.h"
20
+ #include "JsonObjectConverter.h"
21
+ #include "GameFramework/Actor.h"
22
+ #include "Engine/Selection.h"
23
+ #include "Kismet/GameplayStatics.h"
24
+ #include "Async/Async.h"
25
+ // Add Blueprint related includes
26
+ #include "Engine/Blueprint.h"
27
+ #include "Engine/BlueprintGeneratedClass.h"
28
+ #include "Factories/BlueprintFactory.h"
29
+ #include "EdGraphSchema_K2.h"
30
+ #include "K2Node_Event.h"
31
+ #include "K2Node_VariableGet.h"
32
+ #include "K2Node_VariableSet.h"
33
+ #include "Components/StaticMeshComponent.h"
34
+ #include "Components/BoxComponent.h"
35
+ #include "Components/SphereComponent.h"
36
+ #include "Kismet2/BlueprintEditorUtils.h"
37
+ #include "Kismet2/KismetEditorUtilities.h"
38
+ // UE5.5 correct includes
39
+ #include "Engine/SimpleConstructionScript.h"
40
+ #include "Engine/SCS_Node.h"
41
+ #include "UObject/Field.h"
42
+ #include "UObject/FieldPath.h"
43
+ // Blueprint Graph specific includes
44
+ #include "EdGraph/EdGraph.h"
45
+ #include "EdGraph/EdGraphNode.h"
46
+ #include "EdGraph/EdGraphPin.h"
47
+ #include "K2Node_CallFunction.h"
48
+ #include "K2Node_InputAction.h"
49
+ #include "K2Node_Self.h"
50
+ #include "GameFramework/InputSettings.h"
51
+ #include "EditorSubsystem.h"
52
+ #include "Subsystems/EditorActorSubsystem.h"
53
+ // Include our new command handler classes
54
+ #include "Commands/UnrealMCPEditorCommands.h"
55
+ #include "Commands/UnrealMCPBlueprintCommands.h"
56
+ #include "Commands/UnrealMCPBlueprintNodeCommands.h"
57
+ #include "Commands/UnrealMCPProjectCommands.h"
58
+ #include "Commands/UnrealMCPCommonUtils.h"
59
+ #include "Commands/UnrealMCPUMGCommands.h"
60
+ #include "Interfaces/IPluginManager.h"
61
+
62
+ // Default settings
63
+ #define MCP_SERVER_HOST "127.0.0.1"
64
+ #define MCP_SERVER_PORT 55557
65
+
66
+ UUnrealMCPBridge::UUnrealMCPBridge()
67
+ {
68
+ EditorCommands = MakeShared<FUnrealMCPEditorCommands>();
69
+ BlueprintCommands = MakeShared<FUnrealMCPBlueprintCommands>();
70
+ BlueprintNodeCommands = MakeShared<FUnrealMCPBlueprintNodeCommands>();
71
+ ProjectCommands = MakeShared<FUnrealMCPProjectCommands>();
72
+ UMGCommands = MakeShared<FUnrealMCPUMGCommands>();
73
+ }
74
+
75
+ UUnrealMCPBridge::~UUnrealMCPBridge()
76
+ {
77
+ EditorCommands.Reset();
78
+ BlueprintCommands.Reset();
79
+ BlueprintNodeCommands.Reset();
80
+ ProjectCommands.Reset();
81
+ UMGCommands.Reset();
82
+ }
83
+
84
+ // Initialize subsystem
85
+ void UUnrealMCPBridge::Initialize(FSubsystemCollectionBase& Collection)
86
+ {
87
+ UE_LOG(LogTemp, Display, TEXT("UnrealMCPBridge: Initializing"));
88
+
89
+ bIsRunning = false;
90
+ ListenerSocket = nullptr;
91
+ ConnectionSocket = nullptr;
92
+ ServerThread = nullptr;
93
+ Port = MCP_SERVER_PORT;
94
+ FIPv4Address::Parse(MCP_SERVER_HOST, ServerAddress);
95
+
96
+ // Start the server automatically
97
+ StartServer();
98
+ }
99
+
100
+ // Clean up resources when subsystem is destroyed
101
+ void UUnrealMCPBridge::Deinitialize()
102
+ {
103
+ UE_LOG(LogTemp, Display, TEXT("UnrealMCPBridge: Shutting down"));
104
+ StopServer();
105
+ }
106
+
107
+ // Start the MCP server
108
+ void UUnrealMCPBridge::StartServer()
109
+ {
110
+ if (bIsRunning)
111
+ {
112
+ UE_LOG(LogTemp, Warning, TEXT("UnrealMCPBridge: Server is already running"));
113
+ return;
114
+ }
115
+
116
+ // Create socket subsystem
117
+ ISocketSubsystem* SocketSubsystem = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM);
118
+ if (!SocketSubsystem)
119
+ {
120
+ UE_LOG(LogTemp, Error, TEXT("UnrealMCPBridge: Failed to get socket subsystem"));
121
+ return;
122
+ }
123
+
124
+ // Create listener socket
125
+ TSharedPtr<FSocket> NewListenerSocket = MakeShareable(SocketSubsystem->CreateSocket(NAME_Stream, TEXT("UnrealMCPListener"), false));
126
+ if (!NewListenerSocket.IsValid())
127
+ {
128
+ UE_LOG(LogTemp, Error, TEXT("UnrealMCPBridge: Failed to create listener socket"));
129
+ return;
130
+ }
131
+
132
+ // Allow address reuse for quick restarts
133
+ NewListenerSocket->SetReuseAddr(true);
134
+ NewListenerSocket->SetNonBlocking(true);
135
+
136
+ // Bind to address
137
+ FIPv4Endpoint Endpoint(ServerAddress, Port);
138
+ if (!NewListenerSocket->Bind(*Endpoint.ToInternetAddr()))
139
+ {
140
+ UE_LOG(LogTemp, Error, TEXT("UnrealMCPBridge: Failed to bind listener socket to %s:%d"), *ServerAddress.ToString(), Port);
141
+ return;
142
+ }
143
+
144
+ // Start listening
145
+ if (!NewListenerSocket->Listen(5))
146
+ {
147
+ UE_LOG(LogTemp, Error, TEXT("UnrealMCPBridge: Failed to start listening"));
148
+ return;
149
+ }
150
+
151
+ ListenerSocket = NewListenerSocket;
152
+ bIsRunning = true;
153
+ UE_LOG(LogTemp, Display, TEXT("UnrealMCPBridge: Server started on %s:%d"), *ServerAddress.ToString(), Port);
154
+
155
+ // Start server thread
156
+ ServerThread = FRunnableThread::Create(
157
+ new FMCPServerRunnable(this, ListenerSocket),
158
+ TEXT("UnrealMCPServerThread"),
159
+ 0, TPri_Normal
160
+ );
161
+
162
+ if (!ServerThread)
163
+ {
164
+ UE_LOG(LogTemp, Error, TEXT("UnrealMCPBridge: Failed to create server thread"));
165
+ StopServer();
166
+ return;
167
+ }
168
+ }
169
+
170
+ // Stop the MCP server
171
+ void UUnrealMCPBridge::StopServer()
172
+ {
173
+ if (!bIsRunning)
174
+ {
175
+ return;
176
+ }
177
+
178
+ bIsRunning = false;
179
+
180
+ // Clean up thread
181
+ if (ServerThread)
182
+ {
183
+ ServerThread->Kill(true);
184
+ delete ServerThread;
185
+ ServerThread = nullptr;
186
+ }
187
+
188
+ // Close sockets
189
+ if (ConnectionSocket.IsValid())
190
+ {
191
+ ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->DestroySocket(ConnectionSocket.Get());
192
+ ConnectionSocket.Reset();
193
+ }
194
+
195
+ if (ListenerSocket.IsValid())
196
+ {
197
+ ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->DestroySocket(ListenerSocket.Get());
198
+ ListenerSocket.Reset();
199
+ }
200
+
201
+ UE_LOG(LogTemp, Display, TEXT("UnrealMCPBridge: Server stopped"));
202
+ }
203
+
204
+ // Execute a command received from a client
205
+ FString UUnrealMCPBridge::ExecuteCommand(const FString& CommandType, const TSharedPtr<FJsonObject>& Params)
206
+ {
207
+ UE_LOG(LogTemp, Display, TEXT("UnrealMCPBridge: Executing command: %s"), *CommandType);
208
+
209
+ // Create a promise to wait for the result
210
+ TPromise<FString> Promise;
211
+ TFuture<FString> Future = Promise.GetFuture();
212
+
213
+ // Queue execution on Game Thread
214
+ AsyncTask(ENamedThreads::GameThread, [this, CommandType, Params, Promise = MoveTemp(Promise)]() mutable
215
+ {
216
+ TSharedPtr<FJsonObject> ResponseJson = MakeShareable(new FJsonObject);
217
+
218
+ try
219
+ {
220
+ TSharedPtr<FJsonObject> ResultJson;
221
+
222
+ if (CommandType == TEXT("ping"))
223
+ {
224
+ ResultJson = MakeShareable(new FJsonObject);
225
+ ResultJson->SetStringField(TEXT("message"), TEXT("pong"));
226
+ }
227
+ else if (CommandType == TEXT("get_plugin_info"))
228
+ {
229
+ TSharedPtr<IPlugin> Plugin = IPluginManager::Get().FindPlugin(TEXT("UnrealMCP"));
230
+ if (!Plugin.IsValid())
231
+ {
232
+ ResponseJson->SetStringField(TEXT("status"), TEXT("error"));
233
+ ResponseJson->SetStringField(TEXT("error"), TEXT("Plugin not found: UnrealMCP"));
234
+
235
+ FString ResultString;
236
+ TSharedRef<TJsonWriter<>> Writer = TJsonWriterFactory<>::Create(&ResultString);
237
+ FJsonSerializer::Serialize(ResponseJson.ToSharedRef(), Writer);
238
+ Promise.SetValue(ResultString);
239
+ return;
240
+ }
241
+
242
+ const FPluginDescriptor& Descriptor = Plugin->GetDescriptor();
243
+
244
+ ResultJson = MakeShareable(new FJsonObject);
245
+ ResultJson->SetStringField(TEXT("name"), Plugin->GetName());
246
+ ResultJson->SetStringField(TEXT("baseDir"), Plugin->GetBaseDir());
247
+ ResultJson->SetStringField(TEXT("friendlyName"), Descriptor.FriendlyName);
248
+ ResultJson->SetStringField(TEXT("createdBy"), Descriptor.CreatedBy);
249
+ ResultJson->SetStringField(TEXT("versionName"), Descriptor.VersionName);
250
+ ResultJson->SetNumberField(TEXT("version"), Descriptor.Version);
251
+ ResultJson->SetBoolField(TEXT("installed"), Descriptor.bInstalled);
252
+
253
+ // Keep this list explicit so it always matches the exact build running in the editor.
254
+ TArray<TSharedPtr<FJsonValue>> Commands;
255
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("ping"))));
256
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("get_plugin_info"))));
257
+
258
+ // Editor commands
259
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("get_actors_in_level"))));
260
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("find_actors_by_name"))));
261
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("spawn_actor"))));
262
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("create_actor"))));
263
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("delete_actor"))));
264
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("set_actor_transform"))));
265
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("get_actor_properties"))));
266
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("set_actor_property"))));
267
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("spawn_blueprint_actor"))));
268
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("focus_viewport"))));
269
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("take_screenshot"))));
270
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("get_play_in_editor_status"))));
271
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("play_in_editor"))));
272
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("play_in_editor_windowed"))));
273
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("stop_play_in_editor"))));
274
+
275
+ // Blueprint commands
276
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("create_blueprint"))));
277
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("add_component_to_blueprint"))));
278
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("set_component_property"))));
279
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("set_physics_properties"))));
280
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("compile_blueprint"))));
281
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("set_blueprint_property"))));
282
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("set_static_mesh_properties"))));
283
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("set_pawn_properties"))));
284
+
285
+ // Blueprint node commands
286
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("connect_blueprint_nodes"))));
287
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("add_blueprint_get_self_component_reference"))));
288
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("add_blueprint_self_reference"))));
289
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("find_blueprint_nodes"))));
290
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("add_blueprint_event_node"))));
291
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("add_blueprint_input_action_node"))));
292
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("add_blueprint_function_node"))));
293
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("add_blueprint_get_component_node"))));
294
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("add_blueprint_variable"))));
295
+
296
+ // Project commands
297
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("create_input_mapping"))));
298
+
299
+ // UMG commands
300
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("create_umg_widget_blueprint"))));
301
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("add_text_block_to_widget"))));
302
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("add_button_to_widget"))));
303
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("bind_widget_event"))));
304
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("set_text_block_binding"))));
305
+ Commands.Add(MakeShareable(new FJsonValueString(TEXT("add_widget_to_viewport"))));
306
+
307
+ ResultJson->SetArrayField(TEXT("commands"), Commands);
308
+ }
309
+ // Editor Commands (including actor manipulation)
310
+ else if (CommandType == TEXT("get_actors_in_level") ||
311
+ CommandType == TEXT("find_actors_by_name") ||
312
+ CommandType == TEXT("spawn_actor") ||
313
+ CommandType == TEXT("create_actor") ||
314
+ CommandType == TEXT("delete_actor") ||
315
+ CommandType == TEXT("set_actor_transform") ||
316
+ CommandType == TEXT("get_actor_properties") ||
317
+ CommandType == TEXT("set_actor_property") ||
318
+ CommandType == TEXT("spawn_blueprint_actor") ||
319
+ CommandType == TEXT("focus_viewport") ||
320
+ CommandType == TEXT("take_screenshot") ||
321
+ CommandType == TEXT("get_play_in_editor_status") ||
322
+ CommandType == TEXT("play_in_editor") ||
323
+ CommandType == TEXT("play_in_editor_windowed") ||
324
+ CommandType == TEXT("stop_play_in_editor"))
325
+ {
326
+ ResultJson = EditorCommands->HandleCommand(CommandType, Params);
327
+ }
328
+ // Blueprint Commands
329
+ else if (CommandType == TEXT("create_blueprint") ||
330
+ CommandType == TEXT("add_component_to_blueprint") ||
331
+ CommandType == TEXT("set_component_property") ||
332
+ CommandType == TEXT("set_physics_properties") ||
333
+ CommandType == TEXT("compile_blueprint") ||
334
+ CommandType == TEXT("set_blueprint_property") ||
335
+ CommandType == TEXT("set_static_mesh_properties") ||
336
+ CommandType == TEXT("set_pawn_properties"))
337
+ {
338
+ ResultJson = BlueprintCommands->HandleCommand(CommandType, Params);
339
+ }
340
+ // Blueprint Node Commands
341
+ else if (CommandType == TEXT("connect_blueprint_nodes") ||
342
+ CommandType == TEXT("add_blueprint_get_self_component_reference") ||
343
+ CommandType == TEXT("add_blueprint_self_reference") ||
344
+ CommandType == TEXT("find_blueprint_nodes") ||
345
+ CommandType == TEXT("add_blueprint_event_node") ||
346
+ CommandType == TEXT("add_blueprint_input_action_node") ||
347
+ CommandType == TEXT("add_blueprint_function_node") ||
348
+ CommandType == TEXT("add_blueprint_get_component_node") ||
349
+ CommandType == TEXT("add_blueprint_variable"))
350
+ {
351
+ ResultJson = BlueprintNodeCommands->HandleCommand(CommandType, Params);
352
+ }
353
+ // Project Commands
354
+ else if (CommandType == TEXT("create_input_mapping"))
355
+ {
356
+ ResultJson = ProjectCommands->HandleCommand(CommandType, Params);
357
+ }
358
+ // UMG Commands
359
+ else if (CommandType == TEXT("create_umg_widget_blueprint") ||
360
+ CommandType == TEXT("add_text_block_to_widget") ||
361
+ CommandType == TEXT("add_button_to_widget") ||
362
+ CommandType == TEXT("bind_widget_event") ||
363
+ CommandType == TEXT("set_text_block_binding") ||
364
+ CommandType == TEXT("add_widget_to_viewport"))
365
+ {
366
+ ResultJson = UMGCommands->HandleCommand(CommandType, Params);
367
+ }
368
+ else
369
+ {
370
+ ResponseJson->SetStringField(TEXT("status"), TEXT("error"));
371
+ ResponseJson->SetStringField(TEXT("error"), FString::Printf(TEXT("Unknown command: %s"), *CommandType));
372
+
373
+ FString ResultString;
374
+ TSharedRef<TJsonWriter<>> Writer = TJsonWriterFactory<>::Create(&ResultString);
375
+ FJsonSerializer::Serialize(ResponseJson.ToSharedRef(), Writer);
376
+ Promise.SetValue(ResultString);
377
+ return;
378
+ }
379
+
380
+ // Check if the result contains an error
381
+ bool bSuccess = true;
382
+ FString ErrorMessage;
383
+
384
+ if (ResultJson->HasField(TEXT("success")))
385
+ {
386
+ bSuccess = ResultJson->GetBoolField(TEXT("success"));
387
+ if (!bSuccess && ResultJson->HasField(TEXT("error")))
388
+ {
389
+ ErrorMessage = ResultJson->GetStringField(TEXT("error"));
390
+ }
391
+ }
392
+
393
+ if (bSuccess)
394
+ {
395
+ // Set success status and include the result
396
+ ResponseJson->SetStringField(TEXT("status"), TEXT("success"));
397
+ ResponseJson->SetObjectField(TEXT("result"), ResultJson);
398
+ }
399
+ else
400
+ {
401
+ // Set error status and include the error message
402
+ ResponseJson->SetStringField(TEXT("status"), TEXT("error"));
403
+ ResponseJson->SetStringField(TEXT("error"), ErrorMessage);
404
+ }
405
+ }
406
+ catch (const std::exception& e)
407
+ {
408
+ ResponseJson->SetStringField(TEXT("status"), TEXT("error"));
409
+ ResponseJson->SetStringField(TEXT("error"), UTF8_TO_TCHAR(e.what()));
410
+ }
411
+
412
+ FString ResultString;
413
+ TSharedRef<TJsonWriter<>> Writer = TJsonWriterFactory<>::Create(&ResultString);
414
+ FJsonSerializer::Serialize(ResponseJson.ToSharedRef(), Writer);
415
+ Promise.SetValue(ResultString);
416
+ });
417
+
418
+ return Future.Get();
419
+ }
@@ -0,0 +1,21 @@
1
+ #include "UnrealMCPModule.h"
2
+ #include "UnrealMCPBridge.h"
3
+ #include "Modules/ModuleManager.h"
4
+ #include "EditorSubsystem.h"
5
+ #include "Editor.h"
6
+
7
+ #define LOCTEXT_NAMESPACE "FUnrealMCPModule"
8
+
9
+ void FUnrealMCPModule::StartupModule()
10
+ {
11
+ UE_LOG(LogTemp, Display, TEXT("Unreal MCP Module has started"));
12
+ }
13
+
14
+ void FUnrealMCPModule::ShutdownModule()
15
+ {
16
+ UE_LOG(LogTemp, Display, TEXT("Unreal MCP Module has shut down"));
17
+ }
18
+
19
+ #undef LOCTEXT_NAMESPACE
20
+
21
+ IMPLEMENT_MODULE(FUnrealMCPModule, UnrealMCP)
@@ -0,0 +1,34 @@
1
+ #pragma once
2
+
3
+ #include "CoreMinimal.h"
4
+ #include "Json.h"
5
+
6
+ /**
7
+ * Handler class for Blueprint-related MCP commands
8
+ */
9
+ class UNREALMCP_API FUnrealMCPBlueprintCommands
10
+ {
11
+ public:
12
+ FUnrealMCPBlueprintCommands();
13
+
14
+ // Handle blueprint commands
15
+ TSharedPtr<FJsonObject> HandleCommand(const FString& CommandType, const TSharedPtr<FJsonObject>& Params);
16
+
17
+ private:
18
+ // Specific blueprint command handlers
19
+ TSharedPtr<FJsonObject> HandleCreateBlueprint(const TSharedPtr<FJsonObject>& Params);
20
+ TSharedPtr<FJsonObject> HandleAddComponentToBlueprint(const TSharedPtr<FJsonObject>& Params);
21
+ TSharedPtr<FJsonObject> HandleSetComponentProperty(const TSharedPtr<FJsonObject>& Params);
22
+ TSharedPtr<FJsonObject> HandleSetPhysicsProperties(const TSharedPtr<FJsonObject>& Params);
23
+ TSharedPtr<FJsonObject> HandleCompileBlueprint(const TSharedPtr<FJsonObject>& Params);
24
+ TSharedPtr<FJsonObject> HandleSpawnBlueprintActor(const TSharedPtr<FJsonObject>& Params);
25
+ TSharedPtr<FJsonObject> HandleSetBlueprintProperty(const TSharedPtr<FJsonObject>& Params);
26
+ TSharedPtr<FJsonObject> HandleSetStaticMeshProperties(const TSharedPtr<FJsonObject>& Params);
27
+ TSharedPtr<FJsonObject> HandleSetPawnProperties(const TSharedPtr<FJsonObject>& Params);
28
+
29
+ // Helper functions
30
+ TSharedPtr<FJsonObject> AddComponentToBlueprint(const FString& BlueprintName, const FString& ComponentType,
31
+ const FString& ComponentName, const FString& MeshType,
32
+ const TArray<float>& Location, const TArray<float>& Rotation,
33
+ const TArray<float>& Scale, const TSharedPtr<FJsonObject>& ComponentProperties);
34
+ };
@@ -0,0 +1,27 @@
1
+ #pragma once
2
+
3
+ #include "CoreMinimal.h"
4
+ #include "Json.h"
5
+
6
+ /**
7
+ * Handler class for Blueprint Node-related MCP commands
8
+ */
9
+ class UNREALMCP_API FUnrealMCPBlueprintNodeCommands
10
+ {
11
+ public:
12
+ FUnrealMCPBlueprintNodeCommands();
13
+
14
+ // Handle blueprint node commands
15
+ TSharedPtr<FJsonObject> HandleCommand(const FString& CommandType, const TSharedPtr<FJsonObject>& Params);
16
+
17
+ private:
18
+ // Specific blueprint node command handlers
19
+ TSharedPtr<FJsonObject> HandleConnectBlueprintNodes(const TSharedPtr<FJsonObject>& Params);
20
+ TSharedPtr<FJsonObject> HandleAddBlueprintGetSelfComponentReference(const TSharedPtr<FJsonObject>& Params);
21
+ TSharedPtr<FJsonObject> HandleAddBlueprintEvent(const TSharedPtr<FJsonObject>& Params);
22
+ TSharedPtr<FJsonObject> HandleAddBlueprintFunctionCall(const TSharedPtr<FJsonObject>& Params);
23
+ TSharedPtr<FJsonObject> HandleAddBlueprintVariable(const TSharedPtr<FJsonObject>& Params);
24
+ TSharedPtr<FJsonObject> HandleAddBlueprintInputActionNode(const TSharedPtr<FJsonObject>& Params);
25
+ TSharedPtr<FJsonObject> HandleAddBlueprintSelfReference(const TSharedPtr<FJsonObject>& Params);
26
+ TSharedPtr<FJsonObject> HandleFindBlueprintNodes(const TSharedPtr<FJsonObject>& Params);
27
+ };
@@ -0,0 +1,59 @@
1
+ #pragma once
2
+
3
+ #include "CoreMinimal.h"
4
+ #include "Json.h"
5
+
6
+ // Forward declarations
7
+ class AActor;
8
+ class UBlueprint;
9
+ class UEdGraph;
10
+ class UEdGraphNode;
11
+ class UEdGraphPin;
12
+ class UK2Node_Event;
13
+ class UK2Node_CallFunction;
14
+ class UK2Node_VariableGet;
15
+ class UK2Node_VariableSet;
16
+ class UK2Node_InputAction;
17
+ class UK2Node_Self;
18
+ class UFunction;
19
+
20
+ /**
21
+ * Common utilities for UnrealMCP commands
22
+ */
23
+ class UNREALMCP_API FUnrealMCPCommonUtils
24
+ {
25
+ public:
26
+ // JSON utilities
27
+ static TSharedPtr<FJsonObject> CreateErrorResponse(const FString& Message);
28
+ static TSharedPtr<FJsonObject> CreateSuccessResponse(const TSharedPtr<FJsonObject>& Data = nullptr);
29
+ static void GetIntArrayFromJson(const TSharedPtr<FJsonObject>& JsonObject, const FString& FieldName, TArray<int32>& OutArray);
30
+ static void GetFloatArrayFromJson(const TSharedPtr<FJsonObject>& JsonObject, const FString& FieldName, TArray<float>& OutArray);
31
+ static FVector2D GetVector2DFromJson(const TSharedPtr<FJsonObject>& JsonObject, const FString& FieldName);
32
+ static FVector GetVectorFromJson(const TSharedPtr<FJsonObject>& JsonObject, const FString& FieldName);
33
+ static FRotator GetRotatorFromJson(const TSharedPtr<FJsonObject>& JsonObject, const FString& FieldName);
34
+
35
+ // Actor utilities
36
+ static TSharedPtr<FJsonValue> ActorToJson(AActor* Actor);
37
+ static TSharedPtr<FJsonObject> ActorToJsonObject(AActor* Actor, bool bDetailed = false);
38
+
39
+ // Blueprint utilities
40
+ static UBlueprint* FindBlueprint(const FString& BlueprintName);
41
+ static UBlueprint* FindBlueprintByName(const FString& BlueprintName);
42
+ static UEdGraph* FindOrCreateEventGraph(UBlueprint* Blueprint);
43
+
44
+ // Blueprint node utilities
45
+ static UK2Node_Event* CreateEventNode(UEdGraph* Graph, const FString& EventName, const FVector2D& Position);
46
+ static UK2Node_CallFunction* CreateFunctionCallNode(UEdGraph* Graph, UFunction* Function, const FVector2D& Position);
47
+ static UK2Node_VariableGet* CreateVariableGetNode(UEdGraph* Graph, UBlueprint* Blueprint, const FString& VariableName, const FVector2D& Position);
48
+ static UK2Node_VariableSet* CreateVariableSetNode(UEdGraph* Graph, UBlueprint* Blueprint, const FString& VariableName, const FVector2D& Position);
49
+ static UK2Node_InputAction* CreateInputActionNode(UEdGraph* Graph, const FString& ActionName, const FVector2D& Position);
50
+ static UK2Node_Self* CreateSelfReferenceNode(UEdGraph* Graph, const FVector2D& Position);
51
+ static bool ConnectGraphNodes(UEdGraph* Graph, UEdGraphNode* SourceNode, const FString& SourcePinName,
52
+ UEdGraphNode* TargetNode, const FString& TargetPinName);
53
+ static UEdGraphPin* FindPin(UEdGraphNode* Node, const FString& PinName, EEdGraphPinDirection Direction = EGPD_MAX);
54
+ static UK2Node_Event* FindExistingEventNode(UEdGraph* Graph, const FString& EventName);
55
+
56
+ // Property utilities
57
+ static bool SetObjectProperty(UObject* Object, const FString& PropertyName,
58
+ const TSharedPtr<FJsonValue>& Value, FString& OutErrorMessage);
59
+ };
@@ -0,0 +1,40 @@
1
+ #pragma once
2
+
3
+ #include "CoreMinimal.h"
4
+ #include "Json.h"
5
+
6
+ /**
7
+ * Handler class for Editor-related MCP commands
8
+ * Handles viewport control, actor manipulation, and level management
9
+ */
10
+ class UNREALMCP_API FUnrealMCPEditorCommands
11
+ {
12
+ public:
13
+ FUnrealMCPEditorCommands();
14
+
15
+ // Handle editor commands
16
+ TSharedPtr<FJsonObject> HandleCommand(const FString& CommandType, const TSharedPtr<FJsonObject>& Params);
17
+
18
+ private:
19
+ // Actor manipulation commands
20
+ TSharedPtr<FJsonObject> HandleGetActorsInLevel(const TSharedPtr<FJsonObject>& Params);
21
+ TSharedPtr<FJsonObject> HandleFindActorsByName(const TSharedPtr<FJsonObject>& Params);
22
+ TSharedPtr<FJsonObject> HandleSpawnActor(const TSharedPtr<FJsonObject>& Params);
23
+ TSharedPtr<FJsonObject> HandleDeleteActor(const TSharedPtr<FJsonObject>& Params);
24
+ TSharedPtr<FJsonObject> HandleSetActorTransform(const TSharedPtr<FJsonObject>& Params);
25
+ TSharedPtr<FJsonObject> HandleGetActorProperties(const TSharedPtr<FJsonObject>& Params);
26
+ TSharedPtr<FJsonObject> HandleSetActorProperty(const TSharedPtr<FJsonObject>& Params);
27
+
28
+ // Blueprint actor spawning
29
+ TSharedPtr<FJsonObject> HandleSpawnBlueprintActor(const TSharedPtr<FJsonObject>& Params);
30
+
31
+ // Editor viewport commands
32
+ TSharedPtr<FJsonObject> HandleFocusViewport(const TSharedPtr<FJsonObject>& Params);
33
+ TSharedPtr<FJsonObject> HandleTakeScreenshot(const TSharedPtr<FJsonObject>& Params);
34
+
35
+ // Editor play/preview commands
36
+ TSharedPtr<FJsonObject> HandleGetPlayInEditorStatus(const TSharedPtr<FJsonObject>& Params);
37
+ TSharedPtr<FJsonObject> HandlePlayInEditor(const TSharedPtr<FJsonObject>& Params);
38
+ TSharedPtr<FJsonObject> HandlePlayInEditorWindowed(const TSharedPtr<FJsonObject>& Params);
39
+ TSharedPtr<FJsonObject> HandleStopPlayInEditor(const TSharedPtr<FJsonObject>& Params);
40
+ };
@@ -0,0 +1,20 @@
1
+ #pragma once
2
+
3
+ #include "CoreMinimal.h"
4
+ #include "Json.h"
5
+
6
+ /**
7
+ * Handler class for Project-wide MCP commands
8
+ */
9
+ class UNREALMCP_API FUnrealMCPProjectCommands
10
+ {
11
+ public:
12
+ FUnrealMCPProjectCommands();
13
+
14
+ // Handle project commands
15
+ TSharedPtr<FJsonObject> HandleCommand(const FString& CommandType, const TSharedPtr<FJsonObject>& Params);
16
+
17
+ private:
18
+ // Specific project command handlers
19
+ TSharedPtr<FJsonObject> HandleCreateInputMapping(const TSharedPtr<FJsonObject>& Params);
20
+ };