Skip to main content
Glama

delete_data

Executes SQL DELETE FROM queries to remove specific data from a MySQL database, enabling efficient record deletion as part of database management 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 handler function that executes the delete_data tool. Validates input, checks for DELETE FROM query, executes on MySQL pool, returns JSON result or error.
    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; } }
  • src/index.ts:150-163 (registration)
    Tool registration in the ListTools response, including name, description, and input schema requiring a 'query' parameter.
    { 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'], }, },
  • Helper function to validate if a SQL query is a DELETE FROM statement, used in delete_data handler.
    const isDeleteQuery = (query: string): boolean => query.trim().toLowerCase().startsWith('delete from');
  • Input schema for delete_data tool: object with required 'query' string property.
    inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'The SQL DELETE FROM query to execute.', }, }, required: ['query'], },

Other Tools

Related 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