unreal-engine-mcp-server 0.4.6 → 0.5.0
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.
- package/.env.example +26 -0
- package/.env.production +38 -7
- package/.eslintrc.json +0 -54
- package/.eslintrc.override.json +8 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +94 -0
- package/.github/ISSUE_TEMPLATE/config.yml +8 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +56 -0
- package/.github/copilot-instructions.md +478 -45
- package/.github/dependabot.yml +19 -0
- package/.github/labeler.yml +24 -0
- package/.github/labels.yml +70 -0
- package/.github/pull_request_template.md +42 -0
- package/.github/release-drafter.yml +148 -0
- package/.github/workflows/auto-merge.yml +38 -0
- package/.github/workflows/ci.yml +38 -0
- package/.github/workflows/dependency-review.yml +17 -0
- package/.github/workflows/gemini-issue-triage.yml +172 -0
- package/.github/workflows/greetings.yml +23 -0
- package/.github/workflows/labeler.yml +16 -0
- package/.github/workflows/links.yml +80 -0
- package/.github/workflows/pr-size-labeler.yml +137 -0
- package/.github/workflows/publish-mcp.yml +12 -7
- package/.github/workflows/release-drafter.yml +23 -0
- package/.github/workflows/release.yml +112 -0
- package/.github/workflows/semantic-pull-request.yml +35 -0
- package/.github/workflows/smoke-test.yml +36 -0
- package/.github/workflows/stale.yml +28 -0
- package/CHANGELOG.md +269 -22
- package/CONTRIBUTING.md +140 -0
- package/README.md +166 -72
- package/claude_desktop_config_example.json +7 -6
- package/dist/automation/bridge.d.ts +50 -0
- package/dist/automation/bridge.js +452 -0
- package/dist/automation/connection-manager.d.ts +23 -0
- package/dist/automation/connection-manager.js +107 -0
- package/dist/automation/handshake.d.ts +11 -0
- package/dist/automation/handshake.js +89 -0
- package/dist/automation/index.d.ts +3 -0
- package/dist/automation/index.js +3 -0
- package/dist/automation/message-handler.d.ts +12 -0
- package/dist/automation/message-handler.js +149 -0
- package/dist/automation/request-tracker.d.ts +25 -0
- package/dist/automation/request-tracker.js +98 -0
- package/dist/automation/types.d.ts +130 -0
- package/dist/automation/types.js +2 -0
- package/dist/cli.js +32 -5
- package/dist/config.d.ts +27 -0
- package/dist/config.js +60 -0
- package/dist/constants.d.ts +12 -0
- package/dist/constants.js +12 -0
- package/dist/graphql/resolvers.d.ts +268 -0
- package/dist/graphql/resolvers.js +743 -0
- package/dist/graphql/schema.d.ts +5 -0
- package/dist/graphql/schema.js +437 -0
- package/dist/graphql/server.d.ts +26 -0
- package/dist/graphql/server.js +115 -0
- package/dist/graphql/types.d.ts +7 -0
- package/dist/graphql/types.js +2 -0
- package/dist/handlers/resource-handlers.d.ts +20 -0
- package/dist/handlers/resource-handlers.js +180 -0
- package/dist/index.d.ts +31 -18
- package/dist/index.js +119 -604
- package/dist/prompts/index.js +4 -4
- package/dist/resources/actors.d.ts +17 -12
- package/dist/resources/actors.js +56 -76
- package/dist/resources/assets.d.ts +6 -14
- package/dist/resources/assets.js +115 -147
- package/dist/resources/levels.d.ts +13 -13
- package/dist/resources/levels.js +25 -34
- package/dist/server/resource-registry.d.ts +20 -0
- package/dist/server/resource-registry.js +37 -0
- package/dist/server/tool-registry.d.ts +23 -0
- package/dist/server/tool-registry.js +322 -0
- package/dist/server-setup.d.ts +21 -0
- package/dist/server-setup.js +111 -0
- package/dist/services/health-monitor.d.ts +34 -0
- package/dist/services/health-monitor.js +105 -0
- package/dist/services/metrics-server.d.ts +11 -0
- package/dist/services/metrics-server.js +105 -0
- package/dist/tools/actors.d.ts +147 -9
- package/dist/tools/actors.js +350 -311
- package/dist/tools/animation.d.ts +135 -4
- package/dist/tools/animation.js +510 -411
- package/dist/tools/assets.d.ts +117 -19
- package/dist/tools/assets.js +259 -284
- package/dist/tools/audio.d.ts +102 -42
- package/dist/tools/audio.js +272 -685
- package/dist/tools/base-tool.d.ts +17 -0
- package/dist/tools/base-tool.js +46 -0
- package/dist/tools/behavior-tree.d.ts +94 -0
- package/dist/tools/behavior-tree.js +39 -0
- package/dist/tools/blueprint/helpers.d.ts +29 -0
- package/dist/tools/blueprint/helpers.js +182 -0
- package/dist/tools/blueprint.d.ts +228 -118
- package/dist/tools/blueprint.js +685 -832
- package/dist/tools/consolidated-tool-definitions.d.ts +5475 -1627
- package/dist/tools/consolidated-tool-definitions.js +829 -482
- package/dist/tools/consolidated-tool-handlers.d.ts +2 -1
- package/dist/tools/consolidated-tool-handlers.js +211 -1009
- package/dist/tools/debug.d.ts +143 -85
- package/dist/tools/debug.js +234 -180
- package/dist/tools/dynamic-handler-registry.d.ts +11 -0
- package/dist/tools/dynamic-handler-registry.js +101 -0
- package/dist/tools/editor.d.ts +139 -18
- package/dist/tools/editor.js +239 -244
- package/dist/tools/engine.d.ts +10 -4
- package/dist/tools/engine.js +13 -5
- package/dist/tools/environment.d.ts +36 -0
- package/dist/tools/environment.js +267 -0
- package/dist/tools/foliage.d.ts +105 -14
- package/dist/tools/foliage.js +219 -331
- package/dist/tools/handlers/actor-handlers.d.ts +3 -0
- package/dist/tools/handlers/actor-handlers.js +232 -0
- package/dist/tools/handlers/animation-handlers.d.ts +3 -0
- package/dist/tools/handlers/animation-handlers.js +185 -0
- package/dist/tools/handlers/argument-helper.d.ts +16 -0
- package/dist/tools/handlers/argument-helper.js +80 -0
- package/dist/tools/handlers/asset-handlers.d.ts +3 -0
- package/dist/tools/handlers/asset-handlers.js +496 -0
- package/dist/tools/handlers/audio-handlers.d.ts +3 -0
- package/dist/tools/handlers/audio-handlers.js +166 -0
- package/dist/tools/handlers/blueprint-handlers.d.ts +4 -0
- package/dist/tools/handlers/blueprint-handlers.js +358 -0
- package/dist/tools/handlers/common-handlers.d.ts +14 -0
- package/dist/tools/handlers/common-handlers.js +56 -0
- package/dist/tools/handlers/editor-handlers.d.ts +3 -0
- package/dist/tools/handlers/editor-handlers.js +119 -0
- package/dist/tools/handlers/effect-handlers.d.ts +3 -0
- package/dist/tools/handlers/effect-handlers.js +171 -0
- package/dist/tools/handlers/environment-handlers.d.ts +3 -0
- package/dist/tools/handlers/environment-handlers.js +170 -0
- package/dist/tools/handlers/graph-handlers.d.ts +3 -0
- package/dist/tools/handlers/graph-handlers.js +90 -0
- package/dist/tools/handlers/input-handlers.d.ts +3 -0
- package/dist/tools/handlers/input-handlers.js +21 -0
- package/dist/tools/handlers/inspect-handlers.d.ts +3 -0
- package/dist/tools/handlers/inspect-handlers.js +383 -0
- package/dist/tools/handlers/level-handlers.d.ts +3 -0
- package/dist/tools/handlers/level-handlers.js +237 -0
- package/dist/tools/handlers/lighting-handlers.d.ts +3 -0
- package/dist/tools/handlers/lighting-handlers.js +144 -0
- package/dist/tools/handlers/performance-handlers.d.ts +3 -0
- package/dist/tools/handlers/performance-handlers.js +130 -0
- package/dist/tools/handlers/pipeline-handlers.d.ts +3 -0
- package/dist/tools/handlers/pipeline-handlers.js +110 -0
- package/dist/tools/handlers/sequence-handlers.d.ts +3 -0
- package/dist/tools/handlers/sequence-handlers.js +376 -0
- package/dist/tools/handlers/system-handlers.d.ts +4 -0
- package/dist/tools/handlers/system-handlers.js +506 -0
- package/dist/tools/input.d.ts +19 -0
- package/dist/tools/input.js +89 -0
- package/dist/tools/introspection.d.ts +103 -40
- package/dist/tools/introspection.js +425 -568
- package/dist/tools/landscape.d.ts +97 -36
- package/dist/tools/landscape.js +280 -409
- package/dist/tools/level.d.ts +130 -10
- package/dist/tools/level.js +639 -675
- package/dist/tools/lighting.d.ts +77 -38
- package/dist/tools/lighting.js +441 -943
- package/dist/tools/logs.d.ts +45 -0
- package/dist/tools/logs.js +210 -0
- package/dist/tools/materials.d.ts +91 -24
- package/dist/tools/materials.js +190 -118
- package/dist/tools/niagara.d.ts +149 -39
- package/dist/tools/niagara.js +232 -182
- package/dist/tools/performance.d.ts +27 -12
- package/dist/tools/performance.js +204 -122
- package/dist/tools/physics.d.ts +32 -77
- package/dist/tools/physics.js +171 -582
- package/dist/tools/property-dictionary.d.ts +13 -0
- package/dist/tools/property-dictionary.js +82 -0
- package/dist/tools/sequence.d.ts +73 -48
- package/dist/tools/sequence.js +196 -748
- package/dist/tools/tool-definition-utils.d.ts +59 -0
- package/dist/tools/tool-definition-utils.js +35 -0
- package/dist/tools/ui.d.ts +66 -34
- package/dist/tools/ui.js +134 -214
- package/dist/types/env.d.ts +0 -3
- package/dist/types/env.js +0 -7
- package/dist/types/tool-interfaces.d.ts +898 -0
- package/dist/types/tool-interfaces.js +2 -0
- package/dist/types/tool-types.d.ts +195 -11
- package/dist/types/tool-types.js +0 -4
- package/dist/unreal-bridge.d.ts +24 -131
- package/dist/unreal-bridge.js +364 -1506
- package/dist/utils/command-validator.d.ts +9 -0
- package/dist/utils/command-validator.js +67 -0
- package/dist/utils/elicitation.d.ts +1 -1
- package/dist/utils/elicitation.js +12 -15
- package/dist/utils/error-handler.d.ts +2 -51
- package/dist/utils/error-handler.js +11 -87
- package/dist/utils/ini-reader.d.ts +3 -0
- package/dist/utils/ini-reader.js +69 -0
- package/dist/utils/logger.js +9 -6
- package/dist/utils/normalize.d.ts +3 -0
- package/dist/utils/normalize.js +56 -0
- package/dist/utils/response-factory.d.ts +7 -0
- package/dist/utils/response-factory.js +33 -0
- package/dist/utils/response-validator.d.ts +3 -24
- package/dist/utils/response-validator.js +130 -81
- package/dist/utils/result-helpers.d.ts +4 -5
- package/dist/utils/result-helpers.js +15 -16
- package/dist/utils/safe-json.js +5 -11
- package/dist/utils/unreal-command-queue.d.ts +24 -0
- package/dist/utils/unreal-command-queue.js +120 -0
- package/dist/utils/validation.d.ts +0 -40
- package/dist/utils/validation.js +1 -78
- package/dist/wasm/index.d.ts +70 -0
- package/dist/wasm/index.js +535 -0
- package/docs/GraphQL-API.md +888 -0
- package/docs/Migration-Guide-v0.5.0.md +692 -0
- package/docs/Roadmap.md +53 -0
- package/docs/WebAssembly-Integration.md +628 -0
- package/docs/editor-plugin-extension.md +370 -0
- package/docs/handler-mapping.md +242 -0
- package/docs/native-automation-progress.md +128 -0
- package/docs/testing-guide.md +423 -0
- package/mcp-config-example.json +6 -6
- package/package.json +60 -27
- package/plugins/McpAutomationBridge/Config/FilterPlugin.ini +8 -0
- package/plugins/McpAutomationBridge/McpAutomationBridge.uplugin +64 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/McpAutomationBridge.Build.cs +189 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeGlobals.cpp +22 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeGlobals.h +30 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeHelpers.h +1983 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeModule.cpp +72 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeSettings.cpp +46 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeSubsystem.cpp +581 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AnimationHandlers.cpp +2394 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AssetQueryHandlers.cpp +300 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AssetWorkflowHandlers.cpp +2807 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AudioHandlers.cpp +1087 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BehaviorTreeHandlers.cpp +488 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintCreationHandlers.cpp +643 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintCreationHandlers.h +31 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintGraphHandlers.cpp +1184 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintHandlers.cpp +5652 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintHandlers_List.cpp +152 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_ControlHandlers.cpp +2614 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_DebugHandlers.cpp +42 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_EditorFunctionHandlers.cpp +1237 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_EffectHandlers.cpp +1701 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_EnvironmentHandlers.cpp +2145 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_FoliageHandlers.cpp +954 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_InputHandlers.cpp +209 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_InsightsHandlers.cpp +41 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LandscapeHandlers.cpp +1164 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LevelHandlers.cpp +762 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LightingHandlers.cpp +634 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LogHandlers.cpp +136 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_MaterialGraphHandlers.cpp +494 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_NiagaraGraphHandlers.cpp +278 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_NiagaraHandlers.cpp +625 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_PerformanceHandlers.cpp +401 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_PipelineHandlers.cpp +67 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_ProcessRequest.cpp +735 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_PropertyHandlers.cpp +2634 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_RenderHandlers.cpp +189 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SCSHandlers.cpp +917 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SCSHandlers.h +39 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SequenceHandlers.cpp +2670 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SequencerHandlers.cpp +519 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_TestHandlers.cpp +38 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_UiHandlers.cpp +668 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_WorldPartitionHandlers.cpp +346 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpBridgeWebSocket.cpp +1330 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpBridgeWebSocket.h +149 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpConnectionManager.cpp +783 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Public/McpAutomationBridgeSettings.h +115 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Public/McpAutomationBridgeSubsystem.h +796 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Public/McpConnectionManager.h +117 -0
- package/scripts/check-unreal-connection.mjs +19 -0
- package/scripts/clean-tmp.js +23 -0
- package/scripts/patch-wasm.js +26 -0
- package/scripts/run-all-tests.mjs +131 -0
- package/scripts/smoke-test.ts +94 -0
- package/scripts/sync-mcp-plugin.js +143 -0
- package/scripts/test-no-plugin-alternates.mjs +113 -0
- package/scripts/validate-server.js +46 -0
- package/scripts/verify-automation-bridge.js +200 -0
- package/server.json +57 -21
- package/src/automation/bridge.ts +558 -0
- package/src/automation/connection-manager.ts +130 -0
- package/src/automation/handshake.ts +99 -0
- package/src/automation/index.ts +2 -0
- package/src/automation/message-handler.ts +167 -0
- package/src/automation/request-tracker.ts +123 -0
- package/src/automation/types.ts +107 -0
- package/src/cli.ts +33 -6
- package/src/config.ts +73 -0
- package/src/constants.ts +12 -0
- package/src/graphql/resolvers.ts +1010 -0
- package/src/graphql/schema.ts +452 -0
- package/src/graphql/server.ts +154 -0
- package/src/graphql/types.ts +7 -0
- package/src/handlers/resource-handlers.ts +186 -0
- package/src/index.ts +152 -649
- package/src/prompts/index.ts +4 -4
- package/src/resources/actors.ts +58 -76
- package/src/resources/assets.ts +147 -134
- package/src/resources/levels.ts +28 -33
- package/src/server/resource-registry.ts +47 -0
- package/src/server/tool-registry.ts +354 -0
- package/src/server-setup.ts +148 -0
- package/src/services/health-monitor.ts +132 -0
- package/src/services/metrics-server.ts +142 -0
- package/src/tools/actors.ts +417 -322
- package/src/tools/animation.ts +671 -461
- package/src/tools/assets.ts +353 -289
- package/src/tools/audio.ts +323 -766
- package/src/tools/base-tool.ts +52 -0
- package/src/tools/behavior-tree.ts +45 -0
- package/src/tools/blueprint/helpers.ts +189 -0
- package/src/tools/blueprint.ts +787 -965
- package/src/tools/consolidated-tool-definitions.ts +993 -500
- package/src/tools/consolidated-tool-handlers.ts +272 -1122
- package/src/tools/debug.ts +292 -187
- package/src/tools/dynamic-handler-registry.ts +151 -0
- package/src/tools/editor.ts +309 -246
- package/src/tools/engine.ts +14 -3
- package/src/tools/environment.ts +287 -0
- package/src/tools/foliage.ts +314 -379
- package/src/tools/handlers/actor-handlers.ts +271 -0
- package/src/tools/handlers/animation-handlers.ts +237 -0
- package/src/tools/handlers/argument-helper.ts +142 -0
- package/src/tools/handlers/asset-handlers.ts +532 -0
- package/src/tools/handlers/audio-handlers.ts +194 -0
- package/src/tools/handlers/blueprint-handlers.ts +380 -0
- package/src/tools/handlers/common-handlers.ts +87 -0
- package/src/tools/handlers/editor-handlers.ts +123 -0
- package/src/tools/handlers/effect-handlers.ts +220 -0
- package/src/tools/handlers/environment-handlers.ts +183 -0
- package/src/tools/handlers/graph-handlers.ts +116 -0
- package/src/tools/handlers/input-handlers.ts +28 -0
- package/src/tools/handlers/inspect-handlers.ts +450 -0
- package/src/tools/handlers/level-handlers.ts +252 -0
- package/src/tools/handlers/lighting-handlers.ts +147 -0
- package/src/tools/handlers/performance-handlers.ts +132 -0
- package/src/tools/handlers/pipeline-handlers.ts +127 -0
- package/src/tools/handlers/sequence-handlers.ts +415 -0
- package/src/tools/handlers/system-handlers.ts +564 -0
- package/src/tools/input.ts +101 -0
- package/src/tools/introspection.ts +493 -584
- package/src/tools/landscape.ts +394 -489
- package/src/tools/level.ts +752 -694
- package/src/tools/lighting.ts +583 -984
- package/src/tools/logs.ts +219 -0
- package/src/tools/materials.ts +231 -121
- package/src/tools/niagara.ts +293 -168
- package/src/tools/performance.ts +320 -168
- package/src/tools/physics.ts +268 -613
- package/src/tools/property-dictionary.ts +98 -0
- package/src/tools/sequence.ts +255 -815
- package/src/tools/tool-definition-utils.ts +35 -0
- package/src/tools/ui.ts +207 -283
- package/src/types/env.ts +0 -10
- package/src/types/tool-interfaces.ts +250 -0
- package/src/types/tool-types.ts +250 -13
- package/src/unreal-bridge.ts +460 -1550
- package/src/utils/command-validator.ts +75 -0
- package/src/utils/elicitation.ts +10 -7
- package/src/utils/error-handler.ts +14 -90
- package/src/utils/ini-reader.ts +86 -0
- package/src/utils/logger.ts +8 -3
- package/src/utils/normalize.ts +60 -0
- package/src/utils/response-factory.ts +39 -0
- package/src/utils/response-validator.ts +176 -56
- package/src/utils/result-helpers.ts +21 -19
- package/src/utils/safe-json.ts +14 -11
- package/src/utils/unreal-command-queue.ts +152 -0
- package/src/utils/validation.ts +4 -1
- package/src/wasm/index.ts +838 -0
- package/test-server.mjs +100 -0
- package/tests/run-unreal-tool-tests.mjs +242 -14
- package/tests/test-animation.mjs +44 -0
- package/tests/test-asset-advanced.mjs +82 -0
- package/tests/test-asset-errors.mjs +35 -0
- package/tests/test-audio.mjs +219 -0
- package/tests/test-automation-timeouts.mjs +98 -0
- package/tests/test-behavior-tree.mjs +261 -0
- package/tests/test-blueprint-events.mjs +35 -0
- package/tests/test-blueprint-graph.mjs +79 -0
- package/tests/test-blueprint.mjs +577 -0
- package/tests/test-client-mode.mjs +86 -0
- package/tests/test-console-command.mjs +56 -0
- package/tests/test-control-actor.mjs +425 -0
- package/tests/test-control-editor.mjs +80 -0
- package/tests/test-extra-tools.mjs +38 -0
- package/tests/test-graphql.mjs +322 -0
- package/tests/test-inspect.mjs +72 -0
- package/tests/test-landscape.mjs +60 -0
- package/tests/test-manage-asset.mjs +438 -0
- package/tests/test-manage-level.mjs +70 -0
- package/tests/test-materials.mjs +356 -0
- package/tests/test-niagara.mjs +185 -0
- package/tests/test-no-inline-python.mjs +122 -0
- package/tests/test-plugin-handshake.mjs +82 -0
- package/tests/test-render.mjs +33 -0
- package/tests/test-runner.mjs +933 -0
- package/tests/test-search-assets.mjs +66 -0
- package/tests/test-sequence.mjs +68 -0
- package/tests/test-system.mjs +57 -0
- package/tests/test-wasm.mjs +193 -0
- package/tests/test-world-partition.mjs +215 -0
- package/tsconfig.json +3 -3
- package/wasm/Cargo.lock +363 -0
- package/wasm/Cargo.toml +42 -0
- package/wasm/LICENSE +21 -0
- package/wasm/README.md +253 -0
- package/wasm/src/dependency_resolver.rs +377 -0
- package/wasm/src/lib.rs +153 -0
- package/wasm/src/property_parser.rs +271 -0
- package/wasm/src/transform_math.rs +396 -0
- package/wasm/tests/integration.rs +109 -0
- package/.github/workflows/smithery-build.yml +0 -29
- package/dist/tools/build_environment_advanced.d.ts +0 -65
- package/dist/tools/build_environment_advanced.js +0 -633
- package/dist/tools/rc.d.ts +0 -110
- package/dist/tools/rc.js +0 -437
- package/dist/tools/visual.d.ts +0 -40
- package/dist/tools/visual.js +0 -282
- package/dist/utils/http.d.ts +0 -6
- package/dist/utils/http.js +0 -151
- package/dist/utils/python-output.d.ts +0 -18
- package/dist/utils/python-output.js +0 -290
- package/dist/utils/python.d.ts +0 -2
- package/dist/utils/python.js +0 -4
- package/dist/utils/stdio-redirect.d.ts +0 -2
- package/dist/utils/stdio-redirect.js +0 -20
- package/docs/unreal-tool-test-cases.md +0 -572
- package/smithery.yaml +0 -29
- package/src/tools/build_environment_advanced.ts +0 -732
- package/src/tools/rc.ts +0 -515
- package/src/tools/visual.ts +0 -281
- package/src/utils/http.ts +0 -187
- package/src/utils/python-output.ts +0 -351
- package/src/utils/python.ts +0 -3
- package/src/utils/stdio-redirect.ts +0 -18
package/src/index.ts
CHANGED
|
@@ -1,155 +1,120 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
4
|
import { Logger } from './utils/logger.js';
|
|
5
5
|
import { UnrealBridge } from './unreal-bridge.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { LevelResources } from './resources/levels.js';
|
|
9
|
-
import { ActorTools } from './tools/actors.js';
|
|
10
|
-
import { AssetTools } from './tools/assets.js';
|
|
11
|
-
import { EditorTools } from './tools/editor.js';
|
|
12
|
-
import { MaterialTools } from './tools/materials.js';
|
|
13
|
-
import { AnimationTools } from './tools/animation.js';
|
|
14
|
-
import { PhysicsTools } from './tools/physics.js';
|
|
15
|
-
import { NiagaraTools } from './tools/niagara.js';
|
|
16
|
-
import { BlueprintTools } from './tools/blueprint.js';
|
|
17
|
-
import { LevelTools } from './tools/level.js';
|
|
18
|
-
import { LightingTools } from './tools/lighting.js';
|
|
19
|
-
import { LandscapeTools } from './tools/landscape.js';
|
|
20
|
-
import { BuildEnvironmentAdvanced } from './tools/build_environment_advanced.js';
|
|
21
|
-
import { FoliageTools } from './tools/foliage.js';
|
|
22
|
-
import { DebugVisualizationTools } from './tools/debug.js';
|
|
23
|
-
import { PerformanceTools } from './tools/performance.js';
|
|
24
|
-
import { AudioTools } from './tools/audio.js';
|
|
25
|
-
import { UITools } from './tools/ui.js';
|
|
26
|
-
import { RcTools } from './tools/rc.js';
|
|
27
|
-
import { SequenceTools } from './tools/sequence.js';
|
|
28
|
-
import { IntrospectionTools } from './tools/introspection.js';
|
|
29
|
-
import { VisualTools } from './tools/visual.js';
|
|
30
|
-
import { EngineTools } from './tools/engine.js';
|
|
31
|
-
import { consolidatedToolDefinitions } from './tools/consolidated-tool-definitions.js';
|
|
32
|
-
import { handleConsolidatedToolCall } from './tools/consolidated-tool-handlers.js';
|
|
33
|
-
import { prompts } from './prompts/index.js';
|
|
34
|
-
import {
|
|
35
|
-
CallToolRequestSchema,
|
|
36
|
-
ListToolsRequestSchema,
|
|
37
|
-
ListResourcesRequestSchema,
|
|
38
|
-
ReadResourceRequestSchema,
|
|
39
|
-
ListPromptsRequestSchema,
|
|
40
|
-
GetPromptRequestSchema
|
|
41
|
-
} from '@modelcontextprotocol/sdk/types.js';
|
|
6
|
+
import { AutomationBridge } from './automation/index.js';
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
42
8
|
import { responseValidator } from './utils/response-validator.js';
|
|
43
9
|
import { z } from 'zod';
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
10
|
+
import { initializeWASM } from './wasm/index.js';
|
|
11
|
+
import { consolidatedToolDefinitions } from './tools/consolidated-tool-definitions.js';
|
|
12
|
+
import { HealthMonitor } from './services/health-monitor.js';
|
|
13
|
+
import { ServerSetup } from './server-setup.js';
|
|
14
|
+
import { startMetricsServer } from './services/metrics-server.js';
|
|
15
|
+
import { config } from './config.js';
|
|
48
16
|
|
|
49
|
-
const
|
|
17
|
+
const require = createRequire(import.meta.url);
|
|
18
|
+
const packageInfo: { name?: string; version?: string } = (() => {
|
|
19
|
+
try {
|
|
20
|
+
return require('../package.json');
|
|
21
|
+
} catch (error) {
|
|
22
|
+
const log = new Logger('UE-MCP');
|
|
23
|
+
log.debug('Unable to read package.json for server metadata', error);
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
})();
|
|
27
|
+
const DEFAULT_SERVER_NAME = typeof packageInfo.name === 'string' && packageInfo.name.trim().length > 0
|
|
28
|
+
? packageInfo.name
|
|
29
|
+
: 'unreal-engine-mcp';
|
|
30
|
+
const DEFAULT_SERVER_VERSION = typeof packageInfo.version === 'string' && packageInfo.version.trim().length > 0
|
|
31
|
+
? packageInfo.version
|
|
32
|
+
: '0.0.0';
|
|
33
|
+
|
|
34
|
+
function routeStdoutLogsToStderr(): void {
|
|
35
|
+
if (!config.MCP_ROUTE_STDOUT_LOGS) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
50
38
|
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
const writeToStderr = (...args: unknown[]): void => {
|
|
40
|
+
const line = args
|
|
41
|
+
.map((a) => (typeof a === 'string' ? a : JSON.stringify(a)))
|
|
42
|
+
.join(' ');
|
|
43
|
+
process.stderr.write(`${line}\n`);
|
|
44
|
+
};
|
|
53
45
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
averageResponseTime: number;
|
|
60
|
-
responseTimes: number[];
|
|
61
|
-
connectionStatus: 'connected' | 'disconnected' | 'error';
|
|
62
|
-
lastHealthCheck: Date;
|
|
63
|
-
uptime: number;
|
|
64
|
-
recentErrors: Array<{ time: string; scope: string; type: string; message: string; retriable: boolean }>;
|
|
46
|
+
console.log = (...args: unknown[]): void => { writeToStderr(...args); };
|
|
47
|
+
console.info = (...args: unknown[]): void => { writeToStderr(...args); };
|
|
48
|
+
if (typeof console.debug === 'function') {
|
|
49
|
+
console.debug = (...args: unknown[]): void => { writeToStderr(...args); };
|
|
50
|
+
}
|
|
65
51
|
}
|
|
66
52
|
|
|
67
|
-
const
|
|
68
|
-
totalRequests: 0,
|
|
69
|
-
successfulRequests: 0,
|
|
70
|
-
failedRequests: 0,
|
|
71
|
-
averageResponseTime: 0,
|
|
72
|
-
responseTimes: [],
|
|
73
|
-
connectionStatus: 'disconnected',
|
|
74
|
-
lastHealthCheck: new Date(),
|
|
75
|
-
uptime: Date.now(),
|
|
76
|
-
recentErrors: []
|
|
77
|
-
};
|
|
53
|
+
const log = new Logger('UE-MCP');
|
|
78
54
|
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
let lastHealthSuccessAt = 0;
|
|
55
|
+
// Ensure stdout remains JSON-only for MCP by routing logs to stderr unless opted out.
|
|
56
|
+
routeStdoutLogsToStderr();
|
|
82
57
|
|
|
83
58
|
// Configuration
|
|
84
59
|
const CONFIG = {
|
|
85
|
-
// Tooling: use consolidated tools only (13 tools)
|
|
86
|
-
// Connection retry settings
|
|
87
60
|
MAX_RETRY_ATTEMPTS: 3,
|
|
88
61
|
RETRY_DELAY_MS: 2000,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
HEALTH_CHECK_INTERVAL_MS: 30000 // 30 seconds
|
|
62
|
+
SERVER_NAME: DEFAULT_SERVER_NAME,
|
|
63
|
+
SERVER_VERSION: DEFAULT_SERVER_VERSION,
|
|
64
|
+
AUTOMATION_HEARTBEAT_MS: 15000,
|
|
65
|
+
HEALTH_CHECK_INTERVAL_MS: 30000
|
|
94
66
|
};
|
|
95
67
|
|
|
96
|
-
// Helper function to track performance
|
|
97
|
-
function trackPerformance(startTime: number, success: boolean) {
|
|
98
|
-
const responseTime = Date.now() - startTime;
|
|
99
|
-
metrics.totalRequests++;
|
|
100
|
-
if (success) {
|
|
101
|
-
metrics.successfulRequests++;
|
|
102
|
-
} else {
|
|
103
|
-
metrics.failedRequests++;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Keep last 100 response times for average calculation
|
|
107
|
-
metrics.responseTimes.push(responseTime);
|
|
108
|
-
if (metrics.responseTimes.length > 100) {
|
|
109
|
-
metrics.responseTimes.shift();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Calculate average
|
|
113
|
-
metrics.averageResponseTime = metrics.responseTimes.reduce((a, b) => a + b, 0) / metrics.responseTimes.length;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Health check function
|
|
117
|
-
async function performHealthCheck(bridge: UnrealBridge): Promise<boolean> {
|
|
118
|
-
// If not connected, do not attempt any ping (stay quiet)
|
|
119
|
-
if (!bridge.isConnected) {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
try {
|
|
123
|
-
// Use a safe echo command that doesn't affect any settings
|
|
124
|
-
await bridge.executeConsoleCommand('echo MCP Server Health Check');
|
|
125
|
-
metrics.connectionStatus = 'connected';
|
|
126
|
-
metrics.lastHealthCheck = new Date();
|
|
127
|
-
lastHealthSuccessAt = Date.now();
|
|
128
|
-
return true;
|
|
129
|
-
} catch (err1) {
|
|
130
|
-
// Fallback: minimal Python ping (if Python plugin is enabled)
|
|
131
|
-
try {
|
|
132
|
-
await bridge.executePython("import sys; sys.stdout.write('OK')");
|
|
133
|
-
metrics.connectionStatus = 'connected';
|
|
134
|
-
metrics.lastHealthCheck = new Date();
|
|
135
|
-
lastHealthSuccessAt = Date.now();
|
|
136
|
-
return true;
|
|
137
|
-
} catch (err2) {
|
|
138
|
-
metrics.connectionStatus = 'error';
|
|
139
|
-
metrics.lastHealthCheck = new Date();
|
|
140
|
-
// Avoid noisy warnings when engine may be shutting down; log at debug
|
|
141
|
-
log.debug('Health check failed (console and python):', err1, err2);
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
68
|
export function createServer() {
|
|
148
69
|
const bridge = new UnrealBridge();
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
70
|
+
const healthMonitor = new HealthMonitor(log);
|
|
71
|
+
|
|
72
|
+
const automationBridge = new AutomationBridge({
|
|
73
|
+
serverName: CONFIG.SERVER_NAME,
|
|
74
|
+
serverVersion: CONFIG.SERVER_VERSION,
|
|
75
|
+
heartbeatIntervalMs: CONFIG.AUTOMATION_HEARTBEAT_MS,
|
|
76
|
+
clientMode: config.MCP_AUTOMATION_CLIENT_MODE
|
|
77
|
+
});
|
|
78
|
+
bridge.setAutomationBridge(automationBridge);
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
automationBridge.on('connected', ({ metadata, port, protocol }) => {
|
|
82
|
+
log.info(
|
|
83
|
+
`Automation bridge connected (port=${port}, protocol=${protocol ?? 'none'})`,
|
|
84
|
+
metadata
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
automationBridge.on('disconnected', ({ code, reason, port, protocol }) => {
|
|
89
|
+
log.info(
|
|
90
|
+
`Automation bridge disconnected (code=${code}, reason=${reason || 'n/a'}, port=${port}, protocol=${protocol ?? 'none'})`
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
automationBridge.on('handshakeFailed', ({ reason, port }) => {
|
|
95
|
+
log.warn(`Automation bridge handshake failed (port=${port}): ${reason}`);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
automationBridge.on('message', (message) => {
|
|
99
|
+
log.debug('Automation bridge inbound message', message);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
automationBridge.on('error', (error) => {
|
|
103
|
+
log.error('Automation bridge error', error);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Optionally expose Prometheus-style metrics via /metrics
|
|
107
|
+
startMetricsServer({ healthMonitor, automationBridge, logger: log });
|
|
108
|
+
|
|
109
|
+
// Initialize WebAssembly module for high-performance operations (5-8x faster)
|
|
110
|
+
log.debug('Initializing WebAssembly integration...');
|
|
111
|
+
initializeWASM().then(() => {
|
|
112
|
+
log.info('✅ WebAssembly integration initialized (JSON parsing and math operations)');
|
|
113
|
+
}).catch((error) => {
|
|
114
|
+
log.warn('⚠️ WebAssembly initialization failed, using TypeScript fallbacks:', error);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Initialize response validation with schemas
|
|
153
118
|
log.debug('Initializing response validation...');
|
|
154
119
|
const toolDefs = consolidatedToolDefinitions;
|
|
155
120
|
toolDefs.forEach((tool: any) => {
|
|
@@ -157,86 +122,10 @@ export function createServer() {
|
|
|
157
122
|
responseValidator.registerSchema(tool.name, tool.outputSchema);
|
|
158
123
|
}
|
|
159
124
|
});
|
|
160
|
-
// Summary at debug level to avoid repeated noisy blocks in some shells
|
|
161
125
|
log.debug(`Registered ${responseValidator.getStats().totalSchemas} output schemas for validation`);
|
|
162
126
|
|
|
163
|
-
// Do NOT connect to Unreal at startup; connect on demand
|
|
164
127
|
log.debug('Server starting without connecting to Unreal Engine');
|
|
165
|
-
metrics.connectionStatus = 'disconnected';
|
|
166
|
-
|
|
167
|
-
// Health checks manager (only active when connected)
|
|
168
|
-
const startHealthChecks = () => {
|
|
169
|
-
if (healthCheckTimer) return;
|
|
170
|
-
lastHealthSuccessAt = Date.now();
|
|
171
|
-
healthCheckTimer = setInterval(async () => {
|
|
172
|
-
// Only attempt health pings while connected; stay silent otherwise
|
|
173
|
-
if (!bridge.isConnected) {
|
|
174
|
-
// Optionally pause fully after 5 minutes of no success
|
|
175
|
-
const FIVE_MIN_MS = 5 * 60 * 1000;
|
|
176
|
-
if (!lastHealthSuccessAt || Date.now() - lastHealthSuccessAt > FIVE_MIN_MS) {
|
|
177
|
-
if (healthCheckTimer) {
|
|
178
|
-
clearInterval(healthCheckTimer);
|
|
179
|
-
healthCheckTimer = undefined;
|
|
180
|
-
}
|
|
181
|
-
log.info('Health checks paused after 5 minutes without a successful response');
|
|
182
|
-
}
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
await performHealthCheck(bridge);
|
|
187
|
-
// Stop sending echoes if we haven't had a successful response in > 5 minutes
|
|
188
|
-
const FIVE_MIN_MS = 5 * 60 * 1000;
|
|
189
|
-
if (!lastHealthSuccessAt || Date.now() - lastHealthSuccessAt > FIVE_MIN_MS) {
|
|
190
|
-
if (healthCheckTimer) {
|
|
191
|
-
clearInterval(healthCheckTimer);
|
|
192
|
-
healthCheckTimer = undefined;
|
|
193
|
-
log.info('Health checks paused after 5 minutes without a successful response');
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}, CONFIG.HEALTH_CHECK_INTERVAL_MS);
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
// On-demand connection helper
|
|
200
|
-
const ensureConnectedOnDemand = async (): Promise<boolean> => {
|
|
201
|
-
if (bridge.isConnected) return true;
|
|
202
|
-
const ok = await bridge.tryConnect(3, 5000, 1000);
|
|
203
|
-
if (ok) {
|
|
204
|
-
metrics.connectionStatus = 'connected';
|
|
205
|
-
startHealthChecks();
|
|
206
|
-
} else {
|
|
207
|
-
metrics.connectionStatus = 'disconnected';
|
|
208
|
-
}
|
|
209
|
-
return ok;
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
// Resources
|
|
213
|
-
const assetResources = new AssetResources(bridge);
|
|
214
|
-
const actorResources = new ActorResources(bridge);
|
|
215
|
-
const levelResources = new LevelResources(bridge);
|
|
216
|
-
|
|
217
|
-
// Tools
|
|
218
|
-
const actorTools = new ActorTools(bridge);
|
|
219
|
-
const assetTools = new AssetTools(bridge);
|
|
220
|
-
const editorTools = new EditorTools(bridge);
|
|
221
|
-
const materialTools = new MaterialTools(bridge);
|
|
222
|
-
const animationTools = new AnimationTools(bridge);
|
|
223
|
-
const physicsTools = new PhysicsTools(bridge);
|
|
224
|
-
const niagaraTools = new NiagaraTools(bridge);
|
|
225
|
-
const blueprintTools = new BlueprintTools(bridge);
|
|
226
|
-
const levelTools = new LevelTools(bridge);
|
|
227
|
-
const lightingTools = new LightingTools(bridge);
|
|
228
|
-
const landscapeTools = new LandscapeTools(bridge);
|
|
229
|
-
const foliageTools = new FoliageTools(bridge);
|
|
230
|
-
const buildEnvAdvanced = new BuildEnvironmentAdvanced(bridge);
|
|
231
|
-
const debugTools = new DebugVisualizationTools(bridge);
|
|
232
|
-
const performanceTools = new PerformanceTools(bridge);
|
|
233
|
-
const audioTools = new AudioTools(bridge);
|
|
234
|
-
const uiTools = new UITools(bridge);
|
|
235
|
-
const rcTools = new RcTools(bridge);
|
|
236
|
-
const sequenceTools = new SequenceTools(bridge);
|
|
237
|
-
const introspectionTools = new IntrospectionTools(bridge);
|
|
238
|
-
const visualTools = new VisualTools(bridge);
|
|
239
|
-
const engineTools = new EngineTools(bridge);
|
|
128
|
+
healthMonitor.metrics.connectionStatus = 'disconnected';
|
|
240
129
|
|
|
241
130
|
const server = new Server(
|
|
242
131
|
{
|
|
@@ -245,460 +134,34 @@ export function createServer() {
|
|
|
245
134
|
},
|
|
246
135
|
{
|
|
247
136
|
capabilities: {
|
|
248
|
-
resources: {},
|
|
249
137
|
tools: {},
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
},
|
|
253
|
-
logging: {}
|
|
138
|
+
resources: {},
|
|
139
|
+
prompts: {}
|
|
254
140
|
}
|
|
255
141
|
}
|
|
256
142
|
);
|
|
257
143
|
|
|
258
|
-
//
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
const createNotConnectedResponse = (toolName: string) => {
|
|
263
|
-
const payload = {
|
|
264
|
-
success: false,
|
|
265
|
-
error: 'UE_NOT_CONNECTED',
|
|
266
|
-
message: 'Unreal Engine is not connected (after 3 attempts). Please open UE and try again.',
|
|
267
|
-
retriable: false,
|
|
268
|
-
scope: `tool-call/${toolName}`
|
|
269
|
-
} as const;
|
|
270
|
-
|
|
271
|
-
return responseValidator.wrapResponse(toolName, {
|
|
272
|
-
...payload,
|
|
273
|
-
content: [
|
|
274
|
-
{
|
|
275
|
-
type: 'text',
|
|
276
|
-
text: JSON.stringify(payload, null, 2)
|
|
277
|
-
}
|
|
278
|
-
]
|
|
279
|
-
});
|
|
280
|
-
};
|
|
144
|
+
// Setup server using helper class
|
|
145
|
+
const serverSetup = new ServerSetup(server, bridge, automationBridge, log, healthMonitor);
|
|
146
|
+
serverSetup.setup(); // Register tools, resources, and prompts
|
|
281
147
|
|
|
282
|
-
|
|
283
|
-
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
284
|
-
return {
|
|
285
|
-
resources: [
|
|
286
|
-
{
|
|
287
|
-
uri: 'ue://assets',
|
|
288
|
-
name: 'Project Assets',
|
|
289
|
-
description: 'List all assets in the project',
|
|
290
|
-
mimeType: 'application/json'
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
uri: 'ue://actors',
|
|
294
|
-
name: 'Level Actors',
|
|
295
|
-
description: 'List all actors in the current level',
|
|
296
|
-
mimeType: 'application/json'
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
uri: 'ue://level',
|
|
300
|
-
name: 'Current Level',
|
|
301
|
-
description: 'Information about the current level',
|
|
302
|
-
mimeType: 'application/json'
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
uri: 'ue://exposed',
|
|
306
|
-
name: 'Remote Control Exposed',
|
|
307
|
-
description: 'List all exposed properties via Remote Control',
|
|
308
|
-
mimeType: 'application/json'
|
|
309
|
-
},
|
|
310
|
-
{
|
|
311
|
-
uri: 'ue://health',
|
|
312
|
-
name: 'Health Status',
|
|
313
|
-
description: 'Server health and performance metrics',
|
|
314
|
-
mimeType: 'application/json'
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
uri: 'ue://version',
|
|
318
|
-
name: 'Engine Version',
|
|
319
|
-
description: 'Unreal Engine version and compatibility info',
|
|
320
|
-
mimeType: 'application/json'
|
|
321
|
-
}
|
|
322
|
-
]
|
|
323
|
-
};
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
// Handle resource reading
|
|
327
|
-
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
328
|
-
const uri = request.params.uri;
|
|
329
|
-
|
|
330
|
-
if (uri === 'ue://assets') {
|
|
331
|
-
const ok = await ensureConnectedOnDemand();
|
|
332
|
-
if (!ok) {
|
|
333
|
-
return { contents: [{ uri, mimeType: 'text/plain', text: 'Unreal Engine not connected (after 3 attempts).' }] };
|
|
334
|
-
}
|
|
335
|
-
const list = await assetResources.list('/Game', true);
|
|
336
|
-
return {
|
|
337
|
-
contents: [{
|
|
338
|
-
uri,
|
|
339
|
-
mimeType: 'application/json',
|
|
340
|
-
text: JSON.stringify(list, null, 2)
|
|
341
|
-
}]
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (uri === 'ue://actors') {
|
|
346
|
-
const ok = await ensureConnectedOnDemand();
|
|
347
|
-
if (!ok) {
|
|
348
|
-
return { contents: [{ uri, mimeType: 'text/plain', text: 'Unreal Engine not connected (after 3 attempts).' }] };
|
|
349
|
-
}
|
|
350
|
-
const list = await actorResources.listActors();
|
|
351
|
-
return {
|
|
352
|
-
contents: [{
|
|
353
|
-
uri,
|
|
354
|
-
mimeType: 'application/json',
|
|
355
|
-
text: JSON.stringify(list, null, 2)
|
|
356
|
-
}]
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
if (uri === 'ue://level') {
|
|
361
|
-
const ok = await ensureConnectedOnDemand();
|
|
362
|
-
if (!ok) {
|
|
363
|
-
return { contents: [{ uri, mimeType: 'text/plain', text: 'Unreal Engine not connected (after 3 attempts).' }] };
|
|
364
|
-
}
|
|
365
|
-
const level = await levelResources.getCurrentLevel();
|
|
366
|
-
return {
|
|
367
|
-
contents: [{
|
|
368
|
-
uri,
|
|
369
|
-
mimeType: 'application/json',
|
|
370
|
-
text: JSON.stringify(level, null, 2)
|
|
371
|
-
}]
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
if (uri === 'ue://exposed') {
|
|
376
|
-
const ok = await ensureConnectedOnDemand();
|
|
377
|
-
if (!ok) {
|
|
378
|
-
return { contents: [{ uri, mimeType: 'text/plain', text: 'Unreal Engine not connected (after 3 attempts).' }] };
|
|
379
|
-
}
|
|
380
|
-
try {
|
|
381
|
-
const exposed = await bridge.getExposed();
|
|
382
|
-
return {
|
|
383
|
-
contents: [{
|
|
384
|
-
uri,
|
|
385
|
-
mimeType: 'application/json',
|
|
386
|
-
text: JSON.stringify(exposed, null, 2)
|
|
387
|
-
}]
|
|
388
|
-
};
|
|
389
|
-
} catch {
|
|
390
|
-
return {
|
|
391
|
-
contents: [{
|
|
392
|
-
uri,
|
|
393
|
-
mimeType: 'text/plain',
|
|
394
|
-
text: 'Failed to get exposed properties. Ensure Remote Control is configured.'
|
|
395
|
-
}]
|
|
396
|
-
};
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
if (uri === 'ue://health') {
|
|
401
|
-
const uptimeMs = Date.now() - metrics.uptime;
|
|
402
|
-
// Query engine version and feature flags only when connected
|
|
403
|
-
let versionInfo: any = {};
|
|
404
|
-
let featureFlags: any = {};
|
|
405
|
-
if (bridge.isConnected) {
|
|
406
|
-
try { versionInfo = await bridge.getEngineVersion(); } catch {}
|
|
407
|
-
try { featureFlags = await bridge.getFeatureFlags(); } catch {}
|
|
408
|
-
}
|
|
409
|
-
const health = {
|
|
410
|
-
status: metrics.connectionStatus,
|
|
411
|
-
uptime: Math.floor(uptimeMs / 1000),
|
|
412
|
-
performance: {
|
|
413
|
-
totalRequests: metrics.totalRequests,
|
|
414
|
-
successfulRequests: metrics.successfulRequests,
|
|
415
|
-
failedRequests: metrics.failedRequests,
|
|
416
|
-
successRate: metrics.totalRequests > 0 ?
|
|
417
|
-
(metrics.successfulRequests / metrics.totalRequests * 100).toFixed(2) + '%' : 'N/A',
|
|
418
|
-
averageResponseTime: Math.round(metrics.averageResponseTime) + 'ms'
|
|
419
|
-
},
|
|
420
|
-
lastHealthCheck: metrics.lastHealthCheck.toISOString(),
|
|
421
|
-
unrealConnection: {
|
|
422
|
-
status: bridge.isConnected ? 'connected' : 'disconnected',
|
|
423
|
-
host: process.env.UE_HOST || 'localhost',
|
|
424
|
-
httpPort: process.env.UE_RC_HTTP_PORT || 30010,
|
|
425
|
-
wsPort: process.env.UE_RC_WS_PORT || 30020,
|
|
426
|
-
engineVersion: versionInfo,
|
|
427
|
-
features: {
|
|
428
|
-
pythonEnabled: featureFlags.pythonEnabled === true,
|
|
429
|
-
subsystems: featureFlags.subsystems || {},
|
|
430
|
-
rcHttpReachable: bridge.isConnected
|
|
431
|
-
}
|
|
432
|
-
},
|
|
433
|
-
recentErrors: metrics.recentErrors.slice(-5)
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
return {
|
|
437
|
-
contents: [{
|
|
438
|
-
uri,
|
|
439
|
-
mimeType: 'application/json',
|
|
440
|
-
text: JSON.stringify(health, null, 2)
|
|
441
|
-
}]
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
if (uri === 'ue://version') {
|
|
446
|
-
const ok = await ensureConnectedOnDemand();
|
|
447
|
-
if (!ok) {
|
|
448
|
-
return { contents: [{ uri, mimeType: 'text/plain', text: 'Unreal Engine not connected (after 3 attempts).' }] };
|
|
449
|
-
}
|
|
450
|
-
const info = await bridge.getEngineVersion();
|
|
451
|
-
return {
|
|
452
|
-
contents: [{
|
|
453
|
-
uri,
|
|
454
|
-
mimeType: 'application/json',
|
|
455
|
-
text: JSON.stringify(info, null, 2)
|
|
456
|
-
}]
|
|
457
|
-
};
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
throw new Error(`Unknown resource: ${uri}`);
|
|
461
|
-
});
|
|
462
|
-
|
|
463
|
-
// Handle tool listing - consolidated tools only
|
|
464
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
465
|
-
log.info('Serving consolidated tools');
|
|
466
|
-
return {
|
|
467
|
-
tools: consolidatedToolDefinitions
|
|
468
|
-
};
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
// Handle tool calls - consolidated tools only (13)
|
|
472
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
473
|
-
const { name } = request.params;
|
|
474
|
-
let args: any = request.params.arguments || {};
|
|
475
|
-
const startTime = Date.now();
|
|
476
|
-
|
|
477
|
-
// Ensure connection only when needed, with 3 attempts
|
|
478
|
-
const connected = await ensureConnectedOnDemand();
|
|
479
|
-
if (!connected) {
|
|
480
|
-
trackPerformance(startTime, false);
|
|
481
|
-
return createNotConnectedResponse(name);
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
// Create tools object for handler
|
|
485
|
-
const tools = {
|
|
486
|
-
actorTools,
|
|
487
|
-
assetTools,
|
|
488
|
-
materialTools,
|
|
489
|
-
editorTools,
|
|
490
|
-
animationTools,
|
|
491
|
-
physicsTools,
|
|
492
|
-
niagaraTools,
|
|
493
|
-
blueprintTools,
|
|
494
|
-
levelTools,
|
|
495
|
-
lightingTools,
|
|
496
|
-
landscapeTools,
|
|
497
|
-
foliageTools,
|
|
498
|
-
buildEnvAdvanced,
|
|
499
|
-
debugTools,
|
|
500
|
-
performanceTools,
|
|
501
|
-
audioTools,
|
|
502
|
-
uiTools,
|
|
503
|
-
rcTools,
|
|
504
|
-
sequenceTools,
|
|
505
|
-
introspectionTools,
|
|
506
|
-
visualTools,
|
|
507
|
-
engineTools,
|
|
508
|
-
// Elicitation (client-optional)
|
|
509
|
-
elicit: elicitation.elicit,
|
|
510
|
-
supportsElicitation: elicitation.supports,
|
|
511
|
-
elicitationTimeoutMs: defaultElicitationTimeoutMs,
|
|
512
|
-
// Resources for listing and info
|
|
513
|
-
assetResources,
|
|
514
|
-
actorResources,
|
|
515
|
-
levelResources,
|
|
516
|
-
bridge
|
|
517
|
-
};
|
|
518
|
-
|
|
519
|
-
// Execute consolidated tool handler
|
|
520
|
-
try {
|
|
521
|
-
log.debug(`Executing tool: ${name}`);
|
|
522
|
-
|
|
523
|
-
// Opportunistic generic elicitation for missing primitive required fields
|
|
524
|
-
try {
|
|
525
|
-
const toolDef: any = (consolidatedToolDefinitions as any[]).find(t => t.name === name);
|
|
526
|
-
const inputSchema: any = toolDef?.inputSchema;
|
|
527
|
-
const elicitFn: any = (tools as any).elicit;
|
|
528
|
-
if (inputSchema && typeof elicitFn === 'function') {
|
|
529
|
-
const props = inputSchema.properties || {};
|
|
530
|
-
const required: string[] = Array.isArray(inputSchema.required) ? inputSchema.required : [];
|
|
531
|
-
const missing = required.filter((k: string) => {
|
|
532
|
-
const v = (args as any)[k];
|
|
533
|
-
if (v === undefined || v === null) return true;
|
|
534
|
-
if (typeof v === 'string' && v.trim() === '') return true;
|
|
535
|
-
return false;
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
// Build a flat primitive-only schema subset per MCP Elicitation rules
|
|
539
|
-
const primitiveProps: any = {};
|
|
540
|
-
for (const k of missing) {
|
|
541
|
-
const p = props[k];
|
|
542
|
-
if (!p || typeof p !== 'object') continue;
|
|
543
|
-
const t = (p.type || '').toString();
|
|
544
|
-
const isEnum = Array.isArray(p.enum);
|
|
545
|
-
if (t === 'string' || t === 'number' || t === 'integer' || t === 'boolean' || isEnum) {
|
|
546
|
-
primitiveProps[k] = {
|
|
547
|
-
type: t || (isEnum ? 'string' : undefined),
|
|
548
|
-
title: p.title,
|
|
549
|
-
description: p.description,
|
|
550
|
-
enum: p.enum,
|
|
551
|
-
enumNames: p.enumNames,
|
|
552
|
-
minimum: p.minimum,
|
|
553
|
-
maximum: p.maximum,
|
|
554
|
-
minLength: p.minLength,
|
|
555
|
-
maxLength: p.maxLength,
|
|
556
|
-
pattern: p.pattern,
|
|
557
|
-
format: p.format,
|
|
558
|
-
default: p.default
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
if (Object.keys(primitiveProps).length > 0) {
|
|
564
|
-
const elicitOptions: any = { fallback: async () => ({ ok: false, error: 'missing-params' }) };
|
|
565
|
-
if (typeof (tools as any).elicitationTimeoutMs === 'number' && Number.isFinite((tools as any).elicitationTimeoutMs)) {
|
|
566
|
-
elicitOptions.timeoutMs = (tools as any).elicitationTimeoutMs;
|
|
567
|
-
}
|
|
568
|
-
const elicitRes = await elicitFn(
|
|
569
|
-
`Provide missing parameters for ${name}`,
|
|
570
|
-
{ type: 'object', properties: primitiveProps, required: Object.keys(primitiveProps) },
|
|
571
|
-
elicitOptions
|
|
572
|
-
);
|
|
573
|
-
if (elicitRes && elicitRes.ok && elicitRes.value) {
|
|
574
|
-
args = { ...args, ...elicitRes.value };
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
} catch (e) {
|
|
579
|
-
log.debug('Generic elicitation prefill skipped', { err: (e as any)?.message || String(e) });
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
let result = await handleConsolidatedToolCall(name, args, tools);
|
|
583
|
-
|
|
584
|
-
log.debug(`Tool ${name} returned result`);
|
|
585
|
-
|
|
586
|
-
// Clean the result to remove circular references
|
|
587
|
-
result = cleanObject(result);
|
|
588
|
-
|
|
589
|
-
// Validate and enhance response
|
|
590
|
-
result = responseValidator.wrapResponse(name, result);
|
|
591
|
-
|
|
592
|
-
trackPerformance(startTime, true);
|
|
593
|
-
|
|
594
|
-
log.info(`Tool ${name} completed successfully in ${Date.now() - startTime}ms`);
|
|
595
|
-
|
|
596
|
-
// Log that we're returning the response
|
|
597
|
-
const responsePreview = JSON.stringify(result).substring(0, 100);
|
|
598
|
-
log.debug(`Returning response to MCP client: ${responsePreview}...`);
|
|
599
|
-
|
|
600
|
-
return result;
|
|
601
|
-
} catch (error) {
|
|
602
|
-
trackPerformance(startTime, false);
|
|
603
|
-
|
|
604
|
-
// Use consistent error handling
|
|
605
|
-
const errorResponse = ErrorHandler.createErrorResponse(error, name, { ...args, scope: `tool-call/${name}` });
|
|
606
|
-
log.error(`Tool execution failed: ${name}`, errorResponse);
|
|
607
|
-
// Record error for health diagnostics
|
|
608
|
-
try {
|
|
609
|
-
metrics.recentErrors.push({
|
|
610
|
-
time: new Date().toISOString(),
|
|
611
|
-
scope: (errorResponse as any).scope || `tool-call/${name}`,
|
|
612
|
-
type: (errorResponse as any)._debug?.errorType || 'UNKNOWN',
|
|
613
|
-
message: (errorResponse as any).error || (errorResponse as any).message || 'Unknown error',
|
|
614
|
-
retriable: Boolean((errorResponse as any).retriable)
|
|
615
|
-
});
|
|
616
|
-
if (metrics.recentErrors.length > 20) metrics.recentErrors.splice(0, metrics.recentErrors.length - 20);
|
|
617
|
-
} catch {}
|
|
618
|
-
|
|
619
|
-
const sanitizedError = cleanObject(errorResponse);
|
|
620
|
-
let errorText = '';
|
|
621
|
-
try {
|
|
622
|
-
errorText = JSON.stringify(sanitizedError, null, 2);
|
|
623
|
-
} catch {
|
|
624
|
-
errorText = sanitizedError.message || errorResponse.message || `Failed to execute ${name}`;
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
const wrappedError = {
|
|
628
|
-
...sanitizedError,
|
|
629
|
-
isError: true,
|
|
630
|
-
content: [{
|
|
631
|
-
type: 'text',
|
|
632
|
-
text: errorText
|
|
633
|
-
}]
|
|
634
|
-
};
|
|
635
|
-
|
|
636
|
-
return responseValidator.wrapResponse(name, wrappedError);
|
|
637
|
-
}
|
|
638
|
-
});
|
|
639
|
-
|
|
640
|
-
// Handle prompt listing
|
|
641
|
-
server.setRequestHandler(ListPromptsRequestSchema, async () => {
|
|
642
|
-
return {
|
|
643
|
-
prompts: prompts.map(p => ({
|
|
644
|
-
name: p.name,
|
|
645
|
-
description: p.description,
|
|
646
|
-
arguments: Object.entries(p.arguments || {}).map(([name, schema]) => {
|
|
647
|
-
const meta: Record<string, unknown> = {};
|
|
648
|
-
if (schema.type) meta.type = schema.type;
|
|
649
|
-
if (schema.enum) meta.enum = schema.enum;
|
|
650
|
-
if (schema.default !== undefined) meta.default = schema.default;
|
|
651
|
-
return {
|
|
652
|
-
name,
|
|
653
|
-
description: schema.description,
|
|
654
|
-
required: schema.required ?? false,
|
|
655
|
-
...(Object.keys(meta).length ? { _meta: meta } : {})
|
|
656
|
-
};
|
|
657
|
-
})
|
|
658
|
-
}))
|
|
659
|
-
};
|
|
660
|
-
});
|
|
661
|
-
|
|
662
|
-
// Handle prompt retrieval
|
|
663
|
-
server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
664
|
-
const prompt = prompts.find(p => p.name === request.params.name);
|
|
665
|
-
if (!prompt) {
|
|
666
|
-
throw new Error(`Unknown prompt: ${request.params.name}`);
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
const args = (request.params.arguments || {}) as Record<string, unknown>;
|
|
670
|
-
const messages = prompt.build(args);
|
|
671
|
-
return {
|
|
672
|
-
description: prompt.description,
|
|
673
|
-
messages
|
|
674
|
-
};
|
|
675
|
-
});
|
|
676
|
-
|
|
677
|
-
return { server, bridge };
|
|
148
|
+
return { server, bridge, automationBridge };
|
|
678
149
|
}
|
|
679
150
|
|
|
680
|
-
// Export configuration schema for
|
|
151
|
+
// Export configuration schema for session UI and runtime validation
|
|
681
152
|
export const configSchema = z.object({
|
|
682
|
-
ueHost: z.string().optional().default('127.0.0.1').describe('Unreal Engine host (e.g. 127.0.0.1)'),
|
|
683
|
-
ueHttpPort: z.number().int().optional().default(30010).describe('Remote Control HTTP port'),
|
|
684
|
-
ueWsPort: z.number().int().optional().default(30020).describe('Remote Control WebSocket port'),
|
|
685
153
|
logLevel: z.enum(['debug', 'info', 'warn', 'error']).optional().default('info').describe('Runtime log level'),
|
|
686
154
|
projectPath: z.string().optional().default('C:/Users/YourName/Documents/Unreal Projects/YourProject').describe('Absolute path to your Unreal .uproject file')
|
|
687
155
|
});
|
|
688
156
|
|
|
689
|
-
// Default export
|
|
690
|
-
// and injects values into the environment before creating the server.
|
|
157
|
+
// Default export for runtime configuration support.
|
|
691
158
|
export default function createServerDefault({ config }: { config?: any } = {}) {
|
|
692
159
|
try {
|
|
693
160
|
if (config) {
|
|
694
|
-
if (typeof config.
|
|
695
|
-
if (config.
|
|
696
|
-
if (config.ueWsPort !== undefined) process.env.UE_RC_WS_PORT = String(config.ueWsPort);
|
|
697
|
-
if (typeof config.logLevel === 'string') process.env.LOG_LEVEL = config.logLevel;
|
|
698
|
-
if (typeof config.projectPath === 'string' && config.projectPath.trim()) process.env.UE_PROJECT_PATH = config.projectPath;
|
|
161
|
+
if (typeof config.logLevel === 'string') process.env.LOG_LEVEL = config.logLevel;
|
|
162
|
+
if (typeof config.projectPath === 'string' && config.projectPath.trim()) process.env.UE_PROJECT_PATH = config.projectPath;
|
|
699
163
|
}
|
|
700
164
|
} catch (e) {
|
|
701
|
-
// Non-fatal: log and continue (console to avoid circular logger dependencies at top-level)
|
|
702
165
|
console.debug('[createServerDefault] Failed to apply config to environment:', (e as any)?.message || e);
|
|
703
166
|
}
|
|
704
167
|
|
|
@@ -707,19 +170,59 @@ export default function createServerDefault({ config }: { config?: any } = {}) {
|
|
|
707
170
|
}
|
|
708
171
|
|
|
709
172
|
export async function startStdioServer() {
|
|
710
|
-
const { server } = createServer();
|
|
173
|
+
const { server, automationBridge } = createServer();
|
|
711
174
|
const transport = new StdioServerTransport();
|
|
712
|
-
|
|
713
|
-
|
|
175
|
+
let shuttingDown = false;
|
|
176
|
+
|
|
177
|
+
const handleShutdown = async (signal?: NodeJS.Signals) => {
|
|
178
|
+
if (shuttingDown) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
shuttingDown = true;
|
|
182
|
+
const reason = signal ? ` due to ${signal}` : '';
|
|
183
|
+
log.info(`Shutting down MCP server${reason}`);
|
|
184
|
+
try {
|
|
185
|
+
automationBridge.stop();
|
|
186
|
+
} catch (error) {
|
|
187
|
+
log.warn('Failed to stop automation bridge cleanly', error);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
try {
|
|
191
|
+
if (typeof (server as any).close === 'function') {
|
|
192
|
+
await (server as any).close();
|
|
193
|
+
}
|
|
194
|
+
} catch (error) {
|
|
195
|
+
log.warn('Failed to close MCP server transport cleanly', error);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (signal) {
|
|
199
|
+
process.exit(0);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
['SIGINT', 'SIGTERM'].forEach((signal) => {
|
|
204
|
+
process.once(signal as NodeJS.Signals, () => {
|
|
205
|
+
void handleShutdown(signal as NodeJS.Signals);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
process.once('beforeExit', () => {
|
|
210
|
+
automationBridge.stop();
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
process.once('exit', () => {
|
|
214
|
+
automationBridge.stop();
|
|
215
|
+
});
|
|
216
|
+
|
|
714
217
|
const originalWrite = process.stdout.write;
|
|
715
|
-
process.stdout.write = function(...args: any[]) {
|
|
218
|
+
process.stdout.write = function (...args: any[]) {
|
|
716
219
|
const message = args[0];
|
|
717
220
|
if (typeof message === 'string' && message.includes('jsonrpc')) {
|
|
718
221
|
log.debug(`Sending to client: ${message.substring(0, 200)}...`);
|
|
719
222
|
}
|
|
720
223
|
return originalWrite.apply(process.stdout, args as any);
|
|
721
224
|
} as any;
|
|
722
|
-
|
|
225
|
+
|
|
723
226
|
await server.connect(transport);
|
|
724
227
|
log.info('Unreal Engine MCP Server started on stdio');
|
|
725
228
|
}
|