Skip to main content
Glama
ERPNext MCP Server

ERPNext MCP Server

by hatlabs

get_child_documents

Query child table rows by joining parent and child DocTypes, avoiding 403 errors from direct child queries and returning one row per matching child row.

Instructions

Query child table rows by joining parent and child DocTypes. Direct child table queries return 403; this tool queries the parent DocType with child table field joins. Returns one row per matching child table row.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "parent_doctype": "<parent_doctype>",
      "child_doctype": "<child_doctype>"
    },
    "name": "get_child_documents"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNoMaximum number of rows to return (default: 100)
child_fieldsNoFields from the child table (e.g., ["item_code", "qty", "rate"]). Automatically prefixed with child table reference.
child_doctypeYesChild table DocType (e.g., BOM Item, Purchase Order Item, Sales Order Item)
child_filtersNoFilters on child table fields as [field, operator, value] triples (e.g., [["item_code", "like", "%CM5%"]])
parent_fieldsNoFields from the parent document (e.g., ["name", "item", "total_cost"]). Defaults to ["name"].
parent_doctypeYesParent DocType (e.g., BOM, Purchase Order, Sales Order)
parent_filtersNoFilters on parent document fields, same format as get_documents filters (e.g., {"is_active": 1, "docstatus": ["=", "1"]})

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does disclose key traits: the 403 restriction on direct child queries, the join-based workaround, and the return cardinality (one row per matching child row). It stops short of covering permission/auth requirements or how the default limit of 100 interacts with pagination.

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?

Three short sentences, each front-loaded with a distinct fact: what it does, why it exists (403 workaround), and what it returns. No redundant wording.

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

Completeness4/5

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

For a 7-parameter tool with 100% schema coverage and no output schema, the description supplies the essential return-shape fact (one row per child row) and the constraint motivating the tool. Only minor gaps remain, such as pagination behavior beyond the default limit.

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%, including per-field examples for child_fields, child_filters triples, and parent_filters, so the schema does the heavy lifting. The description adds no parameter-level meaning beyond what those property descriptions already state, so the baseline 3 applies.

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?

States a specific verb and resource ('Query child table rows') and explains the mechanism (parent DocType queried with child table field joins). It implicitly distinguishes itself from get_documents by scoping to child rows, though it never names the sibling explicitly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explains the operative condition for using it: direct child table queries return 403, so child data must be fetched via the parent. It lacks an explicit 'use get_documents instead when you only need parent fields' routing statement, but the context is clear enough to select correctly.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.