Skip to main content
Glama

list_documents

Retrieve a list of all currently loaded documents with their metadata to manage and navigate document collections within the DocNav-MCP server.

Instructions

List all currently loaded documents.

Returns:
    List of loaded documents with their metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for 'list_documents' that retrieves the list of loaded documents from the navigator, computes additional stats like heading count, and formats a human-readable output listing all documents with their metadata.
    @mcp.tool()
    def list_documents() -> str:
        """List all currently loaded documents.
    
        Returns:
            List of loaded documents with their metadata
        """
        documents = navigator.list_documents()
        if not documents:
            return "No documents currently loaded."
    
        output = "Loaded documents:\n"
        for doc in documents:
            document = navigator.get_document(doc["id"])
            headings_count = 0
            if document and document.index:
                headings = [
                    node for node in document.index.values() if node.type == "heading"
                ]
                headings_count = len(headings)
    
            output += (
                f"- {doc['title']} (ID: {doc['id']})\n"
                f"  Format: {doc['format']}, Sections: {headings_count}\n"
                f"  Source: {doc['source_type']}\n\n"
            )
    
        return output
  • Core helper method in DocumentNavigator class that returns a list of dictionaries, each containing the ID and metadata for all currently loaded documents.
    def list_documents(self) -> List[Dict[str, str]]:
        """List all loaded documents with their metadata.
    
        Returns:
            List of document info dictionaries
        """
        documents = []
        for doc_id, metadata in self.document_metadata.items():
            documents.append({"id": doc_id, **metadata})
        return 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/shenyimings/DocNav-MCP'

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