get_document
Retrieve complete document content and metadata from a local RAG system by specifying the file path.
Instructions
Get the full content of a specific document.
Args:
filepath: Path to the document file
Returns:
JSON string with document content and metadataInput Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filepath | Yes |
Implementation Reference
- mcp_server/server.py:1342-1360 (handler)Registration and implementation of the 'get_document' MCP tool. It delegates to the 'KnowledgeOrchestrator.get_document' method.
@mcp.tool() def get_document(filepath: str) -> str: """ Get the full content of a specific document. Args: filepath: Path to the document file Returns: JSON string with document content and metadata """ orchestrator = get_orchestrator() doc = orchestrator.get_document(filepath) if not doc: return json.dumps({"status": "error", "message": f"Document not found: {filepath}"}) return json.dumps({"status": "success", "document": doc}, indent=2, ensure_ascii=False) - mcp_server/server.py:917-935 (handler)The actual implementation of 'get_document' within the 'KnowledgeOrchestrator' class. It reads the document content using the document parser.
def get_document(self, filepath: str) -> Optional[Dict[str, Any]]: """Get full document content by filepath""" filepath = Path(filepath) try: doc = self.parser.parse_file(filepath) if doc: return { "content": doc.content, "source": str(doc.source), "filename": doc.filename, "category": doc.category, "format": doc.format, "metadata": doc.metadata, "keywords": doc.keywords, "chunk_count": len(doc.chunks) } except Exception as e: print(f"[ERROR] Failed to read document {filepath}: {e}") return None