drop_table
Delete a table from a MySQL database to remove unnecessary data structures or clean up schema. Specify the table name and optionally the database for targeted removal.
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 that executes DROP TABLE SQL command using the database pool.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)Input schema using Zod for table name and optional database.{ 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 using server.tool method.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, }; } );