Skip to main content
Glama

update_document

Modify existing ERPNext records by updating document fields for customers, items, and other data types to maintain accurate business information.

Instructions

Update an existing document in ERPNext

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doctypeYesERPNext DocType (e.g., Customer, Item)
nameYesDocument name/ID
dataYesDocument data to update

Implementation Reference

  • MCP tool handler for 'update_document': validates authentication and parameters, calls erpnext.updateDocument, formats and returns the result or error response.
    case "update_document": { 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); const name = String(request.params.arguments?.name); const data = request.params.arguments?.data as Record<string, any> | undefined; if (!doctype || !name || !data) { throw new McpError( ErrorCode.InvalidParams, "Doctype, name, and data are required" ); } try { const result = await erpnext.updateDocument(doctype, name, data); return { content: [{ type: "text", text: `Updated ${doctype} ${name}\n\n${JSON.stringify(result, null, 2)}` }] }; } catch (error: any) { return { content: [{ type: "text", text: `Failed to update ${doctype} ${name}: ${error?.message || 'Unknown error'}` }], isError: true }; } }
  • Input schema definition for the 'update_document' tool, specifying required parameters: doctype, name, and data.
    name: "update_document", description: "Update an existing document in ERPNext", inputSchema: { type: "object", properties: { doctype: { type: "string", description: "ERPNext DocType (e.g., Customer, Item)" }, name: { type: "string", description: "Document name/ID" }, data: { type: "object", additionalProperties: true, description: "Document data to update" } }, required: ["doctype", "name", "data"] } },
  • Core ERPNextClient method that performs the actual HTTP PUT request to update the document via ERPNext API.
    async updateDocument(doctype: string, name: string, doc: Record<string, any>): Promise<any> { try { const response = await this.axiosInstance.put(`/api/resource/${doctype}/${name}`, { data: doc }); return response.data.data; } catch (error: any) { throw new Error(`Failed to update ${doctype} ${name}: ${error?.message || 'Unknown error'}`); } }
  • src/index.ts:552-552 (registration)
    Invocation of the updateDocument helper within the tool handler.
    const result = await erpnext.updateDocument(doctype, name, data);

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