Skip to main content
Glama

list_available_documents

Retrieve a list of all .docx files in a specified directory using the Office Word MCP Server. Ideal for managing and accessing Word documents efficiently.

Instructions

List all .docx files in the specified directory.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryNo.

Implementation Reference

  • Core handler function that implements the logic to list all .docx files in a directory with their sizes in KB.
    async def list_available_documents(directory: str = ".") -> str: """List all .docx files in the specified directory. Args: directory: Directory to search for Word documents """ try: if not os.path.exists(directory): return f"Directory {directory} does not exist" docx_files = [f for f in os.listdir(directory) if f.endswith('.docx')] if not docx_files: return f"No Word documents found in {directory}" result = f"Found {len(docx_files)} Word documents in {directory}:\n" for file in docx_files: file_path = os.path.join(directory, file) size = os.path.getsize(file_path) / 1024 # KB result += f"- {file} ({size:.2f} KB)\n" return result except Exception as e: return f"Failed to list documents: {str(e)}"
  • MCP tool registration using @mcp.tool() decorator, which delegates to the core implementation in document_tools.
    @mcp.tool() def list_available_documents(directory: str = "."): """List all .docx files in the specified directory.""" return document_tools.list_available_documents(directory)
  • Re-export of the list_available_documents function from document_tools for module-level access.
    from word_document_server.tools.document_tools import ( create_document, get_document_info, get_document_text, get_document_outline, list_available_documents, copy_document, merge_documents )

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/GongRzhe/Office-Word-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server