Skip to main content
Glama

get_doctypes

Retrieve all available document types from ERPNext to understand data structures and manage business records.

Instructions

Get a list of all available DocTypes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler implementation for the 'get_doctypes' tool. Checks authentication, calls erpnext.getAllDocTypes(), and returns the list as JSON or error.
    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 }; } }
  • src/index.ts:327-334 (registration)
    Tool registration in ListToolsRequestSchema handler, including name, description, and empty input schema.
    { name: "get_doctypes", description: "Get a list of all available DocTypes", inputSchema: { type: "object", properties: {} } },
  • Input schema for get_doctypes tool (empty object).
    inputSchema: { type: "object", properties: {} }
  • ERPNextClient method getAllDocTypes() that fetches DocTypes via API with fallback methods. Called by the tool handler.
    // Get all available DocTypes 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" ]; } } }

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/Web3ViraLabs/ERPNext-MCP-Server'

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