drop_table
Delete a table from a MySQL database to remove unnecessary data structures, manage storage, or reorganize database schemas.
Instructions
Drop/delete a table
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | Table name | |
| database | No | Database name (optional) |
Implementation Reference
- src/index.ts:416-433 (handler)Handler function for the drop_table tool. It constructs the table name (optionally qualified with database), executes the DROP TABLE SQL command using the connection pool, prepares a success output, and returns a structured response with text content.async ({ table, database }) => { const p = await getPool(); const tableName = database ? `\`${database}\`.\`${table}\`` : `\`${table}\``; await p.execute(`DROP TABLE ${tableName}`); const output = { success: true, table, database: database || null }; return { content: [ { type: "text" as const, text: `Table ${table} dropped successfully`, }, ], structuredContent: output, }; }
- src/index.ts:412-415 (schema)Zod schema defining the input parameters for the drop_table tool: required 'table' string and optional 'database' string.{ table: z.string().describe("Table name"), database: z.string().optional().describe("Database name (optional)"), },
- src/index.ts:409-434 (registration)Registration of the drop_table tool via server.tool(), including name, description, input schema, and handler function.server.tool( "drop_table", "Drop/delete a table", { table: z.string().describe("Table name"), database: z.string().optional().describe("Database name (optional)"), }, async ({ table, database }) => { const p = await getPool(); const tableName = database ? `\`${database}\`.\`${table}\`` : `\`${table}\``; await p.execute(`DROP TABLE ${tableName}`); const output = { success: true, table, database: database || null }; return { content: [ { type: "text" as const, text: `Table ${table} dropped successfully`, }, ], structuredContent: output, }; } );