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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves content and metadata, but lacks details on permissions, error handling, rate limits, or data formats. This is a significant gap for a read operation with no structured safety hints.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, with the core purpose stated first. The 'Args' and 'Returns' sections add structure, though they could be more integrated. There is minimal waste, but slight verbosity in labeling sections.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity and the presence of an output schema (which handles return values), the description is somewhat complete. However, with no annotations and incomplete parameter guidance, it lacks sufficient context for safe and effective use, especially compared to siblings.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, so the description must compensate. It adds meaning by explaining that 'filepath' is a 'Path to the document file', which clarifies the parameter's purpose beyond the schema's basic type. However, it does not provide format examples or constraints, leaving some ambiguity.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get the full content of a specific document.' It specifies the verb ('Get') and resource ('document'), but does not explicitly differentiate it from sibling tools like 'list_documents' or 'search_knowledge', which would require mentioning scope or filtering differences.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It does not mention prerequisites, such as needing a valid filepath, or compare it to siblings like 'list_documents' for browsing or 'search_knowledge' for querying, leaving the agent without contextual usage cues.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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