Retourne la liste des clients enregistrés dans la boutique, incluant leurs informations de contact, points de fidélité...
data_list_clientsRetrieve and display client information from the sales recorder system in JSON, CSV, or HTML format for management and reporting purposes.
Instructions
Liste des Lister les clients
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | json |
Implementation Reference
- src/tools/data.ts:90-114 (handler)Handler function executed for the data_list_clients tool. It resolves authentication, makes an HTTP GET request to the PHP endpoint '/workers/getClients.php' with shop ID, API key, and format parameter, logs the result, structures the data for MCP response, and handles errors gracefully.
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)Input schema for the data_list_clients tool, defining the optional 'format' parameter with possible values 'json', 'csv', or 'html' (defaults to 'json').
const CommonShape = { format: z.enum(['json', 'csv', 'html']).default('json'), } satisfies Record<string, ZodTypeAny>; - src/tools/data.ts:125-125 (registration)Registers the 'data_list_clients' tool using the registerSimple helper, specifying the backend PHP endpoint and localized title/description.
registerSimple(server, 'data_list_clients', '/workers/getClients.php', t('tools.data_list_clients.description'), t('tools.data_list_clients.title')); - src/tools/data.ts:52-73 (helper)Utility function to format large data responses for MCP tools, creating a text preview and structuredContent to avoid truncation issues.
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, }; } - src/index.ts:62-62 (registration)Invocation of registerDataTools on the main MCP server instance, which includes registration of data_list_clients among other data list tools.
registerDataTools(mcpServer);