Skip to main content
Glama

drop_table

Remove a table from a Microsoft SQL Server database to manage schema changes or delete obsolete data structures.

Instructions

Drops a table from the MSSQL Database.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableNameYesName of the table to drop

Implementation Reference

  • The `run` method implements the core logic of the drop_table tool: extracts tableName, validates it to prevent SQL injection, executes the DROP TABLE query using mssql, and returns a success or 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}` }; } }
  • Defines the input schema for the drop_table tool, requiring a 'tableName' string parameter.
    inputSchema = { type: "object", properties: { tableName: { type: "string", description: "Name of the table to drop" } }, required: ["tableName"], } as any;
  • src/index.ts:112-112 (registration)
    The dropTableTool instance is included in the array of tools advertised via ListToolsRequestHandler (non-readonly mode).
    : [insertDataTool, readDataTool, describeTableTool, updateDataTool, createTableTool, createIndexTool, dropTableTool, listTableTool], // add all new tools here
  • src/index.ts:138-140 (registration)
    Switch case in CallToolRequestHandler that dispatches calls to drop_table by invoking dropTableTool.run().
    case dropTableTool.name: result = await dropTableTool.run(args); break;
  • dropTableTool is wrapped with ensureSqlConnection before its run method is called.
    [insertDataTool, readDataTool, updateDataTool, createTableTool, createIndexTool, dropTableTool, listTableTool, describeTableTool].forEach(wrapToolRun);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/EvilPhatBoi/McpSqlServer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server