Skip to main content
Glama
Yonsn76

MyPos MCP

by Yonsn76

agregarRestriccionUnica

Add a UNIQUE constraint to existing database columns to prevent duplicate values in specified tables, ensuring data integrity by enforcing uniqueness.

Instructions

Sigue estas reglas para agregar una restricción UNIQUE: PROPÓSITO: Agregar una restricción de unicidad (UNIQUE) a una o más columnas para evitar valores duplicados. REGLA: No la uses para crear tablas o columnas. La columna ya debe existir. PRECAUCIÓN: La operación fallará si ya existen datos duplicados en la(s) columna(s) seleccionada(s). USO: Especifica la tabla y las columnas que deben ser únicas. EJEMPLO: "Haz que el campo email sea único en la tabla usuarios."

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
columnasYesColumnas a restringir como únicas
nombreNoNombre de la restricción (opcional)
tablaYesNombre de la tabla

Implementation Reference

  • mcp_server.js:654-681 (registration)
    Registration of the 'agregarRestriccionUnica' tool, including schema definition and handler implementation. This is the complete tool definition that adds a UNIQUE constraint to columns in a specified table using ALTER TABLE.
    server.tool(
      'agregarRestriccionUnica',
      'Sigue estas reglas para agregar una restricción UNIQUE:\n'
      + 'PROPÓSITO: Agregar una restricción de unicidad (UNIQUE) a una o más columnas para evitar valores duplicados.\n'
      + 'REGLA: No la uses para crear tablas o columnas. La columna ya debe existir.\n'
      + 'PRECAUCIÓN: La operación fallará si ya existen datos duplicados en la(s) columna(s) seleccionada(s).\n'
      + 'USO: Especifica la tabla y las columnas que deben ser únicas.\n'
      + 'EJEMPLO: "Haz que el campo email sea único en la tabla usuarios."',
      {
        tabla: z.string().describe('Nombre de la tabla'),
        columnas: z.array(z.string()).describe('Columnas a restringir como únicas'),
        nombre: z.string().optional().describe('Nombre de la restricción (opcional)'),
      },
      async ({ tabla, columnas, nombre }) => {
        try {
          if (!tabla || !columnas || columnas.length === 0) {
            return { isError: true, content: [{ type: 'text', text: 'Debes proporcionar la tabla y al menos una columna.' }] };
          }
          const restriccion = nombre ? quoteIdent(nombre) : '';
          const cols = columnas.map(quoteIdent).join(', ');
          const sql = `ALTER TABLE ${quoteIdent(tabla)} ADD CONSTRAINT ${restriccion} UNIQUE (${cols})`;
          await query_runner.runQuery(sql);
          return { content: [{ type: 'text', text: 'Restricción UNIQUE agregada exitosamente.' }] };
        } catch (e) {
          return { isError: true, content: [{ type: 'text', text: 'Error al agregar restricción UNIQUE: ' + (e.message || e) }] };
        }
      }
    );
  • The handler function executes the logic to add a UNIQUE constraint by constructing and running an ALTER TABLE SQL statement using the query_runner.
    async ({ tabla, columnas, nombre }) => {
      try {
        if (!tabla || !columnas || columnas.length === 0) {
          return { isError: true, content: [{ type: 'text', text: 'Debes proporcionar la tabla y al menos una columna.' }] };
        }
        const restriccion = nombre ? quoteIdent(nombre) : '';
        const cols = columnas.map(quoteIdent).join(', ');
        const sql = `ALTER TABLE ${quoteIdent(tabla)} ADD CONSTRAINT ${restriccion} UNIQUE (${cols})`;
        await query_runner.runQuery(sql);
        return { content: [{ type: 'text', text: 'Restricción UNIQUE agregada exitosamente.' }] };
      } catch (e) {
        return { isError: true, content: [{ type: 'text', text: 'Error al agregar restricción UNIQUE: ' + (e.message || e) }] };
      }
    }
  • Input schema using Zod for validating parameters: tabla (required string), columnas (required array of strings), nombre (optional string).
    {
      tabla: z.string().describe('Nombre de la tabla'),
      columnas: z.array(z.string()).describe('Columnas a restringir como únicas'),
      nombre: z.string().optional().describe('Nombre de la restricción (opcional)'),
    },
Behavior4/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 effectively describes key behavioral traits: the operation will fail if duplicate data exists ('La operación fallará si ya existen datos duplicados'), it requires pre-existing columns ('La columna ya debe existir'), and it's a mutation operation (implied by 'agregar'). However, it doesn't mention permissions needed, whether the change is reversible, or what happens on success.

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, PRECAUCIÓN, USO, EJEMPLO), each earning its place. It's front-loaded with the purpose, followed by important rules and cautions, then usage guidance and an example. No wasted words, and the structure enhances clarity.

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

Completeness4/5

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

For a mutation tool with no annotations and no output schema, the description does an excellent job covering purpose, usage rules, and behavioral constraints. It clearly explains what the tool does, when to use it, and important failure conditions. The main gap is the lack of information about what happens on success (e.g., confirmation message, constraint name generation), but given the strong coverage elsewhere, this is a minor omission.

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 three parameters. The description adds some context by mentioning 'tabla' and 'columnas' in the USO section and providing an example, but doesn't add meaningful semantic details beyond what the schema provides. The baseline of 3 is appropriate when the schema does the heavy lifting.

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 'Agregar una restricción de unicidad (UNIQUE) a una o más columnas para evitar valores duplicados', which is a specific verb (agregar) + resource (restricción UNIQUE) + outcome (evitar valores duplicados). It clearly distinguishes from siblings like 'crearTabla' or 'agregarColumna' by specifying it's for adding constraints to existing columns, not creating tables or columns.

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: 'No la uses para crear tablas o columnas. La columna ya debe existir.' It also includes a caution about when it will fail ('La operación fallará si ya existen datos duplicados'), and gives a clear example of when to use it ('Haz que el campo email sea único en la tabla usuarios'). This covers when to use, when not to use, and provides context for alternatives.

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