Skip to main content
Glama
Yonsn76

MyPos MCP

by Yonsn76

importarTabla

Import data from CSV or JSON text formats into database tables. Specify the target table name, data string, and format to insert records while ensuring column and type compatibility.

Instructions

Sigue estas reglas para importar a una tabla: PROPÓSITO: Importar y insertar datos en una tabla desde un formato de texto (CSV o JSON). PRECAUCIÓN: Asegúrate de que los datos en el texto coincidan con las columnas y tipos de la tabla destino para evitar errores. USO: Proporciona el nombre de la tabla, los datos en formato de texto (string) y el formato (csv o json). EJEMPLO: "Importa los datos del archivo clientes.csv a la tabla clientes."

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
columnasNoColumnas a importar (opcional, para CSV)
datosYesDatos a importar (CSV o JSON)
formatoYesFormato de los datos
tablaYesNombre de la tabla destino

Implementation Reference

  • The handler function that parses the input data (JSON or CSV), constructs parameterized INSERT SQL statements using database-specific placeholders and quoting, and inserts each record into the specified table using the QueryRunner. Handles errors and returns success count.
    async ({ tabla, datos, formato, columnas }) => {
      try {
        let registros = [];
        if (formato === 'json') {
          registros = JSON.parse(datos);
        } else {
          // CSV
          const rows = datos.split(/\r?\n/).filter(Boolean);
          let headers = rows[0].split(',');
          if (columnas && columnas.length > 0) {
            headers = columnas;
          }
          registros = rows.slice(1).map(row => {
            const values = row.split(',');
            const obj = {};
            headers.forEach((h, i) => { obj[h.trim()] = values[i]?.trim(); });
            return obj;
          });
        }
        let insertedCount = 0;
        for (const registro of registros) {
          const cols = columnas && columnas.length > 0 ? columnas : Object.keys(registro);
          const valores = cols.map(c => registro[c]);
          const placeholders = makePlaceholders(db_type, valores.length).join(', ');
          const columnasStr = cols.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 importaron ${insertedCount} registro(s) en la tabla '${tabla}' exitosamente.` }] };
      } catch (e) {
        return { isError: true, content: [{ type: 'text', text: 'Error al importar datos: ' + (e.message || e) }] };
      }
    }
  • Zod schema defining the input parameters for the tool: table name, data string (CSV/JSON), format, and optional columns.
    {
      tabla: z.string().describe('Nombre de la tabla destino'),
      datos: z.string().describe('Datos a importar (CSV o JSON)'),
      formato: z.enum(['csv', 'json']).describe('Formato de los datos'),
      columnas: z.array(z.string()).optional().describe('Columnas a importar (opcional, para CSV)'),
    },
  • mcp_server.js:185-232 (registration)
    The server.tool registration call that defines and registers the 'importarTabla' tool with the MCP server, including its description, input schema, and handler function.
    server.tool(
      'importarTabla',
      'Sigue estas reglas para importar a una tabla:\n'
      + 'PROPÓSITO: Importar y insertar datos en una tabla desde un formato de texto (CSV o JSON).\n'
      + 'PRECAUCIÓN: Asegúrate de que los datos en el texto coincidan con las columnas y tipos de la tabla destino para evitar errores.\n'
      + 'USO: Proporciona el nombre de la tabla, los datos en formato de texto (string) y el formato (csv o json).\n'
      + 'EJEMPLO: "Importa los datos del archivo clientes.csv a la tabla clientes."',
      {
        tabla: z.string().describe('Nombre de la tabla destino'),
        datos: z.string().describe('Datos a importar (CSV o JSON)'),
        formato: z.enum(['csv', 'json']).describe('Formato de los datos'),
        columnas: z.array(z.string()).optional().describe('Columnas a importar (opcional, para CSV)'),
      },
      async ({ tabla, datos, formato, columnas }) => {
        try {
          let registros = [];
          if (formato === 'json') {
            registros = JSON.parse(datos);
          } else {
            // CSV
            const rows = datos.split(/\r?\n/).filter(Boolean);
            let headers = rows[0].split(',');
            if (columnas && columnas.length > 0) {
              headers = columnas;
            }
            registros = rows.slice(1).map(row => {
              const values = row.split(',');
              const obj = {};
              headers.forEach((h, i) => { obj[h.trim()] = values[i]?.trim(); });
              return obj;
            });
          }
          let insertedCount = 0;
          for (const registro of registros) {
            const cols = columnas && columnas.length > 0 ? columnas : Object.keys(registro);
            const valores = cols.map(c => registro[c]);
            const placeholders = makePlaceholders(db_type, valores.length).join(', ');
            const columnasStr = cols.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 importaron ${insertedCount} registro(s) en la tabla '${tabla}' exitosamente.` }] };
        } catch (e) {
          return { isError: true, content: [{ type: 'text', text: 'Error al importar datos: ' + (e.message || e) }] };
        }
      }
    );
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses that the tool performs data insertion (a write operation) and warns about potential errors if data doesn't match table columns/types, which is useful behavioral context. However, it lacks details on permissions, rate limits, transaction behavior, or error handling specifics, leaving gaps for a mutation tool.

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 well-structured with labeled sections (PROPÓSITO, PRECAUCIÓN, USO, EJEMPLO) and front-loaded key information. It is appropriately sized, but the 'USO' section slightly repeats schema details, and the example could be more concise. Overall, it efficiently conveys necessary information without significant waste.

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 the tool's complexity (data import/insertion with 4 parameters), no annotations, and no output schema, the description is moderately complete. It covers purpose, precautions, usage, and an example, but lacks details on return values, error formats, or advanced behavioral traits. For a mutation tool without structured support, it should provide more context to be fully adequate.

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

Parameters3/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 all parameters thoroughly. The description adds minimal value by mentioning the parameters in the 'USO' section but does not provide additional semantics, syntax examples, or constraints beyond what the schema specifies. The baseline of 3 is appropriate given the comprehensive schema.

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 clearly states the tool's purpose with specific verbs ('importar', 'insertar') and resources ('datos', 'tabla'), and distinguishes it from siblings like 'exportarTabla' (export) and 'insertarDatos' (insert without import). It explicitly mentions the source format (text, CSV, JSON) and destination (table), providing a complete picture of its function.

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

Usage Guidelines4/5

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

The description provides clear context for usage by specifying the required inputs (table name, data string, format) and offering an example. However, it does not explicitly state when to use this tool versus alternatives like 'insertarDatos' or 'exportarTabla', nor does it mention any exclusions or prerequisites beyond data compatibility.

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