data_list_orders
Retrieve unvalidated quotes or validated orders from a cash register system within specified date ranges, with optional delivery method filtering.
Instructions
Listez soit les commandes non validées (les devis) dont la date de création est comprise entre from_date_ISO8601 et to_date_ISO8601, soit les commandes validées (dénommées commandes ou factures) dont la date de valeur est comprise entre from_date_ISO8601 et to_date_ISO8601. Vous pouvez également filtrer les modes de livraison (avec filterDeliveryMethod).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| validatedOrders | Yes | ||
| from_date_ISO8601 | Yes | ||
| to_date_ISO8601 | Yes | ||
| filterDeliveryMethod | No |
Implementation Reference
- src/tools/data.ts:145-151 (handler)Handler function that resolves shop authentication, fetches filtered orders from '/workers/getOrders.php', and returns structured data using the structData helper.async ({ validatedOrders, from_date_ISO8601, to_date_ISO8601, filterDeliveryMethod }: getOrdersArgs, ctx: Ctx) => { const { shopId, apiKey } = resolveAuth(undefined, ctx); const data = await get('/workers/getOrders.php', { idboutique: shopId, key: apiKey, validatedOrders, from_date_ISO8601, to_date_ISO8601, filterDeliveryMethod }); return structData(data); //return { content, structuredContent: isText ? undefined : data }; }
- src/tools/data.ts:19-28 (schema)Zod schema defining input parameters for the data_list_orders tool: validatedOrders (boolean), date ranges, and optional delivery method filter.const getOrdersShape = { validatedOrders: z.boolean(), from_date_ISO8601: z.string().datetime(), to_date_ISO8601: z.string().datetime(), filterDeliveryMethod: z.union([ z.number().int().min(0).max(6), z.enum(['0', '1', '2', '3', '4', '5', '6']) ]).transform((v) => Number(v)).optional(), } satisfies Record<string, ZodTypeAny>;
- src/tools/data.ts:137-152 (registration)Registration of the 'data_list_orders' tool using server.registerTool, including title, description from i18n, input schema, annotations, and the handler function.server.registerTool( 'data_list_orders', { title: t('tools.data_list_orders.title'), description: t('tools.data_list_orders.description'), inputSchema: getOrdersShape, // ZodRawShape, annotations: { readOnlyHint: true } }, async ({ validatedOrders, from_date_ISO8601, to_date_ISO8601, filterDeliveryMethod }: getOrdersArgs, ctx: Ctx) => { const { shopId, apiKey } = resolveAuth(undefined, ctx); const data = await get('/workers/getOrders.php', { idboutique: shopId, key: apiKey, validatedOrders, from_date_ISO8601, to_date_ISO8601, filterDeliveryMethod }); return structData(data); //return { content, structuredContent: isText ? undefined : data }; } );
- src/tools/data.ts:52-73 (helper)Helper function used by the handler to format the raw data into MCP-compatible response with preview content and structuredContent, handling large arrays and serialization safely.function structData(data: any) { // on ne touche PAS à structuredContent (c’est ce que ChatGPT utilise) const light = Array.isArray(data) ? data.slice(0, 5000)//.map(({ id, nom, email, tel, ...r }) => ({ id, nom, email, tel })) : data; const maxLength = 40000; const preview = typeof light === 'string' ? (light.length > maxLength ? light.slice(0, maxLength) + '…(truncated)' : light) : safeStringify(light, 2, maxLength); // <-- aperçu court et “safe” const wrapped = Array.isArray(data) ? { data: data } : data && typeof data === 'object' ? data : { data: data }; return { content: [{ type: 'text', text: preview }], structuredContent: wrapped, }; }