Skip to main content
Glama
Yonsn76

MyPos MCP

by Yonsn76

eliminarClaveForanea

Remove a foreign key constraint from a database table to modify relationships, requiring explicit confirmation to prevent orphaned data and maintain referential integrity.

Instructions

Sigue estas reglas OBLIGATORIAS para eliminar una clave foránea: ADVERTENCIA INICIAL: Informa al usuario que eliminar una clave foránea puede llevar a datos huérfanos y romper la integridad referencial. CONFIRMACIÓN EXPLÍCITA: Para proceder, el usuario DEBE escribir la frase exacta: "Confirmar eliminación de la clave foránea [nombreFK] de la tabla [nombreTabla]". VERIFICACIÓN ESTRICTA: No ejecutes la eliminación si la confirmación no es exacta. USO: Especifica la tabla y el nombre de la clave foránea a eliminar. EJEMPLO: "Elimina la clave foránea fk_cliente de la tabla ventas."

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nombreYesNombre de la clave foránea
tablaYesNombre de la tabla

Implementation Reference

  • The handler function that validates inputs, constructs the appropriate SQL ALTER TABLE statement to drop the foreign key constraint (depending on MySQL or other DB), executes it via query_runner, and returns success or error messages.
    async ({ tabla, nombre }) => {
      try {
        if (!tabla || !nombre) {
          return { isError: true, content: [{ type: 'text', text: 'Debes proporcionar la tabla y el nombre de la clave foránea.' }] };
        }
        let sql;
        if (db_type === 'mysql') {
          sql = `ALTER TABLE ${quoteIdent(tabla)} DROP FOREIGN KEY ${quoteIdent(nombre)}`;
        } else {
          sql = `ALTER TABLE ${quoteIdent(tabla)} DROP CONSTRAINT ${quoteIdent(nombre)}`;
        }
        await query_runner.runQuery(sql);
        return { content: [{ type: 'text', text: 'Clave foránea eliminada exitosamente.' }] };
      } catch (e) {
        return { isError: true, content: [{ type: 'text', text: 'Error al eliminar clave foránea: ' + (e.message || e) }] };
      }
    }
  • Zod schema defining the input parameters: 'tabla' (table name) and 'nombre' (foreign key name).
    {
      tabla: z.string().describe('Nombre de la tabla'),
      nombre: z.string().describe('Nombre de la clave foránea'),
    },
  • mcp_server.js:622-651 (registration)
    The server.tool registration call that defines the tool name, detailed description with safety rules and confirmation requirements, schema, and inline handler function.
    server.tool(
      'eliminarClaveForanea',
      'Sigue estas reglas OBLIGATORIAS para eliminar una clave foránea:\n'
      + 'ADVERTENCIA INICIAL: Informa al usuario que eliminar una clave foránea puede llevar a datos huérfanos y romper la integridad referencial.\n'
      + 'CONFIRMACIÓN EXPLÍCITA: Para proceder, el usuario DEBE escribir la frase exacta: "Confirmar eliminación de la clave foránea [nombreFK] de la tabla [nombreTabla]".\n'
      + 'VERIFICACIÓN ESTRICTA: No ejecutes la eliminación si la confirmación no es exacta.\n'
      + 'USO: Especifica la tabla y el nombre de la clave foránea a eliminar.\n'
      + 'EJEMPLO: "Elimina la clave foránea fk_cliente de la tabla ventas."',
      {
        tabla: z.string().describe('Nombre de la tabla'),
        nombre: z.string().describe('Nombre de la clave foránea'),
      },
      async ({ tabla, nombre }) => {
        try {
          if (!tabla || !nombre) {
            return { isError: true, content: [{ type: 'text', text: 'Debes proporcionar la tabla y el nombre de la clave foránea.' }] };
          }
          let sql;
          if (db_type === 'mysql') {
            sql = `ALTER TABLE ${quoteIdent(tabla)} DROP FOREIGN KEY ${quoteIdent(nombre)}`;
          } else {
            sql = `ALTER TABLE ${quoteIdent(tabla)} DROP CONSTRAINT ${quoteIdent(nombre)}`;
          }
          await query_runner.runQuery(sql);
          return { content: [{ type: 'text', text: 'Clave foránea eliminada exitosamente.' }] };
        } catch (e) {
          return { isError: true, content: [{ type: 'text', text: 'Error al eliminar clave foránea: ' + (e.message || e) }] };
        }
      }
    );
Behavior5/5

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

With no annotations provided, the description carries full burden and excels. It discloses critical behavioral traits: the destructive nature (warns about orphaned data and broken referential integrity), strict confirmation requirements (exact phrase verification), and execution constraints (no execution without exact confirmation). This goes beyond basic function to explain safety and procedural aspects.

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 clear sections (rules, warning, confirmation, usage, example) and front-loaded with mandatory rules. It's appropriately sized for a destructive operation, though slightly verbose due to formatting. Every sentence adds value, but it could be more concise by integrating some points.

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

Completeness5/5

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

Given the tool's complexity (destructive operation with confirmation), no annotations, and no output schema, the description is highly complete. It covers purpose, usage guidelines, behavioral transparency, and includes an example. For a 2-parameter tool with full schema coverage, this provides sufficient context for safe and correct invocation.

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 both parameters ('nombre' and 'tabla'). The description adds minimal value beyond the schema by mentioning 'Especifica la tabla y el nombre de la clave foránea' and providing an example, but doesn't elaborate on parameter semantics like format or constraints. Baseline 3 is appropriate as 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 tool's purpose: 'eliminar una clave foránea' (delete a foreign key). It distinguishes from siblings like 'eliminarColumna' (delete column) or 'eliminarTabla' (delete table) by specifying the exact resource (foreign key) and action (delete with confirmation rules). The description provides specific verb+resource differentiation.

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: it states when to use (to delete a foreign key), includes a mandatory confirmation phrase requirement, and gives a clear example. It also warns about data integrity risks, helping the agent understand the tool's appropriate context versus alternatives like 'agregarClaveForanea' (add foreign key).

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