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

create_document

Generate a new document in FreeCAD by specifying its name, enabling structured project management and file organization for design workflows.

Instructions

Create a new document in FreeCAD.

Args:
    name: The name of the document to create.

Returns:
    A message indicating the success or failure of the document creation.

Examples:
    If you want to create a document named "MyDocument", you can use the following data.
    ```json
    {
        "name": "MyDocument"
    }
    ```

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Primary MCP tool handler for 'create_document'. Calls the FreeCADConnection proxy to create a new document and returns success/error text content.
    def create_document(ctx: Context, name: str) -> list[TextContent]:
        """Create a new document in FreeCAD.
    
        Args:
            name: The name of the document to create.
    
        Returns:
            A message indicating the success or failure of the document creation.
    
        Examples:
            If you want to create a document named "MyDocument", you can use the following data.
            ```json
            {
                "name": "MyDocument"
            }
            ```
        """
        freecad = get_freecad_connection()
        try:
            res = freecad.create_document(name)
            if res["success"]:
                return [
                    TextContent(type="text", text=f"Document '{res['document_name']}' created successfully")
                ]
            else:
                return [
                    TextContent(type="text", text=f"Failed to create document: {res['error']}")
                ]
        except Exception as e:
            logger.error(f"Failed to create document: {str(e)}")
            return [
                TextContent(type="text", text=f"Failed to create document: {str(e)}")
            ]
  • Core implementation that actually creates the FreeCAD document using FreeCAD.newDocument() in the GUI thread.
    def _create_document_gui(self, name):
        doc = FreeCAD.newDocument(name)
        doc.recompute()
        FreeCAD.Console.PrintMessage(f"Document '{name}' created via RPC.\n")
        return True
  • RPC server entrypoint for create_document. Queues the GUI task and returns success/error dict.
    def create_document(self, name="New_Document"):
        rpc_request_queue.put(lambda: self._create_document_gui(name))
        res = rpc_response_queue.get()
        if res is True:
            return {"success": True, "document_name": name}
        else:
            return {"success": False, "error": res}
  • Proxy method in FreeCADConnection class that forwards the call to the XML-RPC server.
    def create_document(self, name: str) -> dict[str, Any]:
        return self.server.create_document(name)

Tool Definition Quality

Score is being calculated. Check back soon.

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