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,
    ];
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While it mentions some implementation details for specific column types, it doesn't address critical behavioral aspects like whether this is a destructive operation (modifies table structure), what permissions are required, error conditions, or what happens if the operation fails. For a schema-altering tool with 15 parameters, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with the core purpose. The three subsequent sentences provide specific guidance for different column types without unnecessary elaboration. Every sentence serves a clear purpose, though the structure could be slightly improved with clearer separation between general and type-specific guidance.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex schema-altering tool with 15 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain the tool's impact on existing data, error handling, return values, or relationships between the many parameters. The description provides only minimal guidance for a few specific column types, leaving most behavioral and operational context undocumented.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds some semantic context for specific parameter combinations (SingleSelect requires options in meta, QrCode/Barcode need reference column IDs, PhoneNumber uses text storage), which provides value beyond the 100% schema description coverage. However, it doesn't explain relationships between parameters or provide guidance on which parameters are most important for common use cases.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Add a new column') and target resource ('to an existing table'), distinguishing it from sibling tools like create_table (creates new table) or delete_column (removes column). It provides a precise verb+resource combination that leaves no ambiguity about the tool's function.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides implied usage guidance through examples for specific column types (SingleSelect, QrCode/Barcode, PhoneNumber), but doesn't explicitly state when to use this tool versus alternatives or mention prerequisites. There's no comparison to sibling tools like update_record or create_table for similar operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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