Open-source Revit MCP server: let Claude and other AI assistants read and edit BIM models, with human approval on every change.
Python aecai-agentsautodeskautomationbimclaudeifcmcpmcp-servermodel-context-protocolnavisworksrevitrevit-addinrevit-apirhino
docs: update handover - panel is wired, hub process lifecycle is the next gap
A. Sam Mohammadcc944893e1f4
diff --git a/docs/product/NEXT_AGENT_HANDOVER.md b/docs/product/NEXT_AGENT_HANDOVER.mdindex 5fdbeb4..0563727 100644--- a/docs/product/NEXT_AGENT_HANDOVER.md+++ b/docs/product/NEXT_AGENT_HANDOVER.md@@ -1,47 +1,39 @@# Next Agent Handover-**Latest session:** 2026-07-08 (second session same day) — verification + bug-fix pass on top of a large implementation batch. Code changed, tests added, all committed to `development`. Nothing deleted.+**Latest session:** 2026-07-08 (third session same day) — implemented the panel→hub wiring that the previous session identified as fake. Code changed, tests added, both C# targets build, all committed to `development`. Nothing deleted.-**IMPORTANT:** the previous version of this file (written by the planning-only session earlier the same day) is obsolete — a separate implementation pass landed ~21 commits (`5ad86e7`…`5c9342d`) claiming Phases 0–17 complete *before this session started*. **Do not trust commit messages as proof of working code in this repo without independent verification** — several of those commits overstated what they actually did (see "What I found was wrong" below). Trust `git log` + reading the diffs, not prose summaries, including this one after enough time has passed.+**Read `git log` before trusting any summary here, including this one.** Two things have already been true today: a batch of commits claimed Phases 0–17 complete before anyone checked, and this file's own previous version called the panel "real plumbing around fake data" — both turned out to need correction on inspection, not blind trust.## What I did this session-1. Spawned an Explore agent to verify the claimed Phase 0–17 work against actual code/tests/builds (not commit messages). Full report is in the conversation history; key findings below.-2. Fixed a real bug: `ApprovalGate.rollback_plan` was `def` (sync) calling an `async def execute_fn` without `await` — the coroutine was created and discarded, so **every rollback in production silently did nothing**. Fixed, made the method `async`, rewrote the test that had masked it (it used a sync mock, production always passes an async one).-3. Closed the actual W5 gap: `parameter_manager.plan_set_params`/`import_params_csv` produced a preview but **there was no way to ever apply it** — no execute path existed. Added `execute_plan` to `ApprovalProvider` (report-and-continue on partial failure) and made the parameter_manager module emit `plan_actions`-ready `actions` lists. Added `tests/test_approval_provider.py` proving the full plan→approve→execute→rollback round trip against a real `ProviderRegistry`.-4. Closed the real R12 gap: Rhino and Speckle/APS mutating tools (`rhino_create_box`, `rhino_run_python`, `speckle_publish_version`, `autodesk_data_create_topic`, ...) had `is_mutating=False` (the `ProviderTool` default) because **nothing ever called mutation-metadata enrichment for those providers** — they bypassed the ApprovalGate entirely regardless of `approval_mode`. Added a shared `enrich_mutation_metadata()` helper (`providers/base.py`), wired it into Rhino and the cloud providers, and manually audited every existing `revit.py`/`navisworks.py` tool name against its own verb list, finding 4 more real gaps in code the audit had called "REAL/WORKING" (`revit_populate_titleblock`, `revit_tag_all_in_view`, `revit_ungroup`, `navisworks_run_clash_test`) — fixed those too.-5. Found the contract test meant to catch exactly this (`test_provider_contract.py`) was itself broken: it checked `getattr(tool, "mutating", None)` but the real field is `is_mutating` — always `None`, and the only test using the result just *printed* a report, asserting nothing. Replaced with a real assertion-based regression test (`test_verb_matched_tools_are_flagged_mutating`), and added `navisworks` to the provider-contract parametrization (it existed but was never covered).-6. `tests/test_rhino_provider.py` (13 tests) was written for an entirely different, abandoned Rhino.Compute-based design (HTTPS, API-key auth, `.gh`/`.3dm` uploads) — the provider was rewritten to the current HTTP-bridge-to-C#-add-in design without ever updating its tests, so **CI has been red since at least commit `949d2e5`**. Rewrote the file from scratch against the real provider.-7. Fixed all 74 `ruff` errors (65 auto-fixable unused imports, 9 by hand — 2 were genuinely dead code, not masked bugs, one confirmed by tracing `semantic/engine.py:reconcile_delta`). Wired `ruff check` into `.github/workflows/ci.yml` (it was never actually run despite being part of the stated DoD). Regenerated `docs/tools-generated.md`, which picked up an entire batch of module tools (parameter_manager, qaqc_checker, report_generator, recipe_runner, familytype_mapper) that were registered but had never made it into the catalog.-8. Found and fixed one more real bug while investigating why `legacy/tools/` (renamed from `tools/`, implying retirement) is still imported live by `providers/revit.py`: in bridge mode, a legacy handler's `WorkspaceViolation` (path-outside-sandbox) was caught and only logged as a warning, with the call still forwarded to the live bridge. Now re-raised always; other legacy-schema validation errors stay advisory (schema drift risk, not a security boundary). Note: in the *current* tool set this had no live exploitable case, since `RevitProvider`'s own universal `_assert_paths_in_workspace` pre-check already covers every path-key name the legacy handlers use — but it's real defense-in-depth for any future handler that doesn't, and "never swallow a security exception" should hold regardless.-9. Verified (not just trusted) that `dotnet build -c Release -p:RevitVersion=2024` for `revit-bridge-addin` really is 0 errors / 84 warnings, confirming that specific Phase-3 claim.+Closed the exact gap the previous handover named: the panel could receive clicks but never called a real hub tool.-Every fix above: implemented → tested (full suite run, not just the new test) → committed individually. Final state this session: **207 passed, 4 skipped, 0 failed. `ruff check`: all checks passed.**+1. **Designed the transport.** MCP is stdio-only; a WebView2 page can't launch/talk to it. `PLUGIN_APP_ARCHITECTURE.md` §2 already said the panel should reach "the hub via localhost" — so I added `panel_server.py`, a loopback-only (127.0.0.1) HTTP server exposing `GET /health` and `POST /execute {tool, arguments}`, running the exact same `ProviderRegistry` + `ApprovalGate` checks as the stdio server. New console script: `aec-model-bridge-panel-server`.+2. **Refactored for reuse, then fixed what the refactor exposed.** Moved provider-registry construction out of `mcp_server.py` into `registry_factory.py` so the new server doesn't duplicate ~60 lines. Along the way found that `revit_mcp_server/__init__.py` eagerly imported `mcp_server` (building a full registry — Speckle/APS OAuth, a Rhino bridge health probe, ModuleRegistry filesystem discovery — as a pure import side effect) purely to re-export an unused `run_server` alias nothing in the codebase actually calls. Made it lazy (`__getattr__`); confirmed by a manual smoke test that only one registry gets built now, not two.+3. **Tested the hub side for real** (`tests/test_panel_server.py`, 7 tests): health, executing a real read-only tool end-to-end, unknown-tool/missing-field/unknown-path error shapes, the ApprovalGate correctly rejecting a mutating call with no plan, and a full `plan_actions → approve_plan → execute_plan` round trip driven purely over HTTP — the same shape the C# side uses.+4. **Wired the C# side.** Added `HubClient.cs` (POSTs to the shim, parses the `{ok, result|error}` envelope) and rewrote `BridgePanel.xaml.cs`'s `OnWebMessageReceived` to parse the panel's message type and dispatch: `qaqc.runHealthCheck → qaqc_checker_run_check`, `plans.refresh → list_pending_plans`, `plan.approve/plan.reject → approve_plan/reject_plan` (then a plans refresh), `reports.exportExcel → report_generator_export_excel`. Hub-down or tool errors post a `tool.error` message instead of silently doing nothing. Needed one new assembly reference (`System.Net.Http`, net48 only — not auto-referenced there unlike net8/net10).+5. **Removed the fixture data.** `panel/app.js`'s hardcoded `plan_demo_01`/`f-001`/`r-001` arrays are gone (state starts empty); added `findings.updated`/`plans.updated`/`reports.updated`/`tool.error` handlers that map the hub's raw result shapes (e.g. QA/QC's `{rule_id, severity, element_uid, message}`) into what the render functions expect.+6. Verified both C# targets build clean (net48: 0 errors/85 warnings; net8/Revit 2025: 0 errors) and the full Python suite passes (214 passed, 4 skipped, ruff clean) after every commit.-## What I found was wrong despite "done" commit messages+**Honest limit of what's proven:** the JSON contract between `HubClient.cs` and `panel_server.py` is verified two ways — `test_panel_server.py` exercises the exact request/response shapes, and both C# targets compile against the real types — but nobody has run this against a live Revit process with WebView2 actually rendering the page and a human clicking the button. That's the boundary of what's provable in this environment; say so plainly if asked whether the panel "works."-- `legacy/server.py` + `legacy/tools/` + `legacy/schemas.py` are **not actually retired** — `providers/revit.py` still imports and calls `legacy.tools.TOOL_HANDLERS` live, in both bridge and mock mode. The rename to `legacy/` is cosmetic; don't delete this directory without first removing that import.-- Commit `d5e6aca` says "register Navisworks/PowerBI" — Navisworks is genuinely registered; **PowerBI is not registered anywhere** (matches decision D-009, "file lane first", so arguably intentional, but the commit message overstates it).-- `packages/navisworks-bridge-addin` **cannot be built in this environment**: `dotnet build` fails with 20 `CS0246` errors (no Navisworks API installed) and — unlike Revit's Nice3point NuGet fallback — there is no NuGet fallback wired up (`NavisworksBridge.csproj:42-44` has an empty comment where one should be). CI doesn't attempt to build it either. This needs either a NuGet package for the Navisworks API or acceptance that this project can only be verified on a machine with Navisworks installed.-- The WebView2 dockable panel (Phase 16) is real plumbing wrapped around **fake data**: `panel/app.js` has hardcoded fixture plans/findings/reports (`plan_demo_01`, `f-001`, ...) that are never replaced with real hub calls, and the C# message bridge (`BridgePanel.xaml.cs:OnWebMessageReceived`) ignores incoming message content and only ever posts host status back — there is **no HTTP client anywhere in the add-in calling the Python hub's tools** (`plan_actions`, `qaqc_run_health_check`, etc.). The panel *looks* done; it does not function end-to-end. I did not fix this — it's a real feature-level task, not a bug fix, and deserves its own session (see below).+## The gap this session did NOT close (the real next task)-## What I did NOT change--- Did not touch the panel/hub wiring gap above (scope: a genuine implementation task, not a fix).-- Did not attempt to build `navisworks-bridge-addin` or `rhino-bridge-addin`/`powerbi-bridge-tool` further than what the earlier verification pass already did.-- Did not remove `legacy/tools` — it's load-bearing, not dead code; removing it needs a real migration, not a delete.-- Did not re-verify Phases 5–15 beyond what the Explore agent's verification pass covered (module registry, semantic engine, individual modules were reported REAL/WORKING with file:line evidence — I did not re-derive that independently, only acted on the two gaps it surfaced in Phase 4 and the panel gap in Phase 16).+**Nothing starts `panel_server.py`.** The C# side now calls `http://127.0.0.1:8787/execute` assuming a hub is listening there, but no code launches it — a user would have to manually run `aec-model-bridge-panel-server` in a terminal before opening the panel in Revit. Wiring the button-to-tool path was necessary but not sufficient; the hub process lifecycle is the remaining piece. Concretely, the add-in needs to (most likely in `App.cs`'s `OnStartup`, alongside where it already starts `BridgeServer`):-## Recommended next task+1. Check if something is already listening on the panel port (`GET /health`); if not, launch `aec-model-bridge-panel-server` as a child process (`Process.Start`, needs the right Python interpreter/venv resolution — check how `scripts/build-addin.ps1` or the install docs currently expect Python to be provisioned, since D-010 in `DECISIONS_AND_RISKS.md` decided on a bundled runtime for the installer but that isn't built yet).+2. Decide shutdown behavior: kill the child process on `OnShutdown`, or leave it running as a background service? (Leaving it running means panel reopens are instant; killing it is cleaner but slower to reopen.)+3. Surface hub-launch failures to the user somewhere sane — probably a `tool.error`-style panel message on first failed `/health` check, reusing the pattern already in `BridgePanel.xaml.cs`.-**Wire the dockable panel to the real hub**, in this order:+Secondary, smaller, independently valuable if picked up first: decide and implement the Navisworks build story (`packages/navisworks-bridge-addin` still can't build in any environment without a paid Navisworks install and no NuGet fallback exists — needs Sam's input, see D-011/D-012).-1. Add an `HttpClient`-based (or reuse `BridgeClient`-style) call path in the C# add-in from `BridgePanel.xaml.cs`'s `OnWebMessageReceived` to the actual MCP hub tools — this requires deciding how the WebView2 panel reaches a Python process (likely: hub exposes a minimal local HTTP shim for panel use, since MCP itself is stdio-only; this is a real architecture decision, not obvious — check `PLUGIN_APP_ARCHITECTURE.md` §2 for the intended shape before inventing one).-2. Replace `panel/app.js`'s hardcoded fixture state with real data from that path.-3. Add an end-to-end test (or at minimum a scripted manual verification) that clicking "Run Health Check" in the panel actually calls `qaqc_run_health_check` and renders real findings.+## What I did NOT change-Secondary, smaller, independently valuable if picked up first: decide and implement the Navisworks build story (D-011/D-012-adjacent — needs Sam's input on whether a NuGet fallback exists or whether this is accepted as "only buildable with Navisworks installed").+- Did not implement hub-process launching (above — this is the real next task).+- Did not wire `chat.message`, `settings.save`, `reports.open`, or `reports.refresh` — no corresponding hub tool exists yet for the first and last, and the middle two are local-only concerns. Left exactly as before (post to host, no round trip).+- Did not touch `navisworks-bridge-addin`'s build story.+- Did not re-verify Phases 5–15 beyond what earlier verification already covered.## Exact next prompt-> Read docs/product/NEXT_AGENT_HANDOVER.md. The dockable panel (packages/revit-bridge-addin/src/UI/BridgePanel.xaml.cs + panel/app.js) is real plumbing around fake data — the message bridge never reaches the Python hub's MCP tools. Design and implement the real connection (check docs/product/PLUGIN_APP_ARCHITECTURE.md §2 for the intended shape first, since MCP is stdio-only and the panel needs some other local transport), replace the hardcoded fixture state in app.js with real calls, and add a test or scripted verification proving one real workflow (e.g. run_health_check) works end-to-end from the panel. Test and commit incrementally, one working piece at a time, no Co-Authored-By trailers.+> Read docs/product/NEXT_AGENT_HANDOVER.md. The panel now calls real hub tools via panel_server.py's HTTP shim, but nothing launches that Python process - a user would have to start `aec-model-bridge-panel-server` manually. Implement hub process lifecycle management in the C# add-in (likely App.cs's OnStartup/OnShutdown, alongside where BridgeServer already starts): check if the panel port is already alive via /health, launch the process if not, decide and implement a shutdown policy, and surface launch failures to the panel via the existing tool.error message pattern. Check how Python is expected to be provisioned today (build/install docs, D-010 in DECISIONS_AND_RISKS.md) before assuming a bare `python`/pipx invocation will work on a clean machine. Test what's testable, build both C# targets, commit incrementally, no Co-Authored-By trailers.