restore_snapshot
Restore the 3D geometry (current_shape and show() registry) to a previously saved snapshot. Python variables remain unchanged, only the model state reverts.
Instructions
Restore geometric state from a previously saved snapshot (current_shape and the show() registry). The Python variable namespace is NOT restored — execute() calls made after the snapshot are still in scope, but current_shape and all show() objects revert to what they were at snapshot time. Raises an error if the snapshot name does not exist.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/build123d_mcp/session.py:228-234 (handler)Core implementation of restore_snapshot in the Session class: validates snapshot exists (raises KeyError if not), then restores current_shape and all objects from the saved snapshot.
def restore_snapshot(self, name: str) -> None: if name not in self.snapshots: raise KeyError(f"No snapshot named '{name}'. Available: {list(self.snapshots.keys())}") snap = self.snapshots[name] self.current_shape = snap["current_shape"] self.objects.clear() self.objects.update(snap["objects"]) - src/build123d_mcp/worker.py:88-95 (handler)Worker dispatch for 'restore_snapshot' op: calls session.restore_snapshot(name), catches KeyError, returns a summary of restored geometry.
if op == "restore_snapshot": name = args["name"] try: session.restore_snapshot(name) except KeyError as e: return f"Error: {e}" restored = (["current_shape"] if session.current_shape is not None else []) + list(session.objects.keys()) return f"Snapshot '{name}' restored. Active geometry: {', '.join(restored) if restored else 'none'}." - src/build123d_mcp/server.py:102-108 (registration)MCP tool registration of restore_snapshot via @mcp.tool() decorator. Defines the tool name, docstring, and delegates to WorkerSession.restore_snapshot.
@mcp.tool() def restore_snapshot(name: str) -> str: """Restore geometric state from a previously saved snapshot (current_shape and the show() registry). The Python variable namespace is NOT restored — execute() calls made after the snapshot are still in scope, but current_shape and all show() objects revert to what they were at snapshot time. Raises an error if the snapshot name does not exist.""" return _session.restore_snapshot(name) - src/build123d_mcp/server.py:102-108 (schema)Schema/type definition: tool accepts a single 'name: str' parameter.
@mcp.tool() def restore_snapshot(name: str) -> str: """Restore geometric state from a previously saved snapshot (current_shape and the show() registry). The Python variable namespace is NOT restored — execute() calls made after the snapshot are still in scope, but current_shape and all show() objects revert to what they were at snapshot time. Raises an error if the snapshot name does not exist.""" return _session.restore_snapshot(name) - src/build123d_mcp/worker.py:275-277 (helper)WorkerSession proxy method that sends 'restore_snapshot' request to worker subprocess via IPC pipe with short timeout.
def restore_snapshot(self, name: str) -> str: return self._call("restore_snapshot", {"name": name}, self._SHORT_TIMEOUT)