Skip to main content
Glama

delete_data

Remove records from MySQL database tables using SQL DELETE queries to manage data cleanup, compliance, or maintenance tasks.

Instructions

Deletes data from a table in the MySQL database.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe SQL DELETE FROM query to execute.

Implementation Reference

  • The primary handler for the 'delete_data' tool. It validates the SQL query arguments, ensures it's a DELETE FROM query using isDeleteQuery helper, executes the query on the MySQL connection pool, logs the transaction, and returns a structured response with success/error details including the MySQL result.
    private async handleDeleteData(request: any, transactionId: string) {
      if (!isValidSqlQueryArgs(request.params.arguments)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid SQL query arguments.'
        );
      }
    
      const query = request.params.arguments.query;
      
      if (!isDeleteQuery(query)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Only DELETE FROM queries are allowed with delete_data tool.'
        );
      }
    
      console.error(`[${transactionId}] Executing DELETE query: ${query}`);
      
      try {
        const [result] = await this.pool.query(query);
        console.error(`[${transactionId}] Data deleted successfully`);
        
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                success: true,
                message: 'Data deleted successfully',
                result
              }, null, 2),
            },
          ],
        };
      } catch (error) {
        console.error(`[${transactionId}] Query error:`, error);
        if (error instanceof Error) {
          return {
            content: [
              {
                type: 'text',
                text: `MySQL error: ${error.message}`,
              },
            ],
            isError: true,
          };
        }
        throw error;
      }
  • The JSON schema definition for the 'delete_data' tool, including name, description, and input schema expecting a 'query' string parameter. This is returned in the ListTools response.
    {
      name: 'delete_data',
      description: 'Deletes data from a table in the MySQL database.',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'The SQL DELETE FROM query to execute.',
          },
        },
        required: ['query'],
      },
    },
  • src/index.ts:195-196 (registration)
    Registration of the 'delete_data' tool handler within the CallToolRequestSchema request handler switch statement, dispatching tool calls to the handleDeleteData method.
    case 'delete_data':
      return this.handleDeleteData(request, transactionId);
  • Helper function used by the delete_data handler to validate that the provided SQL query starts with 'DELETE FROM' (case-insensitive).
    const isDeleteQuery = (query: string): boolean => 
      query.trim().toLowerCase().startsWith('delete from');
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool performs a deletion, implying a destructive mutation, but fails to mention critical aspects like required permissions, whether deletions are permanent or reversible, transaction handling, error behavior, or rate limits. This leaves significant gaps for a destructive operation.

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 a single, efficient sentence that directly states the tool's purpose with zero wasted words. It is appropriately sized and front-loaded, making it easy to parse quickly.

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?

For a destructive mutation tool with no annotations and no output schema, the description is insufficiently complete. It lacks details on behavioral traits (e.g., permanence, permissions), output expectations, error handling, and differentiation from siblings, leaving the agent with inadequate context for safe and effective use.

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 fully documents the single 'query' parameter. The description adds no additional meaning about parameter usage, syntax examples, or constraints beyond what the schema provides, meeting the baseline for high coverage.

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 action ('Deletes') and target resource ('data from a table in the MySQL database'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'execute_sql' or 'run_sql_query' which could also handle DELETE operations, so it misses the highest score for sibling distinction.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'execute_sql' or 'run_sql_query', nor does it mention prerequisites, exclusions, or specific contexts. It merely states what the tool does without indicating appropriate usage scenarios.

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/michael7736/mysql-mcp-server'

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