Skip to main content
Glama

list_docx

Lists all Word documents in a specified directory to help users quickly locate and manage DOCX files within their projects.

Instructions

List all Word documents in a directory.

Args: directory: Directory path to list (defaults to project directory)

Returns: Dictionary with list of documents

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The `list_docx` tool handler, which lists Word documents in a directory.
    def list_docx(directory: Optional[str] = None) -> dict[str, Any]:
        """
        List all Word documents in a directory.
    
        Args:
            directory: Directory path to list (defaults to project directory)
    
        Returns:
            Dictionary with list of documents
        """
        logger.info("Listing documents", extra={"tool": "list_docx", "directory": directory})
    
        try:
            if directory is None:
                dir_path = config.project_dir
            else:
                dir_path = normalize_path(directory)
    
            if not dir_path.is_dir():
                raise InvalidParameterError("directory", "Path is not a directory")
    
            documents = []
            for ext in [".docx", ".doc", ".dotx", ".dot"]:
                for file in dir_path.glob(f"**/*{ext}"):
                    try:
                        file_info = get_safe_file_info(str(file))
                        documents.append(file_info)
                    except Exception:
                        # Skip files that can't be accessed
                        continue
    
            logger.info(f"Found {len(documents)} documents", extra={"tool": "list_docx"})
    
            return {
                "status": "success",
                "directory": str(dir_path),
                "count": len(documents),
                "documents": documents,
            }
        except DocxMcpError as e:
            logger.warning(e.message, extra={"tool": "list_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 listing documents: {str(e)}")
            return {"status": "error", "error": str(e)}
  • The handler for the `list_docx` tool which scans a directory for various Word document file extensions and returns their metadata.
    @app.tool()
    def list_docx(directory: Optional[str] = None) -> dict[str, Any]:
        """
        List all Word documents in a directory.
    
        Args:
            directory: Directory path to list (defaults to project directory)
    
        Returns:
            Dictionary with list of documents
        """
        logger.info("Listing documents", extra={"tool": "list_docx", "directory": directory})
    
        try:
            if directory is None:
                dir_path = config.project_dir
            else:
                dir_path = normalize_path(directory)
    
            if not dir_path.is_dir():
                raise InvalidParameterError("directory", "Path is not a directory")
    
            documents = []
            for ext in [".docx", ".doc", ".dotx", ".dot"]:
                for file in dir_path.glob(f"**/*{ext}"):
                    try:
                        file_info = get_safe_file_info(str(file))
                        documents.append(file_info)
                    except Exception:
                        # Skip files that can't be accessed
                        continue
    
            logger.info(f"Found {len(documents)} documents", extra={"tool": "list_docx"})
    
            return {
                "status": "success",
                "directory": str(dir_path),
                "count": len(documents),
                "documents": documents,
            }
        except DocxMcpError as e:
            logger.warning(e.message, extra={"tool": "list_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 listing documents: {str(e)}")
            return {"status": "error", "error": str(e)}
  • The tool is registered using `@app.tool()` decorator on the `list_docx` function.
    @app.tool()
    def list_docx(directory: Optional[str] = None) -> dict[str, Any]:
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 lists documents but doesn't cover critical aspects like whether it requires specific permissions, how it handles errors (e.g., invalid directories), what format the list includes (e.g., file names, paths, metadata), or if it's read-only (implied but not explicit). This leaves significant gaps in understanding the tool's behavior.

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 appropriately sized and front-loaded, with the core purpose stated first. The 'Args' and 'Returns' sections are structured but could be more integrated. There's no wasted text, though it could be slightly more concise by merging the sections into a single paragraph without losing clarity.

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 low complexity (1 parameter, no nested objects) and the presence of an output schema (which handles return values), the description is somewhat complete but has gaps. It covers the basic purpose and parameter intent but lacks usage guidelines and behavioral details. With no annotations, it should provide more context on how the tool behaves in practice, making it only minimally adequate.

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 beyond the input schema. It explains that 'directory' is a 'Directory path to list' and defaults to the project directory, which provides basic context. However, with 0% schema description coverage and 1 parameter, this doesn't fully compensate for the lack of schema details (e.g., path format, validation rules). The baseline is 3 since the schema covers the parameter structure, but the description adds only marginal value.

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: 'List all Word documents in a directory.' It specifies the verb ('List'), resource ('Word documents'), and scope ('in a directory'), making it easy to understand. However, it doesn't explicitly differentiate from sibling tools like 'list_images' or 'list_equations', which also list specific content types from documents, so it doesn't reach a perfect score.

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 'read_docx' for accessing document content or 'list_content_controls' for other listing purposes, nor does it specify prerequisites or exclusions. The only implied context is that it operates on directories, but this is insufficient for effective tool selection.

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