Skip to main content
Glama

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 metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYes

Implementation Reference

  • 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)
  • 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

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/lyonzin/knowledge-rag'

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