Skip to main content
Glama
paracetamol951

caisse-enregistreuse-mcp-server

Créer une vente

sale_create

Create a new sale transaction in a POS system by specifying payment method and items, which can be catalog products, department items, or custom entries, while optionally linking to an existing customer.

Instructions

Crée une nouvelle vente pour l'établissement. Prend en entrée le mode de paiement (optionnel) et la liste des articles. Chaque article peut être du type « catalogue » (avec productId) ou « rayon » (avec deptId) ou « libre » (avec titre et prix). Vérifier si le client n'existe déjà en utilisant data_list_clients et si le client existe, uniquement préciser idClient. Retourne un objet JSON de confirmation de la vente tel que fourni par l’API distante.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paymentNo
deliveryMethodNo
idtableNo
idcaisseNo
numcouvertsNo
publicCommentNo
privateCommentNo
pagerNumNo
idUserNo
idClientNo
clientNo
itemsYes

Implementation Reference

  • The handler function for the sale_create tool that processes input, builds legacy API request body, encodes items list, calls postForm to /workers/webapp.php, and returns the response.
      async (input: SalesCreateArgs, ctx: Ctx) => {
        const { shopId, apiKey } = resolveAuth(undefined, ctx);
      // ---------- Mode legacy ----------
      const body: Record<string, unknown> = {
          idboutique: shopId,
          key: apiKey
      };
    
        if (input.payment !== undefined) body.payment = input.payment;
        if (input.deliveryMethod !== undefined) body.deliveryMethod = String(input.deliveryMethod);
        if (input.idUser !== undefined) body.idUser = input.idUser;
        if (input.idtable !== undefined) body.idtable = input.idtable;
        if (input.idcaisse !== undefined) body.idcaisse = input.idcaisse;
        if (input.numcouverts !== undefined) body.numcouverts = input.numcouverts;
        if (input.publicComment !== undefined) body.publicComment = input.publicComment;
        if (input.privateComment !== undefined) body.privateComment = input.privateComment;
        if (input.pagerNum !== undefined) body.pagerNum = input.pagerNum;
    
    
      if (input.idClient !== undefined) body.idClient = input.idClient;
      if (!input.idClient && input.client) {
        // Le legacy aime les clés client[...]
        for (const [k, v] of Object.entries(input.client)) {
          if (v !== undefined && v !== null && v !== '') {
            body[`client[${k}]`] = String(v);
          }
        }
      }
      body['itemsList[]'] = encodeItemsList(input.items);
    
      const data = await postForm('/workers/webapp.php', body);
    
      return {
        content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
        structuredContent: data,
      };
    }
  • Zod input schema (SalesCreateShape) for the sale_create tool, defining parameters like payment, deliveryMethod, client details, and items array. References ClientShape and SalesItemShape.
    const SalesCreateShape = {
    
        payment: z.union([z.number(), z.string()]).transform((v) => Number(v)).optional(),
      deliveryMethod: z.union([
        z.number().int().min(0).max(6),
        z.enum(['0','1','2','3','4','5','6'])
      ]).transform((v) => Number(v)).optional(),
    
        idtable: z.union([z.number().int(), z.string()]).optional(),
        idcaisse: z.union([z.number().int(), z.string()]).optional(),
        numcouverts: z.union([z.number().int(), z.string()]).optional(),
        publicComment: z.string().optional(),
        privateComment: z.string().optional(),
        pagerNum: z.union([z.number().int(), z.string()]).optional(),
        idUser: z.union([z.number().int(), z.string()]).optional(),
      idClient: z.union([z.number().int(), z.string()]).optional(),
      client: z.object(ClientShape).partial().optional(),
    
      items: z.array(z.object(SalesItemShape)).min(1),
    } satisfies Record<string, ZodTypeAny>;
  • MCP server registration of the sale_create tool within registerSalesTools, specifying name, i18n title/description, input schema, and handler function.
    server.registerTool(
      'sale_create',
      {
        title: t('tools.sale_create.title'),
        description: t('tools.sale_create.description'),
        inputSchema: SalesCreateShape, // ✅ ZodRawShape
      },
        async (input: SalesCreateArgs, ctx: Ctx) => {
          const { shopId, apiKey } = resolveAuth(undefined, ctx);
        // ---------- Mode legacy ----------
        const body: Record<string, unknown> = {
            idboutique: shopId,
            key: apiKey
        };
    
          if (input.payment !== undefined) body.payment = input.payment;
          if (input.deliveryMethod !== undefined) body.deliveryMethod = String(input.deliveryMethod);
          if (input.idUser !== undefined) body.idUser = input.idUser;
          if (input.idtable !== undefined) body.idtable = input.idtable;
          if (input.idcaisse !== undefined) body.idcaisse = input.idcaisse;
          if (input.numcouverts !== undefined) body.numcouverts = input.numcouverts;
          if (input.publicComment !== undefined) body.publicComment = input.publicComment;
          if (input.privateComment !== undefined) body.privateComment = input.privateComment;
          if (input.pagerNum !== undefined) body.pagerNum = input.pagerNum;
    
    
        if (input.idClient !== undefined) body.idClient = input.idClient;
        if (!input.idClient && input.client) {
          // Le legacy aime les clés client[...]
          for (const [k, v] of Object.entries(input.client)) {
            if (v !== undefined && v !== null && v !== '') {
              body[`client[${k}]`] = String(v);
            }
          }
        }
        body['itemsList[]'] = encodeItemsList(input.items);
    
        const data = await postForm('/workers/webapp.php', body);
    
        return {
          content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
          structuredContent: data,
        };
      }
    );
  • Helper function to encode the items array into the legacy 'itemsList[]' string format required by the API.
    function encodeItemsList(items: SalesCreateArgs['items']): string[] {
      const out: string[] = [];
      for (const it of items) {
          if (it.type === 'catalog') {
              const parts = [
                  it.productId ?? '',
                  it.quantity ?? 1,
                  it.titleOverride ?? '',
                  it.priceOverride ?? '',
              ];
              if (it.declinaisons?.length) parts.push(...it.declinaisons);
              out.push(parts.join('_'));
          } else if (it.type === 'free') {
              const parts = [
                  'Free',
                  it.priceOverride ?? '',
                  it.titleOverride ?? '',
              ];
              out.push(parts.join('_'));
          } else {
              // ligne libre : -<departmentId>_<price>_<title>
              out.push(`-${it.departmentId ?? ''}_${it.price ?? ''}_${it.title ?? ''}`);
          }
      }
      return out;
    }
  • src/index.ts:61-61 (registration)
    Invocation of registerSalesTools to register sale tools including sale_create in the main MCP server setup.
    registerSalesTools(mcpServer);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool 'returns a JSON confirmation object as provided by the remote API,' which is helpful, but doesn't address critical behavioral aspects like whether this is a write operation (implied by 'creates'), error conditions, authentication requirements, rate limits, or what happens with invalid inputs. The description is insufficient for a mutation tool with complex parameters.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is reasonably concise and front-loaded with the main purpose. It uses three sentences that each add value: creation purpose, parameter guidance, and return value. There's no wasted text, though it could be slightly more structured for clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (12 parameters, nested objects, no annotations, no output schema), the description is incomplete. It covers some parameter semantics and mentions the return format, but fails to address behavioral transparency, many parameters, error handling, or usage context adequately. For a mutation tool with this complexity, more comprehensive guidance is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant semantic value beyond the schema, which has 0% description coverage. It explains that payment mode is optional, items are required, and details three types of items (catalog, department, free) with their required fields. However, it doesn't cover all 12 parameters, leaving many undocumented (like deliveryMethod, idtable, etc.).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Crée une nouvelle vente pour l'établissement' (Creates a new sale for the establishment). It specifies the verb (creates) and resource (sale), but doesn't explicitly differentiate from sibling tools like 'order_detail' or 'data_list_orders' beyond mentioning client checking with 'data_list_clients'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides implied usage guidance by mentioning to check if a client exists using 'data_list_clients' and specifying that if the client exists, only 'idClient' should be provided. However, it doesn't explicitly state when to use this tool versus alternatives like 'order_detail' or provide clear prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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