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

edit_object

Modify object properties in FreeCAD when initial creation fails. Specify document, object name, and desired properties to update the object and receive a success confirmation and screenshot.

Instructions

Edit an object in FreeCAD. This tool is used when the create_object tool cannot handle the object creation.

Args:
    doc_name: The name of the document to edit the object in.
    obj_name: The name of the object to edit.
    obj_properties: The properties of the object to edit.

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doc_nameYes
obj_nameYes
obj_propertiesYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Primary MCP tool handler for 'edit_object'. Proxies the call to FreeCADConnection.edit_object, handles errors, formats response with success message and optional screenshot.
    @mcp.tool()
    def edit_object(
        ctx: Context, doc_name: str, obj_name: str, obj_properties: dict[str, Any]
    ) -> list[TextContent | ImageContent]:
        """Edit an object in FreeCAD.
        This tool is used when the `create_object` tool cannot handle the object creation.
    
        Args:
            doc_name: The name of the document to edit the object in.
            obj_name: The name of the object to edit.
            obj_properties: The properties of the object to edit.
    
        Returns:
            A message indicating the success or failure of the object editing and a screenshot of the object.
        """
        freecad = get_freecad_connection()
        try:
            res = freecad.edit_object(doc_name, obj_name, {"Properties": obj_properties})
            screenshot = freecad.get_active_screenshot()
    
            if res["success"]:
                response = [
                    TextContent(type="text", text=f"Object '{res['object_name']}' edited successfully"),
                ]
                return add_screenshot_if_available(response, screenshot)
            else:
                response = [
                    TextContent(type="text", text=f"Failed to edit object: {res['error']}"),
                ]
                return add_screenshot_if_available(response, screenshot)
        except Exception as e:
            logger.error(f"Failed to edit object: {str(e)}")
            return [
                TextContent(type="text", text=f"Failed to edit object: {str(e)}")
            ]
  • Proxy method in FreeCADConnection class that forwards the edit_object RPC call to the FreeCAD XMLRPC server.
    def edit_object(self, doc_name: str, obj_name: str, obj_data: dict[str, Any]) -> dict[str, Any]:
        return self.server.edit_object(doc_name, obj_name, obj_data)
  • XMLRPC server method for edit_object that queues the GUI-safe editing task and returns success/error response.
    def edit_object(self, doc_name: str, obj_name: str, properties: dict[str, Any]) -> dict[str, Any]:
        obj = Object(
            name=obj_name,
            properties=properties.get("Properties", {}),
        )
        rpc_request_queue.put(lambda: self._edit_object_gui(doc_name, obj))
        res = rpc_response_queue.get()
        if res is True:
            return {"success": True, "object_name": obj.name}
        else:
            return {"success": False, "error": res}
  • GUI-thread safe implementation that performs the actual property setting on FreeCAD objects, handling special cases like References and Placement.
    def _edit_object_gui(self, doc_name: str, obj: Object):
        doc = FreeCAD.getDocument(doc_name)
        if not doc:
            FreeCAD.Console.PrintError(f"Document '{doc_name}' not found.\n")
            return f"Document '{doc_name}' not found.\n"
    
        obj_ins = doc.getObject(obj.name)
        if not obj_ins:
            FreeCAD.Console.PrintError(f"Object '{obj.name}' not found in document '{doc_name}'.\n")
            return f"Object '{obj.name}' not found in document '{doc_name}'.\n"
    
        try:
            # For Fem::ConstraintFixed
            if hasattr(obj_ins, "References") and "References" in obj.properties:
                refs = []
                for ref_name, face in obj.properties["References"]:
                    ref_obj = doc.getObject(ref_name)
                    if ref_obj:
                        refs.append((ref_obj, face))
                    else:
                        raise ValueError(f"Referenced object '{ref_name}' not found.")
                obj_ins.References = refs
                FreeCAD.Console.PrintMessage(
                    f"References updated for '{obj.name}' in '{doc_name}'.\n"
                )
                # delete References from properties
                del obj.properties["References"]
            set_object_property(doc, obj_ins, obj.properties)
            doc.recompute()
            FreeCAD.Console.PrintMessage(f"Object '{obj.name}' updated via RPC.\n")
            return True
        except Exception as e:
            return str(e)
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 message indicating success or failure and a screenshot,' which adds some context about outputs. However, it lacks critical details for an edit operation: it doesn't specify if changes are destructive, what permissions are required, how errors are handled, or if there are rate limits. For a mutation tool with zero annotation coverage, this is insufficient.

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 appropriately sized and well-structured: it starts with the core purpose, followed by usage guidelines, and then details parameters and returns in separate sections. Each sentence adds value, such as the alternative tool reference and output details. However, it could be more front-loaded by emphasizing key behavioral traits earlier.

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 complexity (3 parameters, nested objects, no annotations) and the presence of an output schema (which likely covers return values), the description is moderately complete. It explains the tool's purpose and usage but lacks depth in behavioral transparency and parameter semantics. For an edit tool with mutation implications, it should provide more context on safety and error handling to be fully adequate.

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

Parameters2/5

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

Schema description coverage is 0%, meaning parameters are undocumented in the schema. The description lists the parameters ('doc_name', 'obj_name', 'obj_properties') and provides brief explanations, but these are minimal and don't add meaningful semantics beyond the schema's structure. For example, it doesn't clarify what 'obj_properties' entails or provide examples. With low schema coverage, the description fails to compensate adequately.

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: 'Edit an object in FreeCAD.' It specifies the verb ('Edit') and resource ('an object'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'create_object' or 'delete_object' beyond mentioning 'create_object' in a usage context, which is helpful but not a full distinction.

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

Usage Guidelines4/5

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

The description provides clear usage guidance: 'This tool is used when the `create_object` tool cannot handle the object creation.' This indicates when to use this tool (as an alternative to 'create_object' for editing) and references a sibling tool. However, it doesn't specify when not to use it or compare to other siblings like 'delete_object' or 'get_object', leaving some gaps in full alternative coverage.

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