Skip to main content
Glama

create_field

Add a new field to an Airtable table by specifying the field name, type, and optional description or options to customize your database structure.

Instructions

Create a new field in a table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
base_idYesID of the base
table_idYesID of the table
fieldYes

Implementation Reference

  • Handler function for the 'create_field' tool. It validates the field input and sends a POST request to the Airtable metadata API to create a new field in the specified table.
    case "create_field": { const { base_id, table_id, field } = request.params.arguments as { base_id: string; table_id: string; field: FieldOption; }; // Validate field before creation const validatedField = this.validateField(field); const response = await this.axiosInstance.post( `/meta/bases/${base_id}/tables/${table_id}/fields`, validatedField ); return { content: [{ type: "text", text: JSON.stringify(response.data, null, 2), }], }; }
  • src/index.ts:174-213 (registration)
    Tool registration in the list of available tools, including name, description, and detailed input schema definition.
    { name: "create_field", description: "Create a new field in a table", inputSchema: { type: "object", properties: { base_id: { type: "string", description: "ID of the base", }, table_id: { type: "string", description: "ID of the table", }, field: { type: "object", properties: { name: { type: "string", description: "Name of the field", }, type: { type: "string", description: "Type of the field", }, description: { type: "string", description: "Description of the field", }, options: { type: "object", description: "Field-specific options", }, }, required: ["name", "type"], }, }, required: ["base_id", "table_id", "field"], }, },
  • Helper function to validate and normalize field options before creation, removing unnecessary options or adding defaults based on field type.
    private validateField(field: FieldOption): FieldOption { const { type } = field; // Remove options for fields that don't need them if (!fieldRequiresOptions(type as FieldType)) { const { options, ...rest } = field; return rest; } // Add default options for fields that require them if (!field.options) { return { ...field, options: getDefaultOptions(type as FieldType), }; } return field; }
  • Type definition for FieldOption used in create_field input.
    export interface FieldOption { name: string; type: FieldType; description?: string; options?: Record<string, any>; }
  • Helper function determining if a field type requires options, used in validation.
    export const fieldRequiresOptions = (type: FieldType): boolean => { switch (type) { case 'number': case 'singleSelect': case 'multiSelect': case 'date': case 'currency': return true; default: return false; } };

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/felores/airtable-mcp'

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