Skip to main content
Glama

data_list_payments_modes

Retrieve available payment methods from a sales recorder system. Supports JSON, CSV, or HTML formats for integration with POS and cash register applications.

Instructions

Liste des Lister les modes de paiement

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNojson

Implementation Reference

  • Handler function that authenticates with the shop, fetches payment modes data from '/workers/getPaymentModes.php' using the HTTP 'get' utility, logs the result, structures the response using 'structData', 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, }; }
  • Shared input schema used by the tool for parameter validation, supporting 'json', 'csv', or 'html' output formats.
    const CommonShape = { format: z.enum(['json', 'csv', 'html']).default('json'), } satisfies Record<string, ZodTypeAny>;
  • Registers the MCP tool 'data_list_payments_modes' by calling the 'registerSimple' helper, specifying the backend PHP endpoint and localized title/description.
    registerSimple(server, 'data_list_payments_modes', '/workers/getPaymentModes.php', t('tools.data_list_payments.description'), t('tools.data_list_payments.title'));
  • Utility function called by the handler to prepare the tool response, creating a text preview and structured content for MCP compliance.
    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, }; }

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