Skip to main content
Glama
neka-nat
by neka-nat

insert_part_from_library

Add pre-designed parts to your FreeCAD project using a library addon. Specify the part's relative path to integrate it directly into your design.

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 handler for 'insert_part_from_library' tool. Proxies to FreeCADConnection RPC and adds response with optional screenshot.
    @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: merges the specified FCStd part file from the user's parts library into the active FreeCAD 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)
  • Proxy method in FreeCADConnection class that forwards the call to the XML-RPC server.
    def insert_part_from_library(self, relative_path: str) -> dict[str, Any]:
        return self.server.insert_part_from_library(relative_path)
  • RPC server registration of FreeCADRPC instance, which exposes the insert_part_from_library method.
    rpc_server_instance = SimpleXMLRPCServer(
        (host, port), allow_none=True, logRequests=False
    )
    rpc_server_instance.register_instance(FreeCADRPC())
  • RPC method dispatcher: queues the insertion task for GUI thread safety and returns success/error response.
    def insert_part_from_library(self, relative_path):
        rpc_request_queue.put(lambda: self._insert_part_from_library(relative_path))
        res = rpc_response_queue.get()
        if res is True:
            return {"success": True, "message": "Part inserted from library."}
        else:
            return {"success": False, "error": res}
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that the tool returns a success/failure message and a screenshot, which adds some context beyond the input schema. However, it doesn't cover critical aspects like whether this is a read-only or destructive operation, what permissions are required, or how errors are handled. For a tool that likely modifies a document (implied by 'insert'), this is a significant gap.

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 concise and well-structured, with a clear purpose statement followed by Args and Returns sections. Each sentence serves a purpose: the first explains the tool's function, and the next two detail inputs and outputs. There's no unnecessary information, making it easy to parse.

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 one parameter with 0% schema coverage and an output schema exists (implied by the Returns section), the description is moderately complete. It covers the basic purpose and return values, but lacks usage guidelines and detailed behavioral context. For a tool that inserts parts, more information on dependencies or error conditions would improve completeness.

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 description adds minimal semantics for the single parameter 'relative_path', explaining it as 'The relative path of the part to insert.' This provides basic meaning beyond the schema, which has 0% description coverage and only lists the parameter as a string. However, it doesn't elaborate on format, examples, or constraints, leaving the agent with incomplete guidance.

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 tool's purpose: 'Insert a part from the parts library addon.' It specifies the verb ('insert') and resource ('part from the parts library addon'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'create_object' or 'get_parts_list', which could have overlapping functionality.

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. It doesn't mention prerequisites, such as needing the parts library addon to be available, or compare it to siblings like 'create_object' for creating objects from scratch or 'get_parts_list' for listing parts. This lack of context makes it harder for an agent to choose the right tool.

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

Related 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/neka-nat/freecad-mcp'

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