uefn-agent-bridge 0.8.1__tar.gz

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 (32) hide show
  1. uefn_agent_bridge-0.8.1/LICENSE +21 -0
  2. uefn_agent_bridge-0.8.1/PKG-INFO +577 -0
  3. uefn_agent_bridge-0.8.1/README.md +550 -0
  4. uefn_agent_bridge-0.8.1/bridge/__init__.py +2 -0
  5. uefn_agent_bridge-0.8.1/bridge/client.py +377 -0
  6. uefn_agent_bridge-0.8.1/bridge/mcp_client.py +1056 -0
  7. uefn_agent_bridge-0.8.1/bridge/release.json +13 -0
  8. uefn_agent_bridge-0.8.1/bridge/routes.py +305 -0
  9. uefn_agent_bridge-0.8.1/bridge/server.py +3395 -0
  10. uefn_agent_bridge-0.8.1/bridge/startup.py +37 -0
  11. uefn_agent_bridge-0.8.1/bridge/uefn_tool_policy.py +1502 -0
  12. uefn_agent_bridge-0.8.1/bridge/updates.py +261 -0
  13. uefn_agent_bridge-0.8.1/pyproject.toml +42 -0
  14. uefn_agent_bridge-0.8.1/setup.cfg +4 -0
  15. uefn_agent_bridge-0.8.1/tests/test_activity_and_deadlines.py +306 -0
  16. uefn_agent_bridge-0.8.1/tests/test_cli.py +181 -0
  17. uefn_agent_bridge-0.8.1/tests/test_client.py +176 -0
  18. uefn_agent_bridge-0.8.1/tests/test_exec_budget_and_jobs.py +431 -0
  19. uefn_agent_bridge-0.8.1/tests/test_mcp_client.py +707 -0
  20. uefn_agent_bridge-0.8.1/tests/test_rotation_and_delete.py +169 -0
  21. uefn_agent_bridge-0.8.1/tests/test_routes.py +197 -0
  22. uefn_agent_bridge-0.8.1/tests/test_server_http_security.py +208 -0
  23. uefn_agent_bridge-0.8.1/tests/test_server_hybrid.py +493 -0
  24. uefn_agent_bridge-0.8.1/tests/test_updates.py +422 -0
  25. uefn_agent_bridge-0.8.1/tests/test_verse_build_all.py +167 -0
  26. uefn_agent_bridge-0.8.1/uefn_agent_bridge/__init__.py +21 -0
  27. uefn_agent_bridge-0.8.1/uefn_agent_bridge/cli.py +191 -0
  28. uefn_agent_bridge-0.8.1/uefn_agent_bridge.egg-info/PKG-INFO +577 -0
  29. uefn_agent_bridge-0.8.1/uefn_agent_bridge.egg-info/SOURCES.txt +30 -0
  30. uefn_agent_bridge-0.8.1/uefn_agent_bridge.egg-info/dependency_links.txt +1 -0
  31. uefn_agent_bridge-0.8.1/uefn_agent_bridge.egg-info/entry_points.txt +2 -0
  32. uefn_agent_bridge-0.8.1/uefn_agent_bridge.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jon Hughes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,577 @@
