drop_index
Remove an index from a MySQL database table to optimize storage or modify table structure.
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 handler function for the 'drop_index' tool. It retrieves a database pool, constructs the table name (optionally with database), executes the SQL DROP INDEX command, prepares a success output object, and returns an MCP-formatted response with text content and structured data.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 input schema defining parameters for the 'drop_index' tool: required table and indexName strings, optional database string.{ 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 registration call for the 'drop_index' tool, including 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, }; } );