drop_index
Remove an index from a MySQL database table to optimize storage or modify table structure. Specify the table name and index to delete.
Instructions
Drop an index from a table
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | Table name | |
| indexName | Yes | Index name | |
| database | No | Database name (optional) |
Implementation Reference
- src/index.ts:572-594 (handler)The asynchronous handler function that executes the logic to drop the specified index from the table using the database connection pool.async ({ table, indexName, database }) => { const p = await getPool(); const tableName = database ? `\`${database}\`.\`${table}\`` : `\`${table}\``; await p.execute(`DROP INDEX \`${indexName}\` ON ${tableName}`); const output = { success: true, table, indexName, database: database || null, }; return { content: [ { type: "text" as const, text: `Index ${indexName} dropped from ${table}`, }, ], structuredContent: output, }; }
- src/index.ts:567-571 (schema)Zod schema defining the input parameters for the drop_index tool: table, indexName, and optional database.{ table: z.string().describe("Table name"), indexName: z.string().describe("Index name"), database: z.string().optional().describe("Database name (optional)"), },
- src/index.ts:563-595 (registration)The server.tool() call that registers the drop_index tool, including its name, description, input schema, and inline handler function.// Tool: drop_index server.tool( "drop_index", "Drop an index from a table", { table: z.string().describe("Table name"), indexName: z.string().describe("Index name"), database: z.string().optional().describe("Database name (optional)"), }, async ({ table, indexName, database }) => { const p = await getPool(); const tableName = database ? `\`${database}\`.\`${table}\`` : `\`${table}\``; await p.execute(`DROP INDEX \`${indexName}\` ON ${tableName}`); const output = { success: true, table, indexName, database: database || null, }; return { content: [ { type: "text" as const, text: `Index ${indexName} dropped from ${table}`, }, ], structuredContent: output, }; } );