get_document_properties
Extract document properties and metadata from Microsoft Word files to analyze file details and content information.
Instructions
Get document properties and metadata.
Args: filepath: Path to the document
Returns: Dictionary with document properties
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filepath | Yes |
Implementation Reference
- src/docx_mcp/server.py:496-535 (handler)The implementation of the get_document_properties tool, which retrieves document metadata using python-docx and registers the function with the FastMCP application.
@app.tool() def get_document_properties(filepath: str) -> dict[str, Any]: """ Get document properties and metadata. Args: filepath: Path to the document Returns: Dictionary with document properties """ logger.info( "Getting document properties", extra={"tool": "get_document_properties", "filepath": filepath}, ) try: doc = safe_open_document(filepath) props = doc.core_properties return { "status": "success", "filepath": filepath, "properties": { "title": props.title or "", "subject": props.subject or "", "author": props.author or "", "keywords": props.keywords or "", "comments": props.comments or "", "category": props.category or "", "created": str(props.created) if props.created else None, "modified": str(props.modified) if props.modified else None, }, } except DocxMcpError as e: logger.warning( e.message, extra={"tool": "get_document_properties", "error_code": e.error_code}, ) return {"status": "error", "error": e.message, "error_code": e.error_code}