Skip to main content
Glama

get_doctypes

Retrieve all available DocTypes from ERPNext to discover accessible data models and document types for integration and querying.

Instructions

Get a list of all available DocTypes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler case for 'get_doctypes' tool that checks authentication, calls erpnext.getAllDocTypes(), and returns the result as JSON
    case "get_doctypes": {
      if (!erpnext.isAuthenticated()) {
        return {
          content: [{
            type: "text",
            text: "Not authenticated with ERPNext. Please configure API key authentication."
          }],
          isError: true
        };
      }
      
      try {
        const doctypes = await erpnext.getAllDocTypes();
        return {
          content: [{
            type: "text",
            text: JSON.stringify(doctypes, null, 2)
          }]
        };
      } catch (error: any) {
        return {
          content: [{
            type: "text",
            text: `Failed to get DocTypes: ${error?.message || 'Unknown error'}`
          }],
          isError: true
        };
      }
    }
  • The ERPNextClient method that fetches all DocTypes from the ERPNext API, with fallback to alternative method and default list
    async getAllDocTypes(): Promise<string[]> {
      try {
        // Use the standard REST API to fetch DocTypes
        const response = await this.axiosInstance.get('/api/resource/DocType', {
          params: {
            fields: JSON.stringify(["name"]),
            limit_page_length: 500 // Get more doctypes at once
          }
        });
        
        if (response.data && response.data.data) {
          return response.data.data.map((item: any) => item.name);
        }
        
        return [];
      } catch (error: any) {
        console.error("Failed to get DocTypes:", error?.message || 'Unknown error');
        
        // Try an alternative approach if the first one fails
        try {
          // Try using the method API to get doctypes
          const altResponse = await this.axiosInstance.get('/api/method/frappe.desk.search.search_link', {
            params: {
              doctype: 'DocType',
              txt: '',
              limit: 500
            }
          });
          
          if (altResponse.data && altResponse.data.results) {
            return altResponse.data.results.map((item: any) => item.value);
          }
          
          return [];
        } catch (altError: any) {
          console.error("Alternative DocType fetch failed:", altError?.message || 'Unknown error');
          
          // Fallback: Return a list of common DocTypes
          return [
            "Customer", "Supplier", "Item", "Sales Order", "Purchase Order",
            "Sales Invoice", "Purchase Invoice", "Employee", "Lead", "Opportunity",
            "Quotation", "Payment Entry", "Journal Entry", "Stock Entry"
          ];
        }
      }
    }
  • src/index.ts:324-332 (registration)
    Tool registration in the ListToolsRequestSchema handler defining the 'get_doctypes' tool with empty input schema
    tools: [
      {
        name: "get_doctypes",
        description: "Get a list of all available DocTypes",
        inputSchema: {
          type: "object",
          properties: {}
        }
      },
Behavior2/5

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

With no annotations provided, the description fails to disclose idempotency, side effects, or rate limits beyond the basic operation.

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?

Extremely concise at 7 words with no filler, though overly minimal to provide usage context.

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?

Covers the basic operation but lacks explanation of what a DocType represents or how results enable subsequent calls to get_doctype_fields/get_documents.

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?

Zero parameters warrants baseline score; schema requires no additional semantic explanation.

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?

States specific action (get list) and resource (DocTypes), with 'all available' distinguishing it from sibling tools that fetch specific fields or documents.

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?

Provides no guidance on when to use this versus siblings (e.g., when to list DocTypes vs get fields vs query documents).

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/rakeshgangwar/erpnext-server'

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