Skip to main content
Glama

get_doctype_fields

Retrieve field definitions for ERPNext document types to understand data structure and enable accurate data entry or integration.

Instructions

Get fields list for a specific DocType

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doctypeYesERPNext DocType (e.g., Customer, Item)

Implementation Reference

  • Main execution logic for the 'get_doctype_fields' tool: authenticates, fetches a sample document using erpnext.getDocList, extracts field names, types, and samples from the first document, and returns them as JSON.
    case "get_doctype_fields": {
      if (!erpnext.isAuthenticated()) {
        return {
          content: [{
            type: "text",
            text: "Not authenticated with ERPNext. Please configure API key authentication."
          }],
          isError: true
        };
      }
      
      const doctype = String(request.params.arguments?.doctype);
      
      if (!doctype) {
        throw new McpError(
          ErrorCode.InvalidParams,
          "Doctype is required"
        );
      }
      
      try {
        // Get a sample document to understand the fields
        const documents = await erpnext.getDocList(doctype, {}, ["*"], 1);
        
        if (!documents || documents.length === 0) {
          return {
            content: [{
              type: "text",
              text: `No documents found for ${doctype}. Cannot determine fields.`
            }],
            isError: true
          };
        }
        
        // Extract field names from the first document
        const sampleDoc = documents[0];
        const fields = Object.keys(sampleDoc).map(field => ({
          fieldname: field,
          value: typeof sampleDoc[field],
          sample: sampleDoc[field]?.toString()?.substring(0, 50) || null
        }));
        
        return {
          content: [{
            type: "text",
            text: JSON.stringify(fields, null, 2)
          }]
        };
      } catch (error: any) {
        return {
          content: [{
            type: "text",
            text: `Failed to get fields for ${doctype}: ${error?.message || 'Unknown error'}`
          }],
          isError: true
        };
      }
    }
  • Input schema and metadata for the 'get_doctype_fields' tool, defining the required 'doctype' parameter.
      name: "get_doctype_fields",
      description: "Get fields list for a specific DocType",
      inputSchema: {
        type: "object",
        properties: {
          doctype: {
            type: "string",
            description: "ERPNext DocType (e.g., Customer, Item)"
          }
        },
          required: ["doctype"]
      }
    },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but offers minimal information. It doesn't describe whether this is a read-only operation, what the output format looks like (e.g., list of field objects with types), potential errors (e.g., invalid DocType), or any rate limits. This leaves significant gaps for agent understanding.

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 a single, clear sentence that directly states the tool's function without unnecessary words. It is front-loaded and efficiently communicates the core purpose, making it easy to parse quickly.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is insufficiently complete. It doesn't explain what the returned field list contains (e.g., field names, types, properties) or how it might be used in context with sibling tools like 'create_document'. For a tool that likely returns structured metadata, more detail is needed.

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 100%, with the single parameter 'doctype' clearly documented in the schema as 'ERPNext DocType (e.g., Customer, Item)'. The description adds no additional semantic context beyond what the schema provides, so it meets the baseline for high schema coverage.

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 ('Get') and resource ('fields list for a specific DocType'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_doctypes' (which lists DocTypes) or 'get_documents' (which retrieves document instances), leaving some ambiguity about scope.

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 clarify if this should be used before creating/updating documents with 'create_document' or 'update_document', or how it relates to 'get_doctypes' (which lists DocTypes rather than their fields).

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-mcp-server'

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