Skip to main content
Glama

get_document

Retrieve specific documents from Frappe Framework by providing DocType and document name for data access and management.

Instructions

    Retrieve a document from Frappe.
    
    Args:
        doctype: DocType name
        name: Document name (case-sensitive)
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doctypeYes
nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main execution logic for the 'get_document' tool. Fetches the specified Frappe document using the API client and returns JSON-formatted data or error.
    async def get_document(
        doctype: str,
        name: str
    ) -> str:
        """
        Retrieve a document from Frappe.
        
        Args:
            doctype: DocType name
            name: Document name (case-sensitive)
        """
        try:
            client = get_client()
            
            # Make API request to get document
            response = await client.get(f"api/resource/{doctype}/{name}")
            
            if "data" in response:
                return json.dumps(response["data"], indent=2)
            else:
                return json.dumps(response, indent=2)
                
        except Exception as error:
            return _format_error_response(error, "get_document")
  • src/server.py:38-43 (registration)
    The 'documents.register_tools(mcp)' call registers all document-related tools, including 'get_document', with the MCP server.
    # Register all tool modules
    helpers.register_tools(mcp)
    documents.register_tools(mcp)
    schema.register_tools(mcp)
    reports.register_tools(mcp)
  • Helper function called by get_document in error cases to format and return detailed error responses.
    def _format_error_response(error: Exception, operation: str) -> str:
        """Format error response with detailed information."""
        credentials_check = validate_api_credentials()
        
        # Build diagnostic information
        diagnostics = [
            f"Error in {operation}",
            f"Error type: {type(error).__name__}",
            f"Is FrappeApiError: {isinstance(error, FrappeApiError)}",
            f"API Key available: {credentials_check['details']['api_key_available']}",
            f"API Secret available: {credentials_check['details']['api_secret_available']}"
        ]
        
        # Check for missing credentials first
        if not credentials_check["valid"]:
            error_msg = f"Authentication failed: {credentials_check['message']}. "
            error_msg += "API key/secret is the only supported authentication method."
            return error_msg
        
        # Handle FrappeApiError
        if isinstance(error, FrappeApiError):
            error_msg = f"Frappe API error: {error}"
            if error.status_code in (401, 403):
                error_msg += " Please check your API key and secret."
            return error_msg
        
        # Default error handling
        return f"Error in {operation}: {str(error)}"
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action. It lacks behavioral details such as permissions needed, error handling, rate limits, or what happens if the document doesn't exist, which are critical for a retrieval tool.

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

Conciseness5/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 followed by parameter details. Every sentence adds value without redundancy, making it efficient and well-structured.

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 moderate complexity (2 required parameters) and the presence of an output schema, the description is minimally adequate. However, without annotations and with incomplete behavioral context, it leaves gaps in understanding the tool's full operation and constraints.

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

Parameters4/5

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

The description adds meaningful semantics beyond the input schema, which has 0% description coverage. It explains that 'doctype' is the DocType name and 'name' is the case-sensitive document name, providing essential context that the schema alone does not.

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 verb 'Retrieve' and the resource 'a document from Frappe', making the purpose evident. However, it doesn't explicitly differentiate from sibling tools like 'list_documents' or 'get_doctype_schema', which would require more specific scope details for a perfect score.

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?

No guidance is provided on when to use this tool versus alternatives. For example, it doesn't mention using 'list_documents' for multiple documents or 'get_doctype_schema' for schema details, leaving the agent without context for tool selection.

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/appliedrelevance/frappe-mcp-server'

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