Skip to main content
Glama

get_objects

Retrieve all objects from a FreeCAD document to identify available elements for inspection or modification, including a screenshot of the current design.

Instructions

Get all objects in a document. You can use this tool to get the objects in a document to see what you can check or edit.

Args:
    doc_name: The name of the document to get the objects from.

Returns:
    A list of objects in the document and a screenshot of the document.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doc_nameYes

Implementation Reference

  • The primary MCP tool handler for 'get_objects'. Retrieves all objects from the specified FreeCAD document using the RPC proxy, serializes them to JSON, and returns them with an optional screenshot of the current view.
    @mcp.tool()
    def get_objects(ctx: Context, doc_name: str) -> list[dict[str, Any]]:
        """Get all objects in a document.
        You can use this tool to get the objects in a document to see what you can check or edit.
    
        Args:
            doc_name: The name of the document to get the objects from.
    
        Returns:
            A list of objects in the document and a screenshot of the document.
        """
        freecad = get_freecad_connection()
        try:
            screenshot = freecad.get_active_screenshot()
            response = [
                TextContent(type="text", text=json.dumps(freecad.get_objects(doc_name))),
            ]
            return add_screenshot_if_available(response, screenshot)
        except Exception as e:
            logger.error(f"Failed to get objects: {str(e)}")
            return [
                TextContent(type="text", text=f"Failed to get objects: {str(e)}")
            ]
  • Proxy method in the FreeCADConnection class that forwards the get_objects request to the underlying XML-RPC server.
    def get_objects(self, doc_name: str) -> list[dict[str, Any]]:
        return self.server.get_objects(doc_name)
  • Core implementation in the FreeCAD RPC server. Fetches the document by name and returns a list of serialized objects using the serialize_object helper.
    def get_objects(self, doc_name):
        doc = FreeCAD.getDocument(doc_name)
        if doc:
            return [serialize_object(obj) for obj in doc.Objects]
        else:
            return []

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