list_documents
Retrieve a list of all currently loaded documents and their metadata within the DocNav-MCP server. Simplify document management and analysis for enhanced navigation.
Instructions
List all currently loaded documents.
Returns:
List of loaded documents with their metadata
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.py:113-140 (handler)MCP tool handler for 'list_documents' that retrieves document list from navigator, computes heading counts, and formats a human-readable output listing all loaded documents with 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
- docnav/navigator.py:795-804 (helper)Core helper method in DocumentNavigator class that returns a list of dictionaries containing metadata for all 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