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"] } },

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