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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

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)}
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool reads and extracts text, implying a read-only operation, but doesn't specify permissions, file format constraints (e.g., .docx only), error handling, or performance aspects like rate limits. This leaves gaps for a tool that interacts with files.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured: a clear purpose statement followed by brief 'Args' and 'Returns' sections. Every sentence adds value, with no redundant information. It could be slightly more front-loaded by integrating the return info into the main sentence, but it's efficient overall.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (file reading with one parameter) and the presence of an output schema (which handles return values), the description is somewhat complete. It covers the basic operation but lacks details on behavioral aspects like error cases or constraints. With no annotations, it should provide more context to fully guide the agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds minimal semantics: it notes 'filepath: Path to the document to read,' which clarifies the parameter's purpose. However, with 0% schema description coverage and only one parameter, this provides basic context but lacks details like path format (absolute/relative) or supported file types. The baseline is 3 since schema coverage is low but the description compensates somewhat.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Read and extract text content from a Word document.' It specifies the verb ('read and extract'), resource ('Word document'), and content type ('text content'). However, it doesn't explicitly differentiate from sibling tools like 'get_document_properties' or 'extract_images', which might handle similar documents differently.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get_document_properties' (which might return metadata without text) or 'extract_images' (which focuses on images), leaving the agent to infer usage based on tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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