data_list_delivery_zones
Retrieve delivery zone information from the cash register system in JSON, CSV, or HTML formats for operational management.
Instructions
Liste des Lister les zones de livraison
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | json |
Implementation Reference
- src/tools/data.ts:90-114 (handler)The handler function that executes the tool logic: resolves auth, makes HTTP GET to the PHP endpoint '/workers/getDeliveryZones.php' with shopId, apiKey, format; structures the data response using structData; logs and handles errors.async ({ format }: CommonArgs, ctx: Ctx) => { try { const { shopId, apiKey } = resolveAuth(undefined, ctx); const data = await get(path, { idboutique: shopId, key: apiKey, format }); process.stderr.write( `[caisse][tool:${toolName}] ok type=${Array.isArray(data) ? 'array' : typeof data}` + (Array.isArray(data) ? ` len=${data.length}` : '') + '\n' ); //Array.isArray(data) ? data.slice(0, 50) : data const funcResult = structData( data); process.stderr.write(`[caisse][RES] ${JSON.stringify(data)} \n`); process.stderr.write(`[caisse][RES] funcResult ${JSON.stringify(funcResult)} \n`); return funcResult; //return { content, structuredContent: isText ? undefined : data }; } catch (e) { process.stderr.write(`[caisse][tool:${toolName}][error]\n`); process.stderr.write(`[caisse][tool:${toolName}][error] ${(e as Error).message}\n`); // renvoyer un message "propre" plutôt que laisser l’exception devenir un 424 return { content: [{ type: 'text', text: `Erreur pendant la préparation de la réponse: ${(e as Error).message}` }], is_error: true, }; }
- src/tools/data.ts:11-13 (schema)Common input schema for simple list tools including 'data_list_delivery_zones': optional format parameter (json, csv, html).const CommonShape = { format: z.enum(['json', 'csv', 'html']).default('json'), } satisfies Record<string, ZodTypeAny>;
- src/tools/data.ts:130-130 (registration)Registration call for the 'data_list_delivery_zones' tool using the generic registerSimple helper, specifying the PHP backend endpoint.registerSimple(server, 'data_list_delivery_zones', '/workers/getDeliveryZones.php', t('tools.data_list_delivery_zones.description'), t('tools.data_list_delivery_zones.title'));
- src/tools/data.ts:75-117 (helper)Generic registerSimple helper function that registers the tool with schema, title/desc, and shared handler logic.function registerSimple( server: McpServer | any, toolName: string, path: string, title: string, entityLabel: string ) { server.registerTool( toolName, { title, description: `Liste des ${entityLabel}`, inputSchema: CommonShape, // ZodRawShape, annotations: { readOnlyHint: true } }, async ({ format }: CommonArgs, ctx: Ctx) => { try { const { shopId, apiKey } = resolveAuth(undefined, ctx); const data = await get(path, { idboutique: shopId, key: apiKey, format }); process.stderr.write( `[caisse][tool:${toolName}] ok type=${Array.isArray(data) ? 'array' : typeof data}` + (Array.isArray(data) ? ` len=${data.length}` : '') + '\n' ); //Array.isArray(data) ? data.slice(0, 50) : data const funcResult = structData( data); process.stderr.write(`[caisse][RES] ${JSON.stringify(data)} \n`); process.stderr.write(`[caisse][RES] funcResult ${JSON.stringify(funcResult)} \n`); return funcResult; //return { content, structuredContent: isText ? undefined : data }; } catch (e) { process.stderr.write(`[caisse][tool:${toolName}][error]\n`); process.stderr.write(`[caisse][tool:${toolName}][error] ${(e as Error).message}\n`); // renvoyer un message "propre" plutôt que laisser l’exception devenir un 424 return { content: [{ type: 'text', text: `Erreur pendant la préparation de la réponse: ${(e as Error).message}` }], is_error: true, }; } } ); }
- src/index.ts:62-62 (registration)Top-level call to registerDataTools which includes the registration of 'data_list_delivery_zones' among other data tools.registerDataTools(mcpServer);