Skip to main content
Glama
Yonsn76

MyPos MCP

by Yonsn76

insertarDatos

Add new records to database tables by providing an array of data objects. This tool inserts one or multiple rows into specified tables without modifying existing data or table structure.

Instructions

Sigue estas reglas para insertar datos: PROPÓSITO: Insertar uno o varios registros (filas) nuevos en una tabla. REGLA: Solo debe usarse para agregar datos nuevos. No la uses para actualizar registros existentes ni para modificar la estructura de la tabla. FORMATO: Los datos deben ser un array de objetos, donde cada objeto es un registro. EJEMPLO: "Agrega un cliente con nombre Juan a la tabla clientes."

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
datosYesArray de objetos con los datos a insertar
tablaYesNombre de la tabla

Implementation Reference

  • Executes the insertion of one or more records into the specified table. Constructs parameterized INSERT SQL dynamically from data objects, supports multiple DB types via placeholders, uses query_runner for execution, and returns success count or error.
    async ({ tabla, datos }) => {
      try {
        if (!datos || !Array.isArray(datos) || datos.length === 0) {
          return {
            isError: true,
            content: [{ type: 'text', text: 'Debes proporcionar un array de datos para insertar.' }]
          };
        }
        let insertedCount = 0;
        for (const registro of datos) {
          const columnas = Object.keys(registro);
          const valores = Object.values(registro);
          const placeholders = makePlaceholders(db_type, valores.length).join(', ');
          const columnasStr = columnas.map(col => quoteIdent(col)).join(', ');
          const sql = `INSERT INTO ${quoteIdent(tabla)} (${columnasStr}) VALUES (${placeholders})`;
          await query_runner.runQueryWithParams(sql, valores);
          insertedCount++;
        }
        return { 
          content: [{ 
            type: 'text', 
            text: `Se insertaron ${insertedCount} registro(s) en la tabla '${tabla}' exitosamente.` 
          }] 
        };
      } catch (e) {
        return {
          isError: true,
          content: [{ type: 'text', text: 'Error al insertar datos: ' + (e.message || e) }]
        };
      }
    }
  • Zod input schema defining 'tabla' as string and 'datos' as array of objects for validation.
    {
      tabla: z.string().describe('Nombre de la tabla'),
      datos: z.array(z.record(z.any())).describe('Array de objetos con los datos a insertar'),
    },
  • mcp_server.js:313-355 (registration)
    Full registration of the 'insertarDatos' tool using server.tool(), including description, input schema, and inline handler function.
    server.tool(
      'insertarDatos',
      'Sigue estas reglas para insertar datos:\n'
      + 'PROPÓSITO: Insertar uno o varios registros (filas) nuevos en una tabla.\n'
      + 'REGLA: Solo debe usarse para agregar datos nuevos. No la uses para actualizar registros existentes ni para modificar la estructura de la tabla.\n'
      + 'FORMATO: Los datos deben ser un array de objetos, donde cada objeto es un registro.\n'
      + 'EJEMPLO: "Agrega un cliente con nombre Juan a la tabla clientes."',
      {
        tabla: z.string().describe('Nombre de la tabla'),
        datos: z.array(z.record(z.any())).describe('Array de objetos con los datos a insertar'),
      },
      async ({ tabla, datos }) => {
        try {
          if (!datos || !Array.isArray(datos) || datos.length === 0) {
            return {
              isError: true,
              content: [{ type: 'text', text: 'Debes proporcionar un array de datos para insertar.' }]
            };
          }
          let insertedCount = 0;
          for (const registro of datos) {
            const columnas = Object.keys(registro);
            const valores = Object.values(registro);
            const placeholders = makePlaceholders(db_type, valores.length).join(', ');
            const columnasStr = columnas.map(col => quoteIdent(col)).join(', ');
            const sql = `INSERT INTO ${quoteIdent(tabla)} (${columnasStr}) VALUES (${placeholders})`;
            await query_runner.runQueryWithParams(sql, valores);
            insertedCount++;
          }
          return { 
            content: [{ 
              type: 'text', 
              text: `Se insertaron ${insertedCount} registro(s) en la tabla '${tabla}' exitosamente.` 
            }] 
          };
        } catch (e) {
          return {
            isError: true,
            content: [{ type: 'text', text: 'Error al insertar datos: ' + (e.message || e) }]
          };
        }
      }
    );
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It describes the basic behavior (inserting new records) and includes a usage rule about not updating existing records. However, it lacks details about permissions needed, error handling, transaction behavior, or what happens on duplicate keys. For a mutation tool with zero annotation coverage, this provides some behavioral context but leaves significant gaps in understanding the full operational characteristics.

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

Conciseness5/5

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

The description is well-structured with clear sections (PROPÓSITO, REGLA, FORMATO, EJEMPLO) and every sentence earns its place. It's front-loaded with the purpose, followed by important rules and format specifications, ending with a practical example. No wasted words or redundant information.

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

Completeness3/5

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

Given this is a mutation tool with no annotations and no output schema, the description provides good purpose clarity and usage guidelines but lacks information about what happens after insertion (return values, success indicators, error responses). The example helps but doesn't fully compensate for the missing behavioral details that would be important for an AI agent to use this tool effectively in production scenarios.

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?

Schema description coverage is 100%, so the schema already documents both parameters ('tabla' and 'datos'). The description adds value by explaining the format requirement: 'Los datos deben ser un array de objetos, donde cada objeto es un registro' (Data must be an array of objects, where each object is a record) and provides an example that illustrates how the parameters work together. This enhances understanding beyond the basic schema descriptions.

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

Purpose5/5

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

The description explicitly states the purpose as 'Insertar uno o varios registros (filas) nuevos en una tabla' (Insert one or several new records/rows into a table). This is a specific verb+resource combination that clearly distinguishes it from sibling tools like 'actualizar' (update) or 'modificar estructura' (modify structure) operations. The description goes beyond just restating the name by specifying what type of operation it performs.

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

Usage Guidelines5/5

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

The description provides explicit usage rules: 'Solo debe usarse para agregar datos nuevos. No la uses para actualizar registros existentes ni para modificar la estructura de la tabla' (Only use for adding new data. Do not use to update existing records or modify table structure). This clearly defines when to use this tool versus alternatives, with specific exclusions that help differentiate it from other CRUD or schema modification tools in the sibling list.

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/Yonsn76/MyPos-MCP'

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