Skip to main content
Glama
andrewlwn77
by andrewlwn77

add_column

Add a new column to an existing NocoDB table with configurable data types including text, numbers, dates, selects, formulas, and specialized fields like barcodes or phone numbers.

Instructions

Add a new column to an existing table. For SingleSelect: provide options in meta. For QrCode/Barcode: provide reference column ID. PhoneNumber uses standard text storage.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_idYesThe ID of the table to add column to
titleYesDisplay name of the column
column_nameNoDatabase column name (optional, will be generated from title if not provided)
uidtYesUI Data Type - Basic: SingleLineText, LongText, Number, Decimal, Currency, Percent | Date/Time: Date, DateTime, Duration | Boolean: Checkbox | Select: SingleSelect, MultiSelect | Advanced: Attachment, JSON, Email, PhoneNumber, URL, Rating | Virtual/Computed: Formula, Rollup, Lookup, QrCode, Barcode | Relational: Link, Links
dtNoDatabase data type (optional)
pkNoIs primary key (default: false)
rqdNoIs required field (default: false)
uniqueNoHas unique constraint (default: false)
aiNoIs auto increment (default: false)
unNoIs unsigned number (default: false)
cdfNoColumn default value
dtxNoDate format for Date/DateTime columns
npNoNumeric precision (for Number/Decimal types)
nsNoNumeric scale (for Decimal type)
metaNoAdditional metadata for specific column types

