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
feat: add snapshot_publish recipe and verify with integration tests
A. Sam Mohammad812a6c378ecf
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/modules/recipe_runner/recipes/snapshot_publish.yaml b/packages/mcp-server-revit/src/revit_mcp_server/modules/recipe_runner/recipes/snapshot_publish.yamlindex 626a37b..a16bede 100644--- a/packages/mcp-server-revit/src/revit_mcp_server/modules/recipe_runner/recipes/snapshot_publish.yaml+++ b/packages/mcp-server-revit/src/revit_mcp_server/modules/recipe_runner/recipes/snapshot_publish.yaml@@ -1,6 +1,17 @@+# NOTE: the template engine (recipe_runner/module.py:_render) only substitutes+# {{...}} inside string values and always stringifies the looked-up value - it+# cannot thread a whole captured object (e.g. the full snapshot) into another+# step's argument. speckle_send_object's "data" must therefore be a literal+# dict of scalar template strings (a small summary), not "{{snapshot_result}}"+# whole. speckle_send_object is also the tool to use here, not+# speckle_publish_version: send_object uploads data AND creates the Speckle+# version/commit in one call (see providers/cloud.py's+# _tool_speckle_send_object); publish_version is the lower-level API for when+# you already have an object_id from elsewhere. project_id/model_name/data+# must be supplied by the caller via run_recipe's `args`.id: snapshot_publishname: Snapshot → Speckle Publish-description: "Take a BIM snapshot and publish it as a Speckle version."+description: "Take a BIM snapshot and publish a summary of it as a Speckle version. Requires project_id and model_name as recipe args."steps:- id: take_snapshottool: snapshot_take@@ -8,9 +19,13 @@ steps:capture_as: snapshot_result- id: publish_speckle- tool: speckle_publish_version+ tool: speckle_send_objectargs:- snapshot_id: "{{snapshot_result.snapshot_id}}"- stream_id: "{{stream_id}}"+ project_id: "{{project_id}}"+ model_name: "{{model_name}}"+ data:+ snapshot_id: "{{snapshot_result.snapshot_id}}"+ taken_at: "{{snapshot_result.taken_at}}"+ elements_count: "{{snapshot_result.elements_count}}"message: "Auto-publish from recipe at {{snapshot_result.taken_at}}"capture_as: speckle_resultdiff --git a/packages/mcp-server-revit/tests/test_recipe_runner.py b/packages/mcp-server-revit/tests/test_recipe_runner.pyindex a30b2ec..bcd94f5 100644--- a/packages/mcp-server-revit/tests/test_recipe_runner.py+++ b/packages/mcp-server-revit/tests/test_recipe_runner.py@@ -210,6 +210,47 @@ def test_nonexistent_recipe_raises(module, workspace):module.run_recipe(recipe_id="does_not_exist", workspace=workspace)+def test_snapshot_publish_calls_send_object_not_publish_version(module, workspace):+ """snapshot_publish.yaml previously called speckle_publish_version with+ snapshot_id/stream_id args that don't exist on that tool's schema (real+ fields: project_id/model_id/object_id/message) and tried to template the+ whole captured snapshot into a string, which the engine can only+ stringify, not pass as an object. Fixed to call speckle_send_object (the+ tool that actually sends data AND creates the version in one call) with+ a literal dict of scalar-templated fields."""+ call_log = []++ def mock_executor(tool_name: str, args: dict) -> dict:+ call_log.append((tool_name, args))+ if tool_name == "snapshot_take":+ return {"snapshot_id": "snap-042", "taken_at": "2026-01-01T00:00:00Z", "elements_count": 6}+ if tool_name == "speckle_send_object":+ return {"result": "ok", "version_id": "ver-1"}+ return {}++ result = module.run_recipe(+ recipe_id="snapshot_publish",+ args={"project_id": "proj-1", "model_name": "main"},+ dry_run=False,+ workspace=workspace,+ tool_executor=mock_executor,+ )++ assert result["status"] == "completed"+ tool_names = [name for name, _ in call_log]+ assert tool_names == ["snapshot_take", "speckle_send_object"]++ _, publish_args = call_log[1]+ assert publish_args["project_id"] == "proj-1"+ assert publish_args["model_name"] == "main"+ assert publish_args["data"] == {+ "snapshot_id": "snap-042",+ "taken_at": "2026-01-01T00:00:00Z",+ "elements_count": "6", # stringified: template substitution always renders to str+ }+ assert "snap-042" not in "".join(k for k in publish_args if isinstance(k, str)) # sanity: no stray keys++@pytest.mark.anyioasync def test_provider_executes_recipe_steps(tmp_path):registry = ProviderRegistry()