drop_table
Remove a table from your MSSQL database to delete data and free storage space. Specify the table name to execute this schema operation.
Instructions
Drops a table from the MSSQL Database.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tableName | Yes | Name of the table to drop |
Implementation Reference
- src/tools/DropTableTool.ts:16-36 (handler)The async run method that executes the drop_table tool logic: validates tableName, executes DROP TABLE query via MSSQL, returns success/error response.async run(params: any) { try { const { tableName } = params; // Basic validation to prevent SQL injection if (!/^[\w\d_]+$/.test(tableName)) { throw new Error("Invalid table name."); } const query = `DROP TABLE [${tableName}]`; await new sql.Request().query(query); return { success: true, message: `Table '${tableName}' dropped successfully.` }; } catch (error) { console.error("Error dropping table:", error); return { success: false, message: `Failed to drop table: ${error}` }; } }
- src/tools/DropTableTool.ts:8-14 (schema)Input schema definition for drop_table tool, specifying required 'tableName' string property.inputSchema = { type: "object", properties: { tableName: { type: "string", description: "Name of the table to drop" } }, required: ["tableName"], } as any;
- src/index.ts:115-119 (registration)Registration of dropTableTool in the ListToolsRequestSchema handler's tools array (non-readonly mode).server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: isReadOnly ? [listTableTool, readDataTool, describeTableTool] // todo: add searchDataTool to the list of tools available in readonly mode once implemented : [insertDataTool, readDataTool, describeTableTool, updateDataTool, createTableTool, createIndexTool, dropTableTool, listTableTool], // add all new tools here }));
- src/index.ts:144-146 (registration)Switch case in CallToolRequestSchema handler that routes 'drop_table' calls to dropTableTool.run().case dropTableTool.name: result = await dropTableTool.run(args); break;
- src/index.ts:95-95 (registration)Instantiation of the DropTableTool instance referenced throughout the server.const dropTableTool = new DropTableTool();