Skip to main content
Glama

MSSQL MCP Server

by Nirmal123K
DropTableTool.ts1.02 kB
import sql from "mssql"; import { Tool } from "@modelcontextprotocol/sdk/types.js"; export class DropTableTool implements Tool { [key: string]: any; name = "drop_table"; description = "Drops a table from the MSSQL Database."; inputSchema = { type: "object", properties: { tableName: { type: "string", description: "Name of the table to drop" } }, required: ["tableName"], } as any; 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}` }; } } }

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/Nirmal123K/mssql-mcp'

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