Skip to main content
Glama
pickstar-2002

MySQL MCP Server

mysql_delete

Delete data from MySQL database tables by specifying table name and conditions. Use this tool to remove specific records while maintaining database integrity.

Instructions

删除表数据

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableNameYes表名称
whereYes删除条件

Implementation Reference

  • The handler function for the 'mysql_delete' tool. It constructs a parameterized DELETE SQL statement using the provided tableName and where conditions, executes it via the DatabaseManager, and returns a response indicating the number of affected rows.
    private async handleDelete(args: { tableName: string; where: any }): Promise<any> { const whereClause = Object.keys(args.where).map(key => `\`${key}\` = ?`).join(' AND '); const sql = `DELETE FROM \`${args.tableName}\` WHERE ${whereClause}`; const params = Object.values(args.where); const result = await this.dbManager.query(sql, params); return { content: [ { type: 'text', text: `成功删除 ${result.affectedRows} 行数据`, }, ], }; }
  • The input schema definition for the 'mysql_delete' tool, specifying required parameters: tableName (string) and where (object).
    { name: 'mysql_delete', description: '删除表数据', inputSchema: { type: 'object', properties: { tableName: { type: 'string', description: '表名称' }, where: { type: 'object', description: '删除条件' }, }, required: ['tableName', 'where'], }, },
  • src/server.ts:257-258 (registration)
    The switch case registration that maps the 'mysql_delete' tool call to the handleDelete handler function.
    case 'mysql_delete': return await this.handleDelete(args as any);

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/pickstar-2002/mysql-mcp'

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