get_parts_list
Retrieve a comprehensive list of parts from the FreeCAD parts library addon to streamline 3D design and assembly processes within the FreeCAD MCP server.
Instructions
Get the list of parts in the parts library addon.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/freecad_mcp/server.py:550-564 (handler)MCP tool handler for 'get_parts_list' that retrieves the list of available parts from the FreeCAD parts library via the RPC connection and returns it as JSON.@mcp.tool() def get_parts_list(ctx: Context) -> list[str]: """Get the list of parts in the parts library addon. """ freecad = get_freecad_connection() parts = freecad.get_parts_list() if parts: return [ TextContent(type="text", text=json.dumps(parts)) ] else: return [ TextContent(type="text", text=f"No parts found in the parts library. You must add parts_library addon.") ]
- Core cached implementation that scans the 'parts_library' directory in FreeCAD's user data for .FCStd files and returns their relative paths.@cache def get_parts_list() -> list[str]: parts_lib_path = os.path.join(FreeCAD.getUserAppDataDir(), "Mod", "parts_library") if not os.path.exists(parts_lib_path): raise FileNotFoundError(f"Not found: {parts_lib_path}") parts = [] for root, _, files in os.walk(parts_lib_path): for file in files: if file.endswith(".FCStd"): relative_path = os.path.relpath(os.path.join(root, file), parts_lib_path) parts.append(relative_path) return parts
- RPC server method that delegates to the parts_library.get_parts_list() function.def get_parts_list(self): return get_parts_list()
- src/freecad_mcp/server.py:87-88 (helper)Wrapper method in FreeCADConnection class that calls the RPC server's get_parts_list.def get_parts_list(self) -> list[str]: return self.server.get_parts_list()
- addon/FreeCADMCP/rpc_server/rpc_server.py:18-18 (registration)Import of the get_parts_list function from parts_library into the RPC server module.from .parts_library import get_parts_list, insert_part_from_library