Skip to main content
Glama
nilsir

MCP Server MySQL

by nilsir

drop_table

Delete a table from a MySQL database to remove unnecessary data structures, manage storage, or reorganize database schemas.

Instructions

Drop/delete a table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableYesTable name
databaseNoDatabase name (optional)

Implementation Reference

  • Handler function for the drop_table tool. It constructs the table name (optionally qualified with database), executes the DROP TABLE SQL command using the connection pool, prepares a success output, and returns a structured response with text content.
    async ({ table, database }) => {
      const p = await getPool();
    
      const tableName = database ? `\`${database}\`.\`${table}\`` : `\`${table}\``;
      await p.execute(`DROP TABLE ${tableName}`);
    
      const output = { success: true, table, database: database || null };
    
      return {
        content: [
          {
            type: "text" as const,
            text: `Table ${table} dropped successfully`,
          },
        ],
        structuredContent: output,
      };
    }
  • Zod schema defining the input parameters for the drop_table tool: required 'table' string and optional 'database' string.
    {
      table: z.string().describe("Table name"),
      database: z.string().optional().describe("Database name (optional)"),
    },
  • src/index.ts:409-434 (registration)
    Registration of the drop_table tool via server.tool(), including name, description, input schema, and handler function.
    server.tool(
      "drop_table",
      "Drop/delete a table",
      {
        table: z.string().describe("Table name"),
        database: z.string().optional().describe("Database name (optional)"),
      },
      async ({ table, database }) => {
        const p = await getPool();
    
        const tableName = database ? `\`${database}\`.\`${table}\`` : `\`${table}\``;
        await p.execute(`DROP TABLE ${tableName}`);
    
        const output = { success: true, table, database: database || null };
    
        return {
          content: [
            {
              type: "text" as const,
              text: `Table ${table} dropped successfully`,
            },
          ],
          structuredContent: output,
        };
      }
    );

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/nilsir/mcp-server-mysql'

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