1
+ Metadata-Version: 2.4
2
+ Name: uefn-agent-bridge
3
+ Version: 0.8.1
4
+ Summary: Control Unreal Editor for Fortnite (UEFN) from AI agents, scripts and CI
5
+ Author: Valid
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Valid/uefn-agent-bridge
8
+ Project-URL: Source, https://github.com/Valid/uefn-agent-bridge
9
+ Project-URL: Issues, https://github.com/Valid/uefn-agent-bridge/issues
10
+ Project-URL: Discord, https://discord.gg/fchq
11
+ Keywords: uefn,fortnite,unreal,mcp,ai-agents,verse
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Dynamic: license-file
27
+
28
+ # UEFN Agent Bridge: control Unreal Editor for Fortnite from AI agents, scripts and CI
29
+
30
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) ![UEFN v42.40 and v43.00](https://img.shields.io/badge/UEFN-v42.40%20%7C%20v43.00-informational) ![Python 3.11 in UEFN](https://img.shields.io/badge/python-3.11%20(embedded)-informational)
31
+
32
+ *Formerly `uefn-python-bridge`; old links and clones redirect here.*
33
+
34
+ **Give your AI agent all of UEFN, not half of it.** Epic's MCP is slow, reaches only the Fortnite tools Epic exposes, and by Epic's own notes can stall the editor; UEFN's Python reaches the whole editor, but only from inside it. [UEFN Agent Bridge](https://github.com/Valid/uefn-agent-bridge) puts both behind one fast local endpoint your agent can call from outside the editor, running Epic's tools in-process instead of over MCP, with the safety rails unattended work needs. Free and open source; join us on [Discord](https://discord.gg/fchq).
35
+
36
+ It is a plain HTTP + JSON server with no dependencies beyond UEFN's embedded Python, so it works from any language. A stdlib-only Python client is included.
37
+
38
+ ## What you get that MCP or Python alone don't
39
+
40
+ - **Both halves, one endpoint.** The full UEFN Python API plus Epic's Verse, session, device and Scene Graph tools, with friendly names for all 42 UEFN-specific tools plus the widget tools a UMG screen needs, and generic access to every approved creator toolset.
41
+ - **Faster calls.** Commands run as embedded Python on the editor thread and Epic's tools run in-process through the Toolset Registry, skipping MCP's HTTP and discovery overhead. MCP is only the last resort.
42
+ - **No silent duplicates.** One editor command runs at a time, and a call that timed out after it may have started is reported as `outcome_unknown` and never replayed on another route, so you check the editor before retrying instead of stacking a second device, entity or session.
43
+ - **Knows when the editor is stuck.** `status` answers instantly, even mid-build, with the running command, the queue and the time since the editor last ticked, so a modal dialog or a hang looks different from a slow build. Add `"if_busy": "reject"` to fail fast instead of queueing.
44
+ - **Deadlines that fit UEFN.** Session start, push and Verse build get up to 10 minutes by default, so long operations stop reporting false timeouts.
45
+ - **Results instead of log-diving.** Every call returns its result to the caller and names the route that handled it; Python that raises fails with its traceback and output; deletes list what they could not delete.
46
+ - **Keeps running in the background.** At start the bridge switches off UEFN's "Use Less CPU when in Background" throttle where the editor allows it (`fix_throttle` switches it off again), so automation does not stall when the editor is not focused.
47
+ - **Undoable edits.** Direct actor edits run inside editor transactions, and `batch.exec` turns many edits into one undo step.
48
+ - **Stays current.** The bridge checks for a newer release at startup, and `bridge.update` installs it after verifying every file, keeping a backup. Automatic installs are opt-in.
49
+ - **Any language, local only.** Plain HTTP + JSON with a stdlib Python client; loopback only, with cross-origin web pages rejected.
50
+
51
+ ## What you can automate
52
+
53
+ | Task | Commands |
54
+ |---|---|
55
+ | Spawn, move, duplicate, delete and inspect actors | `actors.spawn`, `actors.transform`, `actors.duplicate`, `actors.delete`, `actors.list`, `actors.properties` |
56
+ | Find, import, rename and save assets | `assets.search`, `assets.import_task`, `assets.rename`, `assets.save` |
57
+ | Place Creative devices and wire events | `devices.place`, `devices.set_property`, `devices.add_event_binding`, `devices.list_classic_options`, `devices.get_classic_option_values`, `devices.set_classic_option` |
58
+ | Edit Verse device `@editable` properties on placed devices | `verse.find_device`, `verse.get_properties`, `verse.set_property` |
59
+ | Read, write, search and build Verse | `verse.read_file`, `verse.write_file`, `verse.grep`, `verse.build` |
60
+ | Launch a play session, start a match, push changes | `session.start`, `session.start_game`, `session.push_changes`, `session.status` |
61
+ | Scene Graph entities and components | `entities.create`, `entities.add_component`, `entities.set_component_property` |
62
+ | Material instances, viewport camera, level save | `materials.create_instance`, `viewport.set_camera`, `level.save` |
63
+ | Anything else in the editor | `exec` (run Python), `batch.exec` (several commands in one undo step), `toolsets.call` |
64
+
65
+ ## Quick Start
66
+
67
+ Paste this into an AI coding agent:
68
+
69
+ > Clone https://github.com/Valid/uefn-agent-bridge and help me set it up with my UEFN project.
70
+
71
+ The included [`RULES.md`](RULES.md) explains the routing contract and working UEFN Python patterns.
72
+
73
+ ## Manual Setup
74
+
75
+ ### 1. Enable embedded Python
76
+
77
+ In UEFN Project Settings, enable `Python Editor Scripting`. This is the only requirement for the existing direct Python commands.
78
+
79
+ ### 2. Enable Epic's creator toolsets
80
+
81
+ For the Toolset Registry and MCP capabilities, enable `UEFN MCP Toolsets` in Project Settings. Apply any restart requested by UEFN.
82
+
83
+ ### 3. Enable the official MCP server
84
+
85
+ In Editor Preferences, open `General > Model Context Protocol` and enable `Auto Start Server`.
86
+
87
+ The default endpoint is:
88
+
89
+ ```text
90
+ http://127.0.0.1:8000/mcp
91
+ ```
92
+
93
+ The bridge accepts only a loopback MCP endpoint. To use a different loopback port or path, either set `UEFN_MCP_URL` in UEFN's process environment before running the bridge or configure it at runtime:
94
+
95
+ ```json
96
+ {
97
+ "command": "mcp.configure",
98
+ "params": {"url": "http://127.0.0.1:8123/mcp"}
99
+ }
100
+ ```
101
+
102
+ You can also manage Epic's server from the UEFN console with `ModelContextProtocol.StartServer [port]`, `ModelContextProtocol.StopServer`, and `ModelContextProtocol.RefreshTools`.
103
+
104
+ ### Install with pip
105
+
106
+ ```bash
107
+ pip install uefn-agent-bridge
108
+ uefn-agent-bridge install "C:/path/to/MyProject" --auto-start
109
+ ```
110
+
111
+ Restart UEFN after installing, then check the connection:
112
+
113
+ ```bash
114
+ uefn-agent-bridge status
115
+ ```
116
+
117
+ Omit `--auto-start` to run the bridge manually in step 4. The installer copies the packaged, digest-checked bridge files into your project's `Content/Python/bridge/` folder.
118
+
119
+ ### 4. Run the bridge
120
+
121
+ In UEFN, choose `Tools > Execute Python Script` and select `bridge/server.py`.
122
+
123
+ The Output Log should include:
124
+
125
+ ```text
126
+ [Bridge 12:34:56] Bridge v0.8.1 listening on http://127.0.0.1:9210
127
+ [Bridge 12:34:56] 92 commands registered
128
+ ```
129
+
130
+ The bridge checks ports 9210 through 9220 and uses the first available port.
131
+ If it selects a port other than 9210, pass the logged port to
132
+ `UEFNBridge(port=...)` or use that port in raw HTTP requests.
133
+
134
+ ## How Routing Works: Python First, Toolsets Next, MCP Last
135
+
136
+ Every request follows a deterministic route:
137
+
138
+ | Priority | Response `route` | Used for |
139
+ |---|---|---|
140
+ | 1 | `python` | Existing bridge commands for actors, assets, levels, materials, viewport control, and placed Verse-device inspection |
141
+ | 2 | `toolset_registry` | Epic creator-exposed toolsets called directly inside UEFN, without MCP transport overhead |
142
+ | 3 | `mcp` | Official loopback UEFN MCP when the requested capability or local registry is unavailable before dispatch |
143
+
144
+ `verse.build` has one more route, `verse_source_subsystem`: on UEFN 44.00, which registers no Verse toolset under either name, it builds with the editor's own `VerseSourceEditorSubsystem.build_all()` and returns `{"diagnostics": [...], "error_count": n, "builder": "VerseSourceEditorSubsystem.build_all"}`, with LSP severities named (`error`, `warning`, ...).
145
+
146
+ Named direct commands never detour through MCP. The 71 friendly aliases and `toolsets.*` commands try the local Toolset Registry first. The `mcp.*` commands explicitly bypass local routing for diagnostics or compatibility testing.
147
+
148
+ Fallback is mutation-safe. Once a Toolset Registry or MCP call may have started, a timeout, disconnect, malformed response, or unknown result is returned with `"outcome_unknown": true` and is not replayed through another route. This prevents duplicate entities, devices, file writes, sessions, or event bindings.
149
+
150
+ ### Why hybrid
151
+
152
+ UEFN's Python API is fast and broad for normal editor automation, but some Fortnite-specific operations are not available through `unreal.*`. Epic's creator toolsets add Verse-file, play-session, device, and Scene Graph entity capabilities. Calling those toolsets through the in-process registry avoids the fixed HTTP and discovery cost of MCP whenever possible.
153
+
154
+ Epic currently lists editor slowdowns and hangs during MCP calls as a known issue. Keeping MCP as the final route makes the common path responsive while retaining the capabilities that only Epic's toolsets expose.
155
+
156
+ Official references:
157
+
158
+ - [Unreal MCP is now available in UEFN](https://www.fortnite.com/news/unreal-mcp-is-now-available-in-uefn)
159
+ - [UEFN MCP setup and known issues](https://dev.epicgames.com/documentation/fortnite/uefn-mcp)
160
+ - [Unreal MCP architecture](https://dev.epicgames.com/documentation/unreal-engine/unreal-mcp-in-unreal-editor)
161
+
162
+ ## Sending Commands
163
+
164
+ Every command is a POST to `http://127.0.0.1:9210` with a JSON body:
165
+
166
+ Requests must use `Content-Type: application/json` and are limited to 16 MiB.
167
+ Browser requests with a non-loopback `Origin` are rejected, and both bundled
168
+ clients bypass environment HTTP proxies for their loopback connections.
169
+
170
+ ```json
171
+ {"command": "actors.list"}
172
+ ```
173
+
174
+ ```json
175
+ {
176
+ "command": "actors.spawn",
177
+ "params": {
178
+ "actor_class": "PointLight",
179
+ "location": [0, 0, 200]
180
+ }
181
+ }
182
+ ```
183
+
184
+ ```json
185
+ {
186
+ "command": "session.status",
187
+ "timeout_s": 120
188
+ }
189
+ ```
190
+
191
+ The complete response envelope includes the route that actually handled the request:
192
+
193
+ ```json
194
+ {
195
+ "ok": true,
196
+ "route": "toolset_registry",
197
+ "result": {}
198
+ }
199
+ ```
200
+
201
+ An MCP fallback also includes `fallback_reason`. Failures whose side effect cannot be determined include `outcome_unknown`.
202
+
203
+ ### Busy, Stalled, and Deadlines
204
+
205
+ The bridge serves one editor command at a time; other requests wait their turn. `status` and `GET /` never wait, and both report what the bridge is doing:
206
+
207
+ ```json
208
+ "activity": {
209
+ "editor_command": {"command": "verse.build", "state": "waiting_on_tool", "seconds": 41.2},
210
+ "dispatch_turn": {"command": "verse.build", "seconds": 41.3},
211
+ "waiting": 1,
212
+ "editor_tick_age_s": 0.03
213
+ }
214
+ ```
215
+
216
+ - `editor_command` is the command running on the editor thread (`state` is `running`, `waiting_on_tool` while a native tool works, or `outlived_caller` while a native tool keeps working after its caller timed out), and `dispatch_turn` is the request being served. `waiting` counts the requests queued behind it.
217
+ - `editor_tick_age_s` is the time since the editor last ran the bridge's tick. It grows while the editor's game thread is blocked. A large value with `editor_command` set means a bridge command is slow; with `editor_command` empty, something outside the bridge holds the editor, such as a modal dialog.
218
+ - Add `"if_busy": "reject"` to a request to fail fast instead of queueing. A busy bridge answers HTTP 409 with `busy` (the same `activity` object) and starts nothing. Busy includes editor work whose own caller already timed out. The Python client raises `BridgeBusy`.
219
+ - Without `timeout_s`, a request's deadline is 30 seconds, except for tools that routinely take longer: `session.start`, `session.push_changes` and `verse.build` get 600 seconds, `session.stop` and `session.start_game` 180, and `session.stop_game` 120. The same applies to `toolsets.call` and `mcp.call` naming those tools. The Python client waits at least as long.
220
+ - While an `exec` runs, `editor_command` also carries `exec`: `quiet_s` (seconds since its last sign of work), `budget_s` and `editor_calls`.
221
+
222
+ ### Late Results and Jobs
223
+
224
+ A command that outlives its deadline keeps running in the editor, and its result is kept instead of dropped, so you never have to repeat an import or spawn to learn whether it happened:
225
+
226
+ - A 504 deadline answer carries `job_id`. A native tool that outlives its caller (a push, start or build still working) answers with `job_id` too.
227
+ - Send `job.result` with `{"job_id": "...", "wait_s": 60}` for its state: `running` (with the current `activity`), `done` (`response` is the full reply the caller would have had), `not_started` (it was still queued and never ran) or `unknown` (the bridge stopped, or a native tool went silent). `wait_s` (up to 60) waits for a running job to end. `job.result` answers at once even while the editor is busy, and without `job_id` it lists the kept jobs.
228
+ - Name a job yourself by adding `"job_id"` (letters, digits, `_ . : -`, up to 64) to any request. Its result is then kept however you stop waiting, which helps a caller that gives up before the bridge's own deadline. The Python client sends it with `track_as=`.
229
+ - Results are kept for an hour after a job ends, at most 50 jobs and 1 MB per result; a bridge reload clears them.
230
+
231
+ ### Python Client
232
+
233
+ ```python
234
+ from bridge.client import UEFNBridge
235
+ # After pip installation, you can instead use:
236
+ # from uefn_agent_bridge import UEFNBridge
237
+
238
+ ue = UEFNBridge()
239
+ print(ue.status())
240
+
241
+ # Existing capability: direct embedded Python.
242
+ actors = ue.actors()
243
+ print(ue.last_route) # python
244
+
245
+ # UEFN-specific capability: local registry first, MCP only on a safe miss.
246
+ session = ue.run("session.status", timeout_s=120)
247
+ print(ue.last_route) # toolset_registry or mcp
248
+
249
+ # Generic approved tool lookup and call.
250
+ toolsets = ue.toolsets()
251
+ schema = ue.describe_toolset("ValkyrieFortniteToolset.SessionToolset")
252
+ status = ue.call_tool(
253
+ "ValkyrieFortniteToolset.SessionToolset",
254
+ "GetSessionStatus",
255
+ )
256
+
257
+ # Force MCP only when diagnosing the official transport.
258
+ mcp_status = ue.run("mcp.status", timeout_s=120)
259
+ ```
260
+
261
+ `UEFNBridge.run()` returns only the result. Use `UEFNBridge.request()` when you need the complete envelope, or inspect `ue.last_response` and `ue.last_route` after a call. `UEFNBridge.planned_route(command)` explains the initial route without contacting UEFN. A failed command raises `BridgeError`; its `envelope` holds the complete failure response (for example an `exec` traceback with `stdout`). Pass `if_busy="reject"` to `run()` or `request()` to get `BridgeBusy` instead of waiting behind another command.
262
+
263
+ ### curl
264
+
265
+ ```bash
266
+ curl -s -X POST http://127.0.0.1:9210 \
267
+ -H "Content-Type: application/json" \
268
+ -d '{"command":"actors.list"}' | python -m json.tool
269
+ ```
270
+
271
+ ```bash
272
+ curl -s -X POST http://127.0.0.1:9210 \
273
+ -H "Content-Type: application/json" \
274
+ -d '{"command":"session.status","timeout_s":120}' | python -m json.tool
275
+ ```
276
+
277
+ ### JavaScript or TypeScript
278
+
279
+ ```javascript
280
+ const response = await fetch("http://127.0.0.1:9210", {
281
+ method: "POST",
282
+ headers: { "Content-Type": "application/json" },
283
+ body: JSON.stringify({ command: "actors.list" })
284
+ });
285
+
286
+ const envelope = await response.json();
287
+ console.log(envelope.route, envelope.result);
288
+ ```
289
+
290
+ ## Direct Python Commands
291
+
292
+ These commands always use the embedded-Python route.
293
+
294
+ ### Actors
295
+
296
+ | Command | What it does | Key params |
297
+ |---|---|---|
298
+ | `actors.list` | List level actors | `class_filter` |
299
+ | `actors.selected` | List selected actors | None |
300
+ | `actors.spawn` | Spawn from a class or asset | `actor_class` or `asset_path`, `location`, `rotation`, `label` |
301
+ | `actors.duplicate` | Clone an actor | `source`, `location`, `rotation`, `label` |
302
+ | `actors.delete` | Delete actors; reports each target it could not delete under `failed` | `targets` |
303
+ | `actors.transform` | Set location, rotation, or scale | `target`, `location`, `rotation`, `scale` |
304
+ | `actors.properties` | Read named editable properties | `target`, `properties` |
305
+ | `actors.set_property` | Set an editor property | `target`, `property_name`, `value` |
306
+ | `actors.set_color` | Create and apply a persistent solid-color material | `target`, `color` |
307
+
308
+ Locations and scales are `[x, y, z]`. Rotations are `[pitch, yaw, roll]` in degrees, or an object such as `{"pitch": 0, "yaw": 90, "roll": 0}` (the shape responses return), for `actors.spawn`, `actors.duplicate`, `actors.transform` and `viewport.set_camera`.
309
+
310
+ ### Assets
311
+
312
+ | Command | What it does | Key params |
313
+ |---|---|---|
314
+ | `assets.search` | Search spawnable assets by default | `query` |
315
+ | `assets.list` | List a content directory | `directory`, `recursive` |
316
+ | `assets.info` | Inspect one asset | `path` |
317
+ | `assets.exists` | Check an asset path | `path` |
318
+ | `assets.rename` | Rename or move an asset | `old_path`, `new_path` |
319
+ | `assets.duplicate` | Copy an asset | `source`, `destination` |
320
+ | `assets.delete` | Delete an asset | `path` |
321
+ | `assets.save` | Save an asset | `path` |
322
+ | `assets.selected` | List Content Browser selection | None |
323
+ | `assets.import_task` | Import an external file | `source_file`, `destination_path` |
324
+
325
+ ### Placed Verse Devices
326
+
327
+ | Command | What it does | Key params |
328
+ |---|---|---|
329
+ | `verse.find_device` | Find placed Verse device actors | `query`, `class_filter` |
330
+ | `verse.export_t3d` | Export complete serialized device state | `target`, `filename` |
331
+ | `verse.get_properties` | Read generated subobject properties | `path`, `properties` |
332
+ | `verse.set_property` | Write supported generated subobject properties | `path`, `property_name`, `value`, `is_object_ref` |
333
+
334
+ These direct `verse.*` commands inspect placed generated device objects. They are separate from the creator-toolset `verse.*` file aliases below.
335
+
336
+ ### Level, Viewport, Materials, and System
337
+
338
+ | Command | What it does |
339
+ |---|---|
340
+ | `level.info` | Read current level information |
341
+ | `level.save` | Save the current level |
342
+ | `viewport.camera` | Read viewport location and rotation |
343
+ | `viewport.set_camera` | Move the viewport camera |
344
+ | `materials.create_instance` | Create a material instance with parameters |
345
+ | `status` | Return version, routing configuration, commands, and current activity |
346
+ | `exec` | Run embedded Python and return the variable named `result`. If the code raises, the command fails (`ok: false`) and still returns `result`, `stdout`, `stderr` and `traceback`; changes made before the exception stay. A quiet budget stops an endless loop (see below) |
347
+ | `batch.exec` | Run direct Python commands in one undo transaction and main-thread tick |
348
+ | `undo`, `redo` | Use the editor transaction history |
349
+ | `log`, `history` | Inspect bridge diagnostics |
350
+ | `job.result` | The kept result of a command that outlived its deadline (Late Results and Jobs above) |
351
+ | `reload`, `shutdown` | Manage the bridge process |
352
+ | `bridge.check_update` | Check now whether a newer bridge is published |
353
+ | `bridge.update` | Install the published bridge files, verified, then reload (Updates below) |
354
+ | `fix_throttle` | Disable background CPU throttling |
355
+ | `store.install` | Install the persistent helper store |
356
+
357
+ `exec` runs on the editor's game thread, so an endless loop would freeze UEFN. A quiet budget stops it instead: once the script's Python has run `budget_s` seconds (default 120) without a sign of work, the bridge raises `ExecInterrupted` in it and the command fails with `stopped_by_budget`. Signs of work reset the clock: any `unreal` API call returning, any native call of 1 s or more, a `print`, or `keep_alive()` (available to the script). Time inside an editor call or a long native call never counts, and the stop never lands while one runs, so a long import, build or save is never cut short. `ExecInterrupted` is not an `Exception`, so `except Exception` does not swallow it. Changes made before the stop stay. Send `budget_s` up to 86400 for a long pure-Python computation, or `0` to turn the budget off.
358
+
359
+ `batch.exec` accepts direct Python commands only. Toolset Registry and MCP calls are asynchronous and serialized, so friendly aliases and all `toolsets.*` or `mcp.*` commands are rejected inside a batch.
360
+
361
+ ## UEFN-Specific Friendly Aliases
362
+
363
+ Version 0.3.0 maps all 42 UEFN-specific tools shipped with UEFN v42 to stable bridge command names. Version 0.6.0 adds 29 `widgets.*` aliases for Widget Blueprints, their Verse fields and view bindings (see "Widget Blueprints and Verse UI" in [`RULES.md`](RULES.md), including a 42.40 bug where a blueprint made by `widgets.create_blueprint` never reflects its Verse fields). Version 0.7.0 follows UEFN 43.00's toolset renames (see "UEFN 43.00 toolset renames" below) and adds `verse.file_tree`, `session.verse_output` and three `devices.*classic*` aliases. Pass the official tool arguments directly as `params`.
364
+
365
+ | Domain | Friendly aliases |
366
+ |---|---|
367
+ | Python setup | `uefn.python_enabled`, `uefn.enable_python` |
368
+ | Verse files and build | `verse.write_file`, `verse.replace`, `verse.read_file`, `verse.move`, `verse.list_files`, `verse.grep`, `verse.delete`, `verse.create_directory`, `verse.copy`, `verse.file_tree`, `verse.build` |
369
+ | Play session | `session.stop`, `session.stop_game`, `session.start`, `session.start_game`, `session.push_changes`, `session.status`, `session.game_state`, `session.client_log`, `session.verse_output` |
370
+ | Creative devices | `devices.set_property`, `devices.remove_event_binding`, `devices.place`, `devices.list_event_bindings`, `devices.list_properties`, `devices.list_assets`, `devices.get_properties`, `devices.get_binding_options`, `devices.add_event_binding`, `devices.list_classic_options`, `devices.get_classic_option_values`, `devices.set_classic_option` |
371
+ | Scene Graph entities | `entities.set_transform`, `entities.set_component_property`, `entities.remove_component`, `entities.list_classes`, `entities.list_component_properties`, `entities.list_component_classes`, `entities.get_transform`, `entities.get_components`, `entities.get_component_property`, `entities.find`, `entities.delete`, `entities.create`, `entities.add_component` |
372
+ | Widget Blueprints | `widgets.list_blueprints`, `widgets.list_classes`, `widgets.class_info`, `widgets.describe`, `widgets.tree`, `widgets.named_slots`, `widgets.create_blueprint`, `widgets.compile`, `widgets.add`, `widgets.remove`, `widgets.rename`, `widgets.move`, `widgets.wrap`, `widgets.replace_with_template`, `widgets.set_named_slot_content` |
373
+ | Widget Verse fields | `widgets.verse_field_types`, `widgets.verse_fields`, `widgets.add_verse_field`, `widgets.duplicate_verse_field`, `widgets.edit_verse_field`, `widgets.remove_verse_field`, `widgets.bind_verse_field` |
374
+ | Widget view bindings (MVVM) | `widgets.view_bindings`, `widgets.view_events`, `widgets.bindable_properties`, `widgets.conversion_functions`, `widgets.create_view_binding`, `widgets.create_view_event_binding`, `widgets.remove_view_binding` |
375
+
376
+ ### UEFN 43.00 toolset renames
377
+
378
+ UEFN 43.00 (CL 59596594) renamed most of Epic's toolsets. The aliases name the 43.00 toolsets and fall back to the 42.40 names, so they work on either build:
379
+
380
+ | 42.40 | 43.00 |
381
+ |---|---|
382
+ | `ValkyrieToolset.VerseToolset` | `VerseToolset.VerseToolset` (adds `FileTree`) |
383
+ | `ValkyrieToolset.SessionToolset` | `ValkyrieFortniteToolset.SessionToolset` (adds `GetVerseOutput`) |
384
+ | `ValkyrieToolset.DeviceToolset` | `ValkyrieFortniteToolset.DeviceToolset` (adds three classic-device option tools) |
385
+ | `EditorToolset.LogsToolset` | `ConsoleToolset.LogsToolset` |
386
+ | `ValkyriePythonToolset.IsPythonEnabledInUEFN`, `EnablePythonInUEFN` | `IsPythonReadyForMainProject`, `EnablePythonForMainProject` |
387
+ | `editor_toolset.toolsets.*` (snake_case tools) | `EditorToolset.*` (PascalCase tools; `SceneTools` became `LevelToolset`) |
388
+
389
+ A `toolsets.call` that names a renamed Verse, Session, Device, Logs or Python tool by either build's name runs the one the running editor exposes, locally or through MCP. The `editor_toolset.toolsets.*` tools changed names and argument shapes, so call those by the running build's exact name. `widgets.describe` (`GetWidgetDescription`) exists only on 42.40.
390
+
391
+ Use `toolsets.describe` before the first unfamiliar call. Epic's JSON schema is the source of truth for parameter names, required fields, object reference shapes, and result values. When a schema requests an Unreal object reference, it commonly uses a JSON object such as `{"refPath":"/Path/To/Object"}`. Do not substitute that shape where a tool expects a plain string.
392
+
393
+ ## Generic Creator Toolsets
394
+
395
+ The bridge pins local routing to Epic's creator-exposed policy for each supported build: `UEFN-v42.40-CL-59247843` (29 toolsets, 386 tools) and `UEFN-v43.00-CL-59596594` (54 toolsets, 819 tools). A tool runs locally only when a pinned snapshot lists it and the running editor's registry exposes it. Epic's `ProgrammaticToolset` (`execute_tool_script`) and 43.00's `PythonScriptingTools` are left out on purpose; the bridge's own `exec` covers scripting. This prevents registered editor-internal toolsets or hidden tools from becoming available through the fast local path.
396
+
397
+ | Command | Purpose |
398
+ |---|---|
399
+ | `toolsets.list` | List locally approved toolsets, with MCP fallback if the registry is unavailable |
400
+ | `toolsets.describe` | Return the full schema for one toolset |
401
+ | `toolsets.call` | Call an exact `toolset_name` and `tool_name` locally first |
402
+
403
+ Example:
404
+
405
+ ```json
406
+ {
407
+ "command": "toolsets.call",
408
+ "params": {
409
+ "toolset_name": "ValkyrieFortniteToolset.SessionToolset",
410
+ "tool_name": "GetSessionStatus",
411
+ "arguments": {},
412
+ "allow_mcp_fallback": true
413
+ },
414
+ "timeout_s": 120
415
+ }
416
+ ```
417
+
418
+ Set `allow_mcp_fallback` to `false` when you explicitly require local execution. If UEFN adds a tool after the pinned policies, that tool is not executed through the local registry until the policy is reviewed. An exact generic call may still reach the official MCP server as a pre-dispatch capability fallback.
419
+
420
+ Tool names can collide across toolsets. Always provide the full toolset name and the exact tool name returned by its schema.
421
+
422
+ ## Forced MCP Commands
423
+
424
+ Use these only when you intentionally need the official HTTP path:
425
+
426
+ | Command | Purpose |
427
+ |---|---|
428
+ | `mcp.status` | Initialize the MCP session and report negotiation state |
429
+ | `mcp.list_toolsets` | List toolsets through MCP |
430
+ | `mcp.describe_toolset` | Fetch one toolset schema through MCP |
431
+ | `mcp.call` | Invoke one tool through MCP |
432
+ | `mcp.configure` | Change the loopback endpoint and reset the session |
433
+ | `mcp.reset` | Close and discard the cached MCP session |
434
+
435
+ The MCP client uses Streamable HTTP, negotiates one session lazily, serializes requests through a single mutex, and caches discovery results per session. It accepts JSON and server-sent event responses. It does not use stdio, WebSocket, browser control, or UI automation.
436
+
437
+ ## Mutation and Session Safety
438
+
439
+ - Treat `outcome_unknown: true` as a hard stop. Inspect current editor state before deciding whether another operation is needed.
440
+ - Do not automatically retry file writes, builds, entity or device mutations, event bindings, or session controls.
441
+ - Read-only discovery can be refreshed deliberately with `refresh: true`.
442
+ - Toolset schemas are cached locally. Use `toolsets.list` or `toolsets.describe` with `refresh: true` after a UEFN tool refresh.
443
+ - MCP discovery is cached for its session. Use `mcp.reset` after restarting Epic's server or changing its tool configuration.
444
+ - MCP requests are serialized, and Toolset Registry dispatch runs on UEFN's main editor thread. Do not issue overlapping session or mutation calls.
445
+ - If a session result reports `StillRunning`, poll `session.status` before issuing another session mutation.
446
+ - `toolsets.call` and `mcp.call` refuse `AssetTools.save_assets` with an empty or missing `asset_paths` list, which would save every unsaved asset in the project. Name the assets you changed, or set `"allow_save_all": true` on purpose.
447
+
448
+ Epic's UEFN session tools operate Play in Client (PIC) sessions. Do not assume Play in Editor (PIE) behavior or state.
449
+
450
+ ## Coordinates and Scene Graph
451
+
452
+ UEFN currently has two coordinate naming conventions in related APIs:
453
+
454
+ - Unreal Python and the creator toolset JSON schemas use X, Y, and Z.
455
+ - UEFN Scene Graph and `/Verse.org/SpatialMath` use Forward, Left, and Up (LUF).
456
+
457
+ For `entities.*` calls, send the X, Y, and Z field names required by the tool schema, even though the affected Scene Graph transform is represented as LUF in Verse. Do not rename fields or swap axes by intuition. The older `/UnrealEngine.com/Temporary/SpatialMath` types are also distinct from `/Verse.org/SpatialMath`; use the documented Verse conversion functions when crossing between them.
458
+
459
+ ## Editing Placed Verse Devices
460
+
461
+ Find a placed `VerseDevice_C` actor by internal name, then export its serialized state for programmatic inspection:
462
+
463
+ ```json
464
+ {"command":"verse.find_device","params":{"query":"game manager"}}
465
+ ```
466
+
467
+ ```json
468
+ {
469
+ "command": "verse.export_t3d",
470
+ "params": {
471
+ "target": "VerseDevice_C_UAID_ABC123"
472
+ },
473
+ "timeout_s": 120
474
+ }
475
+ ```
476
+
477
+ Plain property access works for numbers, object references, and reference arrays. Verse string, enum, and option values require the editor text-import roundtrip documented in [`RULES.md`](RULES.md). Writes mutate the open level, so get user approval before editing or saving.
478
+
479
+ ## Updates
480
+
481
+ A few seconds after it starts, the bridge reads the published `bridge/release.json` from this repository's `main` branch. If that version is newer, the Output Log says so once, and `status` and `GET /` carry the result:
482
+
483
+ ```json
484
+ "update": {"current": "0.5.1", "latest": "0.5.2", "available": true, "checked_at": "2026-10-13T04:00:00Z", "error": null, "install": "copy"}
485
+ ```
486
+
487
+ - **Install it:** send `{"command": "bridge.update"}`. The bridge downloads every file the manifest lists, checks each file's SHA-256 against it, and changes nothing unless all of them match. Each install copies the files it replaces to its own `bridge/.bridge-backup/<installed version>-<UTC time>/` folder, swaps the new ones in (rolling back if a swap fails), and reloads itself once no command is running or waiting on a native tool. Pass `"reload": false` to reload later; a later `bridge.update` or `reload` picks up the installed files. It never installs an older version unless you pass `"allow_downgrade": true`.
488
+ - **Git checkouts are left to git.** When the bridge runs from a clone of this repository, `install` is `"git"` and `bridge.update` refuses; run `git pull` there instead.
489
+ - **Automatic updates are off by default.** The bridge usually lives inside a project's `Content/Python/`, so an update changes project files that revision control will pick up. To install updates automatically at startup, add `bridge/settings.json` with `{"auto_update": true}`. To stop the startup check, use `{"check_for_updates": false}`. The environment variables `UEFN_BRIDGE_AUTO_UPDATE` and `UEFN_BRIDGE_UPDATE_CHECK` (`1` or `0`) override the file.
490
+ - The check is one HTTPS request to `raw.githubusercontent.com` per bridge start, with no identifying data beyond the request itself. A failed check is reported in `update.error` and never stops the bridge.
491
+ - Bridges older than 0.5.0 do not check. Update those by copying the `bridge/` folder once.
492
+
493
+ ## How It Works
494
+
495
+ 1. A local HTTP server listens on `127.0.0.1:9210` or the next free bridge port.
496
+ 2. Direct commands that touch Unreal are queued to UEFN's main editor thread and executed on a Slate tick.
497
+ 3. Creator-toolset calls are dispatched through `unreal.ToolsetRegistry` on the editor thread and polled on later ticks, without blocking UEFN in a busy loop.
498
+ 4. A proven pre-dispatch capability miss is handed to the official loopback MCP client on the HTTP worker thread.
499
+ 5. Results return in one bridge envelope with the actual route and safety metadata.
500
+
501
+ The local toolset schema cache avoids repeated discovery. MCP maintains its own session-scoped discovery caches and serializes its HTTP requests. Registry dispatch stays on UEFN's main editor thread. Callers should not overlap Epic tool operations.
502
+
503
+ On startup, the bridge disables UEFN's background CPU throttle so commands continue while the editor is not focused.
504
+
505
+ ## Repository Layout
506
+
507
+ ```text
508
+ bridge/
509
+ server.py HTTP bridge and hybrid router, runs inside UEFN
510
+ client.py Local Python client
511
+ routes.py Direct-command and 42-alias routing metadata
512
+ uefn_tool_policy.py Exact UEFN 42.40 and 43.00 local tool allowlists
513
+ mcp_client.py Stdlib-only official UEFN MCP client
514
+ startup.py Optional UEFN init_unreal.py auto-start helper
515
+ updates.py Update check and verified install
516
+ release.json Published version and file digests (tools/write_release_manifest.py)
517
+
518
+ uefn_agent_bridge/
519
+ __init__.py Importable client package and version
520
+ cli.py Installer, status, and call command
521
+
522
+ pyproject.toml Setuptools packaging and console entry point
523
+
524
+ examples/
525
+ hybrid_routing.py Read-only routing and discovery example
526
+ verse_devices.py Placed Verse device workflow
527
+
528
+ tests/ Unit tests that run outside UEFN with fakes
529
+ tools/ API introspection, stub generation, release manifest
530
+ RULES.md LLM context and operating rules
531
+ ```
532
+
533
+ ## IDE Autocomplete
534
+
535
+ 1. In UEFN, choose `Tools > Execute Python Script` and run `tools/generate_stubs.py`.
536
+ 2. Find `unreal.pyi` under your project's `Saved` directory.
537
+ 3. Add that directory to your Python analysis paths.
538
+
539
+ ```json
540
+ {
541
+ "python.analysis.extraPaths": ["path/to/Saved"]
542
+ }
543
+ ```
544
+
545
+ ## Good to Know
546
+
547
+ - UEFN is not standard Unreal Engine. Many standard UE5 Python APIs are stripped or changed. See [`RULES.md`](RULES.md) for tested patterns.
548
+ - Epic documents editor hitching or hanging during MCP calls. Prefer direct Python and the in-process registry.
549
+ - Any request can include a top-level `timeout_s` up to 600 seconds; without one, slow session and build tools get longer defaults (Busy, Stalled, and Deadlines above). A timeout after dispatch is not proof that the operation failed.
550
+ - If background throttling returns, run `fix_throttle` or focus UEFN.
551
+ - Start manually with `bridge/server.py`, or copy `bridge/startup.py` to `<Project>/Content/Python/init_unreal.py` alongside the `bridge/` package for project auto-start.
552
+ - `reload` re-reads `server.py` and its sibling modules (`routes.py`, `uefn_tool_policy.py`, `mcp_client.py`, `updates.py`) from disk, so a changed sibling module no longer needs a UEFN restart.
553
+ - The bridge only connects to loopback MCP endpoints and has no remote-access mode.
554
+ - UEFN 42.40 asks two new questions that block the editor: an "Unreal Editor Security" trust prompt when a project opens, and a toast asking to enable Python Editor Scripting locally. The bridge cannot start until Python is enabled; Epic's MCP tool `ValkyrieToolset.ValkyriePythonToolset.EnablePythonInUEFN` (`EnablePythonForMainProject` on 43.00) turns it on without the GUI.
555
+
556
+ ## Contributing
557
+
558
+ See [CONTRIBUTING.md](CONTRIBUTING.md) and [good first issues](https://github.com/Valid/uefn-agent-bridge/labels/good%20first%20issue) to get started.
559
+
560
+ To add a direct Python command:
561
+
562
+ 1. Add a function with `@command("category.name")` in `bridge/server.py`.
563
+ 2. Add the command to `PYTHON_COMMANDS` in `bridge/routes.py`.
564
+ 3. Add tests and a working example.
565
+ 4. Update `RULES.md` and this README.
566
+ 5. After changing any file in `bridge/` (or `VERSION` in `server.py`), run `python tools/write_release_manifest.py`. `tests/test_updates.py` fails until the manifest matches, because installed bridges verify their downloads against it.
567
+
568
+ When Epic changes its creator toolsets, review the official exposed schemas before updating `bridge/uefn_tool_policy.py`. Do not widen the local policy from registered toolsets alone.
569
+
570
+ ## Support
571
+
572
+ - [GitHub Issues](https://github.com/Valid/uefn-agent-bridge/issues)
573
+ - [Discord](https://discord.gg/fchq)
574
+
575
+ ## License
576
+
577
+ MIT