Skip to main content
Glama

create_docx

Create new blank Word documents with optional titles using the docx-mcp server. Specify filepath to generate documents for writing, editing, or content management.

Instructions

Create a new blank Word document.

Args: filepath: Path where to create the document title: Optional title for the document

Returns: Dictionary with status and document info

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYes
titleNo

Implementation Reference

  • The 'create_docx' tool handler function that creates a new blank Word document.
    @app.tool()
    def create_docx(filepath: str, title: Optional[str] = None) -> dict[str, Any]:
        """
        Create a new blank Word document.
    
        Args:
            filepath: Path where to create the document
            title: Optional title for the document
    
        Returns:
            Dictionary with status and document info
        """
        logger.info("Creating new document", extra={"tool": "create_docx", "filepath": filepath})
    
        try:
            path = normalize_path(filepath)
            path.parent.mkdir(parents=True, exist_ok=True)
    
            doc = Document()
    
            if title:
                doc.core_properties.title = title
    
            doc.save(str(path))
            logger.info("Document created successfully", extra={"filepath": filepath})
    
            return {
                "status": "success",
                "filepath": str(path),
                "message": f"Document created: {path.name}",
            }
        except DocxMcpError as e:
            logger.warning(e.message, extra={"tool": "create_docx", "error_code": e.error_code})
            return {"status": "error", "error": e.message, "error_code": e.error_code}
        except Exception as e:
            logger.error(f"Unexpected error creating document: {str(e)}")
            return {"status": "error", "error": str(e)}

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/Andrew82106/LLM_Docx_Agent_MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server