Skip to main content
Glama

Update Purchase Order Lines

update_purchase_order_lines
Destructive

Edit the lines of a DRAFT purchase order (status created) the way the Purchase Orders page's Save does: add lines (addLines — itemSku or itemId + quantity, optional unitCost; an omitted cost is priced from the vendor's price book, then the item's catalog cost, then its last purchase), change lines (updateLines — the line's id or its SKU, plus a new quantity and/or unitCost), and remove lines (removeLineIds — line ids, or SKUs on exactly one line). Lines you do not name stay as they are. Line ids come from get_purchase_order_receiving. An order that was already issued, is awaiting approval or is further along cannot be edited here. The preview lists the resulting lines, what is added, changed and removed, and the new total; its receipt is bound to the order's current state, so an edit landing in between rejects the commit. Saving gives every line a new id. Max 500 resulting lines.

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": {
      "purchaseOrder": "<purchaseOrder>"
    },
    "name": "update_purchase_order_lines"
  }
}

Input Schema

NameRequiredDescriptionDefault
previewNoStep 1 of the required two-step write: set true to validate and receive the resulting lines plus a single-use previewReceipt. Nothing changes until the commit call.
addLinesNoLines to add (each itemSku or itemId + quantity, optional unitCost/expense).
updateLinesNoExisting lines to change, by line id or SKU.
purchaseOrderYesPurchase order id (GUID) or document number (e.g. PO-1042).
removeLineIdsNoExisting lines to remove: line ids (GUIDs) or SKUs on exactly one line.
idempotencyKeyNoCaller-generated idempotency key; required with previewReceipt to commit.
previewReceiptNoStep 2 of the required two-step write: the receipt returned by the preview call. Supply together with a fresh idempotencyKey to commit; calls without it are refused.

Output Schema

NameRequiredDescriptionDefault
okNo
numberNo
statusNo
previewNo
warningsNo
expiresAtNo
lineCountNo
linesAddedNo
totalAmountNo
actionItemIdNo
confirmationNo
linesChangedNo
linesRemovedNo
correlationIdNo
totalQuantityNo
approvalResultNo
idempotencyKeyNo
previewReceiptNo
purchaseOrderIdNo
approvalRequiredNo
approvalRuleNameNo
idempotentReplayNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.4/5.0
Behavior5/5

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

Beyond the annotations (destructive=true, idempotent=false), the description discloses that lines not named are left alone, that the preview is a required two-step write with a single-use receipt bound to the order's current state, that a concurrent edit rejects the commit, that saving regenerates every line id, and the 500-line cap. These are exactly the behavioral facts an agent needs before a destructive write.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The scope statement is front-loaded and every sentence carries operational information — pricing fallbacks, receipt binding, id re-assignment, line cap. It is a long, dense paragraph with a slightly run-on middle section, but there is little filler to cut.

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

Completeness5/5

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

For a destructive, two-step, multi-mode mutation this is thorough: it covers what can be edited, what happens on preview, what invalidates a commit, and what changes after save. With an output schema present, it correctly omits return-value detail while still explaining the preview's contents.

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 the schema already documents each parameter in detail, including the pricing fallback chain. The description largely restates those groupings (addLines/updateLines/removeLineIds) rather than adding new meaning, so baseline 3 is appropriate despite the clarity of the summary.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource ('Edit the lines of a DRAFT purchase order (status created)') and enumerates the three operations — add, change, remove — so an agent can tell instantly what the tool mutates. The draft-only scope cleanly separates it from siblings like issue_purchase_order or transition_purchase_order.

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?

It states the preconditions (order must be status 'created') and explicit exclusions ('already issued, is awaiting approval or is further along cannot be edited here'), plus it points to get_purchase_order_receiving as the source for line ids. It does not name which sibling to use for those excluded states, so it stops short of full alternative routing.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources