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
| Name | Required | Description | Default |
|---|---|---|---|
| table_id | Yes | The ID of the table containing the column | |
| column_id | No | The ID of the column to delete (provide either column_id or column_name) | |
| column_name | No | The name of the column to delete (provide either column_id or column_name) |
Implementation Reference
- src/tools/table.ts:399-435 (handler)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, }; },
- src/tools/table.ts:379-398 (schema)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, ];
- src/nocodb-api.ts:137-139 (helper)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}`); }