Skip to main content
Glama

data_list_clients

Retrieve 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

TableJSON Schema
NameRequiredDescriptionDefault
formatNojson

Implementation Reference

  • 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, }; }
  • 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>;
  • 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'));
  • 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);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/paracetamol951/caisse-enregistreuse-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server