Skip to main content
Glama

Import Historical Sales Orders

import_historical_sales_orders
Idempotent

Import HISTORICAL sales orders (already fulfilled in a previous system). They feed demand velocity, forecasting, and reporting but never touch current inventory: no reservations, no pick lists, no notifications. Orders are written as completed+paid, dated from each order's orderDate (required). By default the import also seeds the catalog: items (by SKU/UPC), customers (by email/name), and UOMs referenced by the history are created when missing, so a fresh tenant can be populated from its order history alone. Idempotent: orders whose customerPurchaseOrder or orderNumber already exist are skipped, so retrying or chunking a large history is safe. Import no more than the latest 36 months: sales history establishes total item velocity, while customer fields preserve attribution and do not create separate forecasts. For reliable inline calls, prefer batches of 100 orders or fewer (500 is the hard ceiling), and pass the first result's importSessionId into later chunks. 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 (order 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. LARGE HISTORIES: for more than ~100 orders when a raw CSV/XLSX export is available, use create_import_session instead: the customer uploads the file directly and the server maps/validates/commits it without the rows ever entering your context. Every commit returns an importSessionId (rollback lineage): rollback_import_session undoes the whole import by that id, and passing the id back into later chunked calls keeps one history under one session so a single rollback undoes all of it.

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_sales_orders"
  }
}

Input Schema

NameRequiredDescriptionDefault
ordersYesThe historical orders to import (prefer 100 or fewer per inline call; hard max 500).
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.
storeIdNoOptional STORE id (GUID); the tenant's default store when omitted. Get store ids from list_warehouses (each warehouse row lists its stores with their storeId) — a warehouse id is not a store id, even though a warehouse's companion store shares its name.
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.
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.
importSessionIdNoOptional: the importSessionId returned by an earlier chunk of this SAME history — joins this chunk to that session so ONE rollback_import_session call undoes the whole import. Omit on the first chunk; a new session is created and its id returned.
createMissingEntitiesNoCreate items, customers, and UOMs that the orders reference but the tenant doesn't have yet (default true). When false, unknown SKUs become item-less text lines that are invisible to velocity/forecasting.

Output Schema

NameRequiredDescriptionDefault
okNo
errorsNo
failedNo
previewNo
skippedNo
importedNo
warningsNo
expiresAtNo
uomsCreatedNo
actionItemIdNo
confirmationNo
itemsCreatedNo
correlationIdNo
approvalResultNo
idempotencyKeyNo
previewReceiptNo
backtestSummaryNo
importSessionIdNo
customersCreatedNo
idempotentReplayNo
importedOrderIdsNo
backtestMedianMapeNo
backtestPooledWapeNo
projectionsPendingNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.6/5.0
Behavior4/5

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

Annotations already declare idempotentHint=true and destructiveHint=false, but the description adds substantial context beyond them: orders land as completed+paid, the import never creates reservations or notifications, catalog entities are seeded by default, dedup is by customerPurchaseOrder/orderNumber, and a bare commit is refused with PREVIEW_RECEIPT_REQUIRED. The scarce remaining gap is the return shape, which is partly covered by the existing output schema and the mention of importSessionId.

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?

Dense but front-loaded: the historical-only scope comes first, then the two-step protocol, then batching, then the large-history alternative, marked with caps for scanning. It is one long block with no visual breaks and a few clauses that could be trimmed, but nearly every sentence carries operational information.

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-free but complex multi-step import with 8 parameters, the description covers the write protocol, chunking, the 36-month constraint, entity seeding, dedup, credential nuances, and rollback lineage, and it defers return details to a schema that exists. An agent can execute correctly from this text alone.

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 a 3 would be defensible, but the description connects parameters into workflows the schema does not: passing importSessionId across chunks so one rollback undoes everything, pairing previewReceipt with a fresh idempotencyKey, and the consequence of createMissingEntities=false (item-less text lines invisible to forecasting). That is meaning beyond per-field documentation.

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?

States a specific verb and resource ("Import HISTORICAL sales orders (already fulfilled in a previous system)") and immediately delimits scope: "never touch current inventory: no reservations, no pick lists, no notifications." That cleanly separates it from create_sales_order, push_external_sales_orders, and import_historical_purchase_orders without needing their 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?

Gives explicit when-to-use and when-to-use-something-else rules: inline calls for <=100 orders, and "for more than ~100 orders when a raw CSV/XLSX export is available, use create_import_session instead," plus rollback via rollback_import_session. It also states the mandatory preview/commit protocol and the 36-month ceiling, leaving nothing to inference.

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