Skip to main content
Glama

read_docx

Extract text content and metadata from Word documents to access and analyze document information.

Instructions

Read and extract text content from a Word document.

Args: filepath: Path to the document to read

Returns: Dictionary with document text and metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYes

Implementation Reference

  • The read_docx tool handler, which extracts text and document information.
    @app.tool()
    def read_docx(filepath: str) -> dict[str, Any]:
        """
        Read and extract text content from a Word document.
    
        Args:
            filepath: Path to the document to read
    
        Returns:
            Dictionary with document text and metadata
        """
        logger.info("Reading document", extra={"tool": "read_docx", "filepath": filepath})
    
        try:
            text = extract_all_text(filepath)
            doc_info = get_document_info(filepath)
    
            return {
                "status": "success",
                "filepath": filepath,
                "content": text,
                "info": doc_info,
            }
        except DocxMcpError as e:
            logger.warning(e.message, extra={"tool": "read_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 reading 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