Skip to main content
Glama

Import Historical Purchase Orders

import_historical_purchase_orders
Idempotent

Import HISTORICAL purchase orders (already received in a previous system). receivedDate − orderDate becomes the OBSERVED LEAD TIME the reorder engine reads (POs from the last 12 months count; it needs at least 3 per item to beat the vendor default), so spread real dates rather than inventing them. Also seeds the purchasing graph: vendors are created by name (new ones get a default lead time from the batch average), unknown items are created costed from their PO line, ItemSupplier vendor-terms links (with MOQ) are created per (item, vendor) pair, and items without a default vendor get one. Never touches inventory — use set_inventory_levels for opening stock. Idempotent: POs whose number already exists are skipped, so retrying or chunking is safe. Max 500 orders per call. Operator (unpinned) credentials on 3PL tenants pass clientId to name the client the history belongs to. Requires the governed two-step protocol: call with preview=true to validate and receive a parse report (PO count, would-create counts, sample) plus a single-use previewReceipt, then repeat the identical call with that previewReceipt and a fresh idempotencyKey to commit — a bare call is refused with PREVIEW_RECEIPT_REQUIRED.

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": {
      "orders": "<orders>"
    },
    "name": "import_historical_purchase_orders"
  }
}

Input Schema

NameRequiredDescriptionDefault
ordersYesThe historical purchase orders to import (max 500 per call).
previewNoStep 1 of the required two-step write: set true to validate and receive a structured preview plus a single-use previewReceipt. Nothing is imported until the commit call.
clientIdNoOperator (unpinned) credentials on 3PL tenants: the target client id (GUID) the imported history belongs to — get ids from list_clients. Client-pinned credentials omit this; the credential decides.
warehouseIdNoOptional destination warehouse id (GUID); left unset on the imported POs when omitted (lead-time math does not use it).
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.
supplierAliasesNoOptional vendor-name aliases to resolve spelling inconsistencies before import. Keys are variant names found in the data, values are the canonical name to use. Preview surfaces vendorCollisions — use them to build this map, then re-preview or commit with the aliases applied.
createMissingItemsNoCreate items that the POs reference but the tenant doesn't have yet (default true). Vendors and vendor links are always seeded.

Output Schema

NameRequiredDescriptionDefault
okNo
errorsNo
failedNo
previewNo
skippedNo
importedNo
warningsNo
expiresAtNo
uomsCreatedNo
actionItemIdNo
confirmationNo
itemsCreatedNo
correlationIdNo
approvalResultNo
failureDetailsNo
idempotencyKeyNo
previewReceiptNo
idempotentReplayNo
suppliersCreatedNo
projectionsPendingNo
defaultSuppliersSetNo
importedPurchaseOrderIdsNo
itemSupplierLinksCreatedNo
itemsWithSeveralSuppliersNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Annotations declare only readOnly/destructive/idempotent/openWorld hints, but the description discloses the substantive side effects: creating vendors by name, creating unknown items with costs, seeding ItemSupplier links with MOQ, assigning default vendors, and how cancelled POs are excluded from lead-time and inbound quantity. It also explains the idempotency mechanism (PO-number dedup makes retries/chunking safe), the preview-receipt requirement, and operator-credential clientId behavior — well beyond what the annotations convey.

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 purpose and the most consequential constraint (lead-time observation) are front-loaded, and virtually every sentence adds operational value for a complex migration tool. It is dense and runs as one monolithic paragraph, lacking visual separation between behavior, limits, and protocol, which slightly hurts scanability.

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 complex, multi-effect import with an output schema present, the description covers the pipeline effects, the preview report contents, idempotency, size limits, credential scoping, and the two-step commit flow. Nothing an agent needs to invoke it safely and correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3; the description adds real meaning on top by explaining how receivedDate−orderDate becomes observed lead time and warning to 'spread real dates rather than inventing them.' It also outlines the supplierAliases workflow driven by preview-surfaced vendorCollisions, which is semantic guidance the schema alone does not provide.

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 opening sentence names a specific verb+resource (import historical purchase orders) and immediately scopes it ('already received in a previous system'), distinguishing it from sibling import tools. It also explicitly disclaims the neighboring domain ('Never touches inventory — use set_inventory_levels for opening stock'), so an agent can tell it apart from set_inventory_levels and import_historical_sales_orders without reading schemas.

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

Usage Guidelines5/5

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

It gives explicit usage conditions (historical, already-received POs; last 12 months count toward lead time; at least 3 per item needed), names the alternative for opening stock, states the 500-order cap, and spells out the mandatory two-step preview/commit protocol with the exact refusal error. Both when-to-use and when-not-to-use are covered.

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