Skip to main content
Glama
paracetamol951

caisse-enregistreuse-mcp-server

Récupère la liste complète des articles (produits) enregistrés dans la boutique. Retourne un tableau d’articles contenant les champs id, titre, prix, rayon, TVA, etc. Le paramètre optionnel 'format' permet de choisir la sortie (json, csv ou html).

data_list_products
Read-only

Retrieve product listings from a sales recorder system in JSON, CSV, or HTML formats for inventory management and reporting.

Instructions

Liste des Lister les articles

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNojson

Implementation Reference

  • Handler function that resolves authentication, makes an HTTP GET request to the PHP endpoint '/workers/getPlus.php' with shop credentials and format, processes the data with structData helper, logs details, and returns structured content or an error message.
    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 Zod input schema for 'data_list_products' and similar list tools, defining an optional 'format' parameter defaulting to 'json'.
    const CommonShape = {
        format: z.enum(['json', 'csv', 'html']).default('json'),
    } satisfies Record<string, ZodTypeAny>;
  • Registers the 'data_list_products' tool using the registerSimple helper, providing title, description from i18n, and the backend PHP endpoint.
    registerSimple(server, 'data_list_products', '/workers/getPlus.php', t('tools.data_list_products.description'), t('tools.data_list_products.title'));
  • Helper utility used by the handler to create MCP-compatible response with preview text content and full structuredContent, safely handling large data and truncation.
    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,
        };
    }
  • Helper function that registers simple list tools like 'data_list_products', defining shared schema, description, and a generic handler that proxies to a PHP endpoint.
    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,
                    };
                }
            }
        );
    }

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