order_detail
Retrieve complete order information including sold items, customer details, payment method, and total amount using the order ID.
Instructions
Récupère toutes les informations d’une commande à partir de son identifiant unique, y compris les articles vendus, le client, le mode de paiement et le montant total.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| order_id | Yes |
Implementation Reference
- src/tools/data.ts:162-168 (handler)Handler function for 'order_detail' tool: fetches order details from '/workers/getOrder.php' using shop credentials and order_id, then structures the data for response.async ({ order_id }: getOrderArgs, ctx: Ctx) => { const { shopId, apiKey } = resolveAuth(undefined, ctx); const data = await get('/workers/getOrder.php', { idboutique: shopId, key: apiKey, order_id }); return structData(data); //return { content, structuredContent: isText ? undefined : data }; }
- src/tools/data.ts:15-17 (schema)Zod input schema for 'order_detail' tool defining the required 'order_id' parameter as an integer.const getOrderShape = { order_id: z.number().int(), } satisfies Record<string, ZodTypeAny>;
- src/tools/data.ts:154-169 (registration)Registration of the 'order_detail' tool on the MCP server, specifying title, description, input schema, and inline handler function.server.registerTool( 'order_detail', { title: t('tools.order_detail.title'), description: t('tools.order_detail.description'), inputSchema: getOrderShape, // ZodRawShape, annotations: { readOnlyHint: true } }, async ({ order_id }: getOrderArgs, ctx: Ctx) => { const { shopId, apiKey } = resolveAuth(undefined, ctx); const data = await get('/workers/getOrder.php', { idboutique: shopId, key: apiKey, order_id }); return structData(data); //return { content, structuredContent: isText ? undefined : data }; } );
- src/tools/data.ts:52-73 (helper)Helper function 'structData' used by the handler to format the response with preview content and structured data, handling truncation 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, }; }