Skip to main content
Glama

delete_object

Remove specific objects from FreeCAD documents to clean up designs or correct modeling errors. Specify document and object names to delete unwanted elements from your CAD project.

Instructions

Delete an object in FreeCAD.

Args:
    doc_name: The name of the document to delete the object from.
    obj_name: The name of the object to delete.

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doc_nameYes
obj_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Primary MCP tool handler for 'delete_object'. Decorated with @mcp.tool() for automatic registration. Proxies the call to FreeCADConnection.delete_object and formats response with optional screenshot.
    @mcp.tool()
    def delete_object(ctx: Context, doc_name: str, obj_name: str) -> list[TextContent | ImageContent]:
        """Delete an object in FreeCAD.
    
        Args:
            doc_name: The name of the document to delete the object from.
            obj_name: The name of the object to delete.
    
        Returns:
            A message indicating the success or failure of the object deletion and a screenshot of the object.
        """
        freecad = get_freecad_connection()
        try:
            res = freecad.delete_object(doc_name, obj_name)
            screenshot = freecad.get_active_screenshot()
            
            if res["success"]:
                response = [
                    TextContent(type="text", text=f"Object '{res['object_name']}' deleted successfully"),
                ]
                return add_screenshot_if_available(response, screenshot)
            else:
                response = [
                    TextContent(type="text", text=f"Failed to delete object: {res['error']}"),
                ]
                return add_screenshot_if_available(response, screenshot)
        except Exception as e:
            logger.error(f"Failed to delete object: {str(e)}")
            return [
                TextContent(type="text", text=f"Failed to delete object: {str(e)}")
            ]
  • Core implementation in FreeCAD RPC server that performs the actual object deletion using FreeCAD.Document.removeObject() in the GUI thread.
    def _delete_object_gui(self, doc_name: str, obj_name: str):
        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"
    
        try:
            doc.removeObject(obj_name)
            doc.recompute()
            FreeCAD.Console.PrintMessage(f"Object '{obj_name}' deleted via RPC.\n")
            return True
        except Exception as e:
            return str(e)
  • RPC server method for delete_object that queues the GUI-safe deletion task and returns success/error response.
    def delete_object(self, doc_name: str, obj_name: str):
        rpc_request_queue.put(lambda: self._delete_object_gui(doc_name, obj_name))
        res = rpc_response_queue.get()
        if res is True:
            return {"success": True, "object_name": obj_name}
        else:
            return {"success": False, "error": res}
  • Proxy method in FreeCADConnection class that forwards the delete_object call to the XML-RPC server.
    def delete_object(self, doc_name: str, obj_name: str) -> dict[str, Any]:
        return self.server.delete_object(doc_name, obj_name)
Behavior3/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 deletes an object, implying a destructive mutation, and mentions a return message and screenshot, which adds some context beyond the basic action. However, it doesn't cover critical aspects like permissions needed, whether deletion is reversible, error handling, or side effects on related objects, leaving gaps in transparency.

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

Conciseness5/5

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

The description is well-structured and concise, with no wasted words. It starts with the core purpose, followed by clear sections for arguments and returns, making it easy to parse. Every sentence serves a functional role, and the information is front-loaded for quick understanding.

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's complexity (a destructive operation with 2 parameters) and the presence of an output schema (implied by 'Returns' section), the description is moderately complete. It covers the basic action and parameters but lacks details on behavioral traits like safety, prerequisites, or error cases. The output schema helps, but without annotations, the description should do more to address mutation risks and usage context.

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%, so the description must compensate. It lists and briefly explains the two parameters ('doc_name' and 'obj_name'), adding meaning beyond the schema's minimal titles. However, it doesn't provide details like format examples, constraints, or how to find valid names, which limits the added value. Given the low coverage, this is adequate but not comprehensive.

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: 'Delete an object in FreeCAD.' It specifies the verb ('Delete') and resource ('an object in FreeCAD'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'edit_object' or 'get_object', which would require more specific context about when deletion is appropriate versus modification or retrieval.

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 (e.g., whether the object must exist), exclusions (e.g., not for read-only operations), or comparisons to siblings like 'edit_object' for modifications. This lack of context leaves the agent to infer usage based on the tool name alone.

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