get_parts_list
Retrieve available parts from the FreeCAD parts library to use in 3D designs. This tool provides access to components for building CAD models.
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'. Fetches the parts list through the FreeCADConnection RPC client and formats it as JSON text content, or provides an error message if unavailable.@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 implementation that scans the 'parts_library' directory in FreeCAD's user app data for all .FCStd files and returns their relative paths. Uses caching for efficiency.@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 in FreeCADRPC class 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)Proxy method in FreeCADConnection class that forwards the call to the XML-RPC server.def get_parts_list(self) -> list[str]: return self.server.get_parts_list()