list_objects
List all named shapes in the current session with volume, face, edge, and vertex counts to audit state without guessing.
Instructions
List all named shapes registered via show(), each with volume (mm³), face, edge, and vertex counts. Call this to audit session state without guessing what show() has been called on.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- Core handler that iterates session.objects, collecting name, volume, faces, edges, vertices for each shape, returning JSON.
def list_objects(session) -> str: if not session.objects: return "No named objects in session. Use show(shape, name) to register shapes." results = [] for name, shape in session.objects.items(): try: results.append({ "name": name, "volume": round(shape.volume, 4), "faces": len(shape.faces()), "edges": len(shape.edges()), "vertices": len(shape.vertices()), }) except Exception as e: results.append({"name": name, "error": str(e)}) return json.dumps(results, indent=2) - src/build123d_mcp/server.py:88-91 (registration)MCP tool registration of list_objects via @mcp.tool() decorator, calling WorkerSession.list_objects().
@mcp.tool() def list_objects() -> str: """List all named shapes registered via show(), each with volume (mm³), face, edge, and vertex counts. Call this to audit session state without guessing what show() has been called on.""" return _session.list_objects() - src/build123d_mcp/worker.py:269-270 (helper)WorkerSession method that sends a 'list_objects' RPC call to the worker subprocess.
def list_objects(self) -> str: return self._call("list_objects", {}, self._SHORT_TIMEOUT) - src/build123d_mcp/worker.py:78-80 (helper)Worker subprocess dispatch that imports and calls the list_objects handler when op is 'list_objects'.
if op == "list_objects": from build123d_mcp.tools.list_objects import list_objects return list_objects(session) - tests/test_tools.py:755-760 (schema)Tests confirming output shape: name, volume, faces, edges, vertices fields.
def test_list_objects_includes_geometry(session): execute_code(session, "show(Box(10, 10, 10), 'cube')") data = json.loads(list_objects(session)) cube = next(item for item in data if item["name"] == "cube") assert abs(cube["volume"] - 1000) < 0.1 assert cube["faces"] == 6