Skip to main content
Glama

create_document

Generate a new FreeCAD document by specifying its name. Simplifies CAD file creation and management within the FreeCAD MCP server for efficient 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

Implementation Reference

  • Primary MCP tool handler for 'create_document'. Decorated with @mcp.tool(), connects to FreeCAD RPC, executes document creation, and returns formatted TextContent response.
    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)}") ]
  • Helper method in FreeCADConnection class that proxies the create_document call to the XML-RPC server.
    def create_document(self, name: str) -> dict[str, Any]: return self.server.create_document(name)
  • RPC server method for create_document that 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}
  • Core GUI-thread-safe implementation that actually calls FreeCAD.newDocument(name) to create the document.
    def _create_document_gui(self, name): doc = FreeCAD.newDocument(name) doc.recompute() FreeCAD.Console.PrintMessage(f"Document '{name}' created via RPC.\n") return True

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