drop_table
Remove a database table using DBeaver connections with built-in safety confirmation to prevent accidental data loss.
Instructions
Remove a table from the database with safety confirmation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| confirm | Yes | Safety confirmation flag (must be true) | |
| connectionId | Yes | The ID or name of the DBeaver connection | |
| tableName | Yes | Name of the table to drop |
Implementation Reference
- src/index.ts:768-813 (handler)The main handler function that executes the drop_table tool logic: validates inputs, checks safety confirmation, verifies table existence, constructs and executes DROP TABLE query via DBeaver client.private async handleDropTable(args: { connectionId: string; tableName: string; confirm: boolean }) { const connectionId = sanitizeConnectionId(args.connectionId); const tableName = args.tableName; if (!tableName) { throw new McpError(ErrorCode.InvalidParams, 'Table name is required'); } if (!args.confirm) { return { content: [{ type: 'text' as const, text: JSON.stringify({ success: false, message: 'Safety confirmation required. Set confirm=true to proceed with dropping the table.' }, null, 2), }], }; } const connection = await this.configParser.getConnection(connectionId); if (!connection) { throw new McpError(ErrorCode.InvalidParams, `Connection not found: ${connectionId}`); } // Check if table exists first try { await this.dbeaverClient.getTableSchema(connection, tableName); } catch (error) { throw new McpError(ErrorCode.InvalidParams, `Table '${tableName}' does not exist or cannot be accessed`); } const dropQuery = `DROP TABLE "${tableName}"`; const result = await this.dbeaverClient.executeQuery(connection, dropQuery); return { content: [{ type: 'text' as const, text: JSON.stringify({ success: true, message: `Table '${tableName}' dropped successfully`, executionTime: result.executionTime }, null, 2), }], }; }
- src/index.ts:298-319 (schema)Tool definition including name, description, and input schema specifying required parameters: connectionId, tableName, and confirm boolean.{ name: 'drop_table', description: 'Remove a table from the database with safety confirmation', inputSchema: { type: 'object', properties: { connectionId: { type: 'string', description: 'The ID or name of the DBeaver connection', }, tableName: { type: 'string', description: 'Name of the table to drop', }, confirm: { type: 'boolean', description: 'Safety confirmation flag (must be true)', }, }, required: ['connectionId', 'tableName', 'confirm'], }, },
- src/index.ts:512-517 (registration)Switch case in CallToolRequestSchema handler that dispatches to the handleDropTable method based on tool name.case 'drop_table': return await this.handleDropTable(args as { connectionId: string; tableName: string; confirm: boolean });