Skip to main content
Glama
andrewlwn77
by andrewlwn77

delete_column

Remove a column from a NocoDB table by specifying its ID or name to restructure database tables and manage data organization.

Instructions

Delete a column from a table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_idYesThe ID of the table containing the column
column_idNoThe ID of the column to delete (provide either column_id or column_name)
column_nameNoThe name of the column to delete (provide either column_id or column_name)

Implementation Reference

  • The main handler function for the 'delete_column' tool. It resolves the column ID from name if necessary by listing columns, then calls the NocoDB client to delete the column.
    handler: async (
      client: NocoDBClient,
      args: {
        table_id: string;
        column_id?: string;
        column_name?: string;
      },
    ) => {
      if (!args.column_id && !args.column_name) {
        throw new Error("Either column_id or column_name must be provided");
      }
    
      let columnId = args.column_id;
    
      // If column_name is provided, find the column ID
      if (!columnId && args.column_name) {
        const columns = await client.listColumns(args.table_id);
        const column = columns.find(
          (col) =>
            col.column_name === args.column_name ||
            col.title === args.column_name,
        );
    
        if (!column) {
          throw new Error(`Column '${args.column_name}' not found in table`);
        }
    
        columnId = column.id;
      }
    
      await client.deleteColumn(columnId!);
    
      return {
        message: `Column ${args.column_name || args.column_id} deleted successfully`,
        column_id: columnId,
      };
    },
  • The input schema defining the parameters for the delete_column tool: table_id (required), optional column_id or column_name.
    inputSchema: {
      type: "object",
      properties: {
        table_id: {
          type: "string",
          description: "The ID of the table containing the column",
        },
        column_id: {
          type: "string",
          description:
            "The ID of the column to delete (provide either column_id or column_name)",
        },
        column_name: {
          type: "string",
          description:
            "The name of the column to delete (provide either column_id or column_name)",
        },
      },
      required: ["table_id"],
    },
  • src/index.ts:55-62 (registration)
    The delete_column tool is registered by including tableTools (which contains it) in the allTools array used by the MCP server for tool listing and execution.
    const allTools = [
      ...databaseTools,
      ...tableTools,
      ...recordTools,
      ...viewTools,
      ...queryTools,
      ...attachmentTools,
    ];
  • Helper method in NocoDBClient that performs the API call to delete a column, invoked by the tool handler.
    async deleteColumn(columnId: string): Promise<void> {
      await this.client.delete(`/api/v2/meta/columns/${columnId}`);
    }

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/andrewlwn77/nocodb-mcp'

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