Skip to main content
Glama

set_document_properties

Set metadata like title, author, and keywords in Microsoft Word documents to organize and identify files effectively.

Instructions

Set document properties and metadata.

Args: filepath: Path to the document title: Document title subject: Document subject author: Document author keywords: Document keywords comments: Document comments

Returns: Dictionary with status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYes
titleNo
subjectNo
authorNo
keywordsNo
commentsNo

Implementation Reference

  • The set_document_properties tool handler function is registered with @app.tool() and manages the updating of core document properties using the python-docx library.
    @app.tool()
    def set_document_properties(
        filepath: str,
        title: Optional[str] = None,
        subject: Optional[str] = None,
        author: Optional[str] = None,
        keywords: Optional[str] = None,
        comments: Optional[str] = None,
    ) -> dict[str, Any]:
        """
        Set document properties and metadata.
    
        Args:
            filepath: Path to the document
            title: Document title
            subject: Document subject
            author: Document author
            keywords: Document keywords
            comments: Document comments
    
        Returns:
            Dictionary with status
        """
        logger.info(
            "Setting document properties",
            extra={"tool": "set_document_properties", "filepath": filepath},
        )
    
        try:
            doc = safe_open_document(filepath)
            props = doc.core_properties
    
            if title is not None:
                props.title = title
            if subject is not None:
                props.subject = subject
            if author is not None:
                props.author = author
            if keywords is not None:
                props.keywords = keywords
            if comments is not None:
                props.comments = comments
    
            safe_save_document(doc, filepath)
            logger.info("Document properties updated", extra={"filepath": filepath})
    
            return {
                "status": "success",
                "filepath": filepath,
                "message": "Document properties updated",
            }
        except DocxMcpError as e:
            logger.warning(
                e.message,
                extra={"tool": "set_document_properties", "error_code": e.error_code},
            )
            return {"status": "error", "error": e.message, "error_code": e.error_code}

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