Implementation Reference

  • MCP tool handler for 'add_column': constructs column definition from args, handles special cases for QrCode/Barcode/meta, calls NocoDBClient.addColumn, and returns column info.
    handler: async (
      client: NocoDBClient,
      args: {
        table_id: string;
        title: string;
        column_name?: string;
        uidt: string;
        dt?: string;
        pk?: boolean;
        rqd?: boolean;
        unique?: boolean;
        ai?: boolean;
        un?: boolean;
        cdf?: string;
        dtx?: string;
        np?: number;
        ns?: number;
        meta?: any;
      },
    ) => {
      const columnDefinition: any = {
        title: args.title,
        column_name:
          args.column_name || args.title.toLowerCase().replace(/\s+/g, "_"),
        uidt: args.uidt,
        ...(args.dt && { dt: args.dt }),
        ...(args.pk !== undefined && { pk: args.pk }),
        ...(args.rqd !== undefined && { rqd: args.rqd }),
        ...(args.unique !== undefined && { unique: args.unique }),
        ...(args.ai !== undefined && { ai: args.ai }),
        ...(args.un !== undefined && { un: args.un }),
        ...(args.cdf !== undefined && { cdf: args.cdf }),
        ...(args.dtx && { dtx: args.dtx }),
        ...(args.np !== undefined && { np: args.np }),
        ...(args.ns !== undefined && { ns: args.ns }),
      };
    
      // Handle special column types that need properties at root level
      if (args.uidt === "QrCode" && args.meta?.fk_qr_value_column_id) {
        columnDefinition.fk_qr_value_column_id =
          args.meta.fk_qr_value_column_id;
      } else if (
        args.uidt === "Barcode" &&
        args.meta?.fk_barcode_value_column_id
      ) {
        columnDefinition.fk_barcode_value_column_id =
          args.meta.fk_barcode_value_column_id;
        if (args.meta.barcode_format) {
          columnDefinition.barcode_format = args.meta.barcode_format;
        }
      } else if (args.meta) {
        // For other column types, keep meta as is
        columnDefinition.meta = args.meta;
      }
    
      const column = await client.addColumn(args.table_id, columnDefinition);
      return {
        column: {
          id: column.id,
          title: column.title,
          column_name: column.column_name,
          uidt: column.uidt,
          dt: column.dt,
          pk: column.pk,
          rqd: column.rqd,
          unique: column.unique,
          ai: column.ai,
        },
        message: `Column '${column.title}' added successfully to table`,
      };
    },
  • Input schema for 'add_column' tool defining all parameters including uidt types, numeric options, meta for selects, QR/barcode references, etc.
    inputSchema: {
      type: "object",
      properties: {
        table_id: {
          type: "string",
          description: "The ID of the table to add column to",
        },
        title: {
          type: "string",
          description: "Display name of the column",
        },
        column_name: {
          type: "string",
          description:
            "Database column name (optional, will be generated from title if not provided)",
        },
        uidt: {
          type: "string",
          description:
            "UI Data Type - Basic: SingleLineText, LongText, Number, Decimal, Currency, Percent | Date/Time: Date, DateTime, Duration | Boolean: Checkbox | Select: SingleSelect, MultiSelect | Advanced: Attachment, JSON, Email, PhoneNumber, URL, Rating | Virtual/Computed: Formula, Rollup, Lookup, QrCode, Barcode | Relational: Link, Links",
        },
        dt: {
          type: "string",
          description: "Database data type (optional)",
        },
        pk: {
          type: "boolean",
          description: "Is primary key (default: false)",
        },
        rqd: {
          type: "boolean",
          description: "Is required field (default: false)",
        },
        unique: {
          type: "boolean",
          description: "Has unique constraint (default: false)",
        },
        ai: {
          type: "boolean",
          description: "Is auto increment (default: false)",
        },
        un: {
          type: "boolean",
          description: "Is unsigned number (default: false)",
        },
        cdf: {
          type: "string",
          description: "Column default value",
        },
        dtx: {
          type: "string",
          description: "Date format for Date/DateTime columns",
        },
        np: {
          type: "number",
          description: "Numeric precision (for Number/Decimal types)",
        },
        ns: {
          type: "number",
          description: "Numeric scale (for Decimal type)",
        },
        meta: {
          type: "object",
          description: "Additional metadata for specific column types",
          properties: {
            options: {
              type: "array",
              description: "Options for SingleSelect/MultiSelect columns",
              items: {
                type: "object",
                properties: {
                  title: {
                    type: "string",
                    description: "Option label",
                  },
                  color: {
                    type: "string",
                    description: "Option color in hex format (e.g., #FF5733)",
                  },
                },
                required: ["title"],
              },
            },
            fk_barcode_value_column_id: {
              type: "string",
              description:
                "Required for Barcode column - ID of the column containing the value to encode",
            },
            fk_qr_value_column_id: {
              type: "string",
              description:
                "Required for QrCode column - ID of the column containing the value to encode",
            },
            barcode_format: {
              type: "string",
              description:
                "Barcode format for Barcode columns (e.g., CODE128, EAN, EAN-13, EAN-8, EAN-5, EAN-2, UPC, CODE39, ITF-14, MSI, Pharmacode, Codabar)",
            },
            currency_code: {
              type: "string",
              description:
                "Currency code for Currency columns (e.g., USD, EUR, GBP)",
            },
          },
        },
      },
      required: ["table_id", "title", "uidt"],
  • Tool object registration in tableTools array, defining name, description, schema, and handler for 'add_column'.
    {
      name: "add_column",
      description:
        "Add a new column to an existing table. For SingleSelect: provide options in meta. For QrCode/Barcode: provide reference column ID. PhoneNumber uses standard text storage.",
      inputSchema: {
        type: "object",
        properties: {
          table_id: {
            type: "string",
            description: "The ID of the table to add column to",
          },
          title: {
            type: "string",
            description: "Display name of the column",
          },
          column_name: {
            type: "string",
            description:
              "Database column name (optional, will be generated from title if not provided)",
          },
          uidt: {
            type: "string",
            description:
              "UI Data Type - Basic: SingleLineText, LongText, Number, Decimal, Currency, Percent | Date/Time: Date, DateTime, Duration | Boolean: Checkbox | Select: SingleSelect, MultiSelect | Advanced: Attachment, JSON, Email, PhoneNumber, URL, Rating | Virtual/Computed: Formula, Rollup, Lookup, QrCode, Barcode | Relational: Link, Links",
          },
          dt: {
            type: "string",
            description: "Database data type (optional)",
          },
          pk: {
            type: "boolean",
            description: "Is primary key (default: false)",
          },
          rqd: {
            type: "boolean",
            description: "Is required field (default: false)",
          },
          unique: {
            type: "boolean",
            description: "Has unique constraint (default: false)",
          },
          ai: {
            type: "boolean",
            description: "Is auto increment (default: false)",
          },
          un: {
            type: "boolean",
            description: "Is unsigned number (default: false)",
          },
          cdf: {
            type: "string",
            description: "Column default value",
          },
          dtx: {
            type: "string",
            description: "Date format for Date/DateTime columns",
          },
          np: {
            type: "number",
            description: "Numeric precision (for Number/Decimal types)",
          },
          ns: {
            type: "number",
            description: "Numeric scale (for Decimal type)",
          },
          meta: {
            type: "object",
            description: "Additional metadata for specific column types",
            properties: {
              options: {
                type: "array",
                description: "Options for SingleSelect/MultiSelect columns",
                items: {
                  type: "object",
                  properties: {
                    title: {
                      type: "string",
                      description: "Option label",
                    },
                    color: {
                      type: "string",
                      description: "Option color in hex format (e.g., #FF5733)",
                    },
                  },
                  required: ["title"],
                },
              },
              fk_barcode_value_column_id: {
                type: "string",
                description:
                  "Required for Barcode column - ID of the column containing the value to encode",
              },
              fk_qr_value_column_id: {
                type: "string",
                description:
                  "Required for QrCode column - ID of the column containing the value to encode",
              },
              barcode_format: {
                type: "string",
                description:
                  "Barcode format for Barcode columns (e.g., CODE128, EAN, EAN-13, EAN-8, EAN-5, EAN-2, UPC, CODE39, ITF-14, MSI, Pharmacode, Codabar)",
              },
              currency_code: {
                type: "string",
                description:
                  "Currency code for Currency columns (e.g., USD, EUR, GBP)",
              },
            },
          },
        },
        required: ["table_id", "title", "uidt"],
      },
      handler: async (
        client: NocoDBClient,
        args: {
          table_id: string;
          title: string;
          column_name?: string;
          uidt: string;
          dt?: string;
          pk?: boolean;
          rqd?: boolean;
          unique?: boolean;
          ai?: boolean;
          un?: boolean;
          cdf?: string;
          dtx?: string;
          np?: number;
          ns?: number;
          meta?: any;
        },
      ) => {
        const columnDefinition: any = {
          title: args.title,
          column_name:
            args.column_name || args.title.toLowerCase().replace(/\s+/g, "_"),
          uidt: args.uidt,
          ...(args.dt && { dt: args.dt }),
          ...(args.pk !== undefined && { pk: args.pk }),
          ...(args.rqd !== undefined && { rqd: args.rqd }),
          ...(args.unique !== undefined && { unique: args.unique }),
          ...(args.ai !== undefined && { ai: args.ai }),
          ...(args.un !== undefined && { un: args.un }),
          ...(args.cdf !== undefined && { cdf: args.cdf }),
          ...(args.dtx && { dtx: args.dtx }),
          ...(args.np !== undefined && { np: args.np }),
          ...(args.ns !== undefined && { ns: args.ns }),
        };
    
        // Handle special column types that need properties at root level
        if (args.uidt === "QrCode" && args.meta?.fk_qr_value_column_id) {
          columnDefinition.fk_qr_value_column_id =
            args.meta.fk_qr_value_column_id;
        } else if (
          args.uidt === "Barcode" &&
          args.meta?.fk_barcode_value_column_id
        ) {
          columnDefinition.fk_barcode_value_column_id =
            args.meta.fk_barcode_value_column_id;
          if (args.meta.barcode_format) {
            columnDefinition.barcode_format = args.meta.barcode_format;
          }
        } else if (args.meta) {
          // For other column types, keep meta as is
          columnDefinition.meta = args.meta;
        }
    
        const column = await client.addColumn(args.table_id, columnDefinition);
        return {
          column: {
            id: column.id,
            title: column.title,
            column_name: column.column_name,
            uidt: column.uidt,
            dt: column.dt,
            pk: column.pk,
            rqd: column.rqd,
            unique: column.unique,
            ai: column.ai,
          },
          message: `Column '${column.title}' added successfully to table`,
        };
      },
    },
  • src/index.ts:55-62 (registration)
    Top-level aggregation of all tools including tableTools (with 'add_column') into allTools used by MCP server for tool listing and execution.
    const allTools = [
      ...databaseTools,
      ...tableTools,
      ...recordTools,
      ...viewTools,
      ...queryTools,
      ...attachmentTools,
    ];

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