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);
Behavior2/5

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

With no annotations, the description carries full burden but provides minimal behavioral context. It states the tool updates documents but doesn't disclose critical traits like required permissions, whether updates are partial/complete, error handling, or side effects. This is inadequate for a mutation tool with zero annotation coverage.

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, efficient sentence with zero wasted words. It's front-loaded with 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?

For a mutation tool with no annotations and no output schema, the description is incomplete. It lacks behavioral details (e.g., permissions, error cases), usage context relative to siblings, and output expectations, leaving significant gaps for an AI agent.

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?

Schema description coverage is 100%, so parameters are fully documented in the schema. The description adds no additional meaning beyond implying 'data' contains update fields, which is already clear from the schema. Baseline 3 is appropriate when the schema does the heavy lifting.

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 action ('Update') and target resource ('an existing document in ERPNext'), making the purpose immediately understandable. It doesn't explicitly differentiate from siblings like 'create_document' or 'get_documents', but the verb 'Update' implies modification rather than creation or retrieval.

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. The description doesn't mention prerequisites (e.g., document must exist), exclusions, or comparisons to siblings like 'create_document' for new documents or 'get_documents' for read-only access.

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