Skip to main content
Glama

insert_part_from_library

Insert pre-designed 3D parts from FreeCAD's library into your CAD project using a relative file path to streamline design assembly.

Instructions

Insert a part from the parts library addon.

Args:
    relative_path: The relative path of the part to insert.

Returns:
    A message indicating the success or failure of the part insertion and a screenshot of the object.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
relative_pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler decorated with @mcp.tool(). Proxies the insertion request to FreeCADConnection RPC client and handles response with screenshot feedback.
    @mcp.tool()
    def insert_part_from_library(ctx: Context, relative_path: str) -> list[TextContent | ImageContent]:
        """Insert a part from the parts library addon.
    
        Args:
            relative_path: The relative path of the part to insert.
    
        Returns:
            A message indicating the success or failure of the part insertion and a screenshot of the object.
        """
        freecad = get_freecad_connection()
        try:
            res = freecad.insert_part_from_library(relative_path)
            screenshot = freecad.get_active_screenshot()
            
            if res["success"]:
                response = [
                    TextContent(type="text", text=f"Part inserted from library: {res['message']}"),
                ]
                return add_screenshot_if_available(response, screenshot)
            else:
                response = [
                    TextContent(type="text", text=f"Failed to insert part from library: {res['error']}"),
                ]
                return add_screenshot_if_available(response, screenshot)
        except Exception as e:
            logger.error(f"Failed to insert part from library: {str(e)}")
            return [
                TextContent(type="text", text=f"Failed to insert part from library: {str(e)}")
            ]
  • Core implementation in FreeCAD addon: constructs path to parts library FCStd file and merges it into active document.
    def insert_part_from_library(relative_path):
        parts_lib_path = os.path.join(FreeCAD.getUserAppDataDir(), "Mod", "parts_library")
        part_path = os.path.join(parts_lib_path, relative_path)
    
        if not os.path.exists(part_path):
            raise FileNotFoundError(f"Not found: {part_path}")
    
        FreeCADGui.ActiveDocument.mergeProject(part_path)
  • RPC server's private GUI-thread-safe method that invokes the parts library insertion function.
    def _insert_part_from_library(self, relative_path):
        try:
            insert_part_from_library(relative_path)
            return True
        except Exception as e:
            return str(e)
  • Proxy method in FreeCADConnection class that forwards RPC call to XML-RPC server.
    def insert_part_from_library(self, relative_path: str) -> dict[str, Any]:
        return self.server.insert_part_from_library(relative_path)
  • The @mcp.tool() decorator registers this function as an MCP tool.
    @mcp.tool()
    def insert_part_from_library(ctx: Context, relative_path: str) -> list[TextContent | ImageContent]:
        """Insert a part from the parts library addon.
    
        Args:
            relative_path: The relative path of the part to insert.
    
        Returns:
            A message indicating the success or failure of the part insertion and a screenshot of the object.
        """
        freecad = get_freecad_connection()
        try:
            res = freecad.insert_part_from_library(relative_path)
            screenshot = freecad.get_active_screenshot()
            
            if res["success"]:
                response = [
                    TextContent(type="text", text=f"Part inserted from library: {res['message']}"),
                ]
                return add_screenshot_if_available(response, screenshot)
            else:
                response = [
                    TextContent(type="text", text=f"Failed to insert part from library: {res['error']}"),
                ]
                return add_screenshot_if_available(response, screenshot)
        except Exception as e:
            logger.error(f"Failed to insert part from library: {str(e)}")
            return [
                TextContent(type="text", text=f"Failed to insert part from library: {str(e)}")
            ]
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool inserts a part and returns a success/failure message with a screenshot, but lacks details on permissions, side effects, error handling, or rate limits. This is insufficient for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections for Args and Returns, and it uses minimal sentences to convey key information. However, the first sentence could be more front-loaded with additional context, slightly reducing efficiency.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (which covers return values), the description doesn't need to detail returns extensively. However, as a mutation tool with no annotations and incomplete parameter guidance, it leaves gaps in behavioral and usage context, making it only minimally adequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, but the description includes an 'Args' section that explains 'relative_path' as 'The relative path of the part to insert', adding meaningful context beyond the bare schema. However, it doesn't elaborate on format or examples, so it only partially compensates for the low coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Insert a part') and the source ('from the parts library addon'), which is specific and distinguishes it from siblings like 'create_object' or 'get_parts_list'. However, it doesn't explicitly differentiate from similar tools like 'create_object' in terms of when to use one over the other, keeping it from a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives such as 'create_object' or 'get_parts_list'. It mentions the parts library addon but doesn't specify prerequisites or contexts, leaving the agent without clear usage instructions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/heok-yongssun/freecad-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server