Skip to main content
Glama

create_table

Create a new database table with custom columns including SingleSelect, PhoneNumber, QR Code, and Barcode types to organize data in NocoDB.

Instructions

Create a new table in a base with specified columns. Supports various column types including SingleSelect (with options), PhoneNumber, QrCode, and Barcode.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
base_idYesThe ID of the base/project
table_nameYesName of the new table
columnsYesArray of column definitions

Implementation Reference

  • The handler function that implements the core logic of the 'create_table' tool. It uses the NocoDBClient to create a table with the given base_id, table_name, and columns, then returns the created table details.
    handler: async ( client: NocoDBClient, args: { base_id: string; table_name: string; columns: any[]; }, ) => { const table = await client.createTable( args.base_id, args.table_name, args.columns, ); return { table: { id: table.id, table_name: table.table_name, title: table.title, type: table.type, enabled: table.enabled, created_at: table.created_at, updated_at: table.updated_at, }, message: `Table '${table.title}' created successfully`, }; },
  • The input schema for the 'create_table' tool, specifying required parameters base_id, table_name, and an array of columns with properties like title, uidt, dt, pk, etc., supporting various column types.
    inputSchema: { type: "object", properties: { base_id: { type: "string", description: "The ID of the base/project", }, table_name: { type: "string", description: "Name of the new table", }, columns: { type: "array", description: "Array of column definitions", items: { type: "object", properties: { title: { type: "string", description: "Column display name", }, column_name: { type: "string", description: "Column name in database", }, 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", }, pk: { type: "boolean", description: "Is primary key", }, rqd: { type: "boolean", description: "Is required field", }, unique: { type: "boolean", description: "Is unique constraint", }, ai: { type: "boolean", description: "Is auto increment", }, meta: { type: "object", description: "Additional metadata for specific column types (e.g., options for SingleSelect/MultiSelect, reference columns for QrCode/Barcode)", }, }, required: ["title", "uidt"], }, }, }, required: ["base_id", "table_name", "columns"], },
  • The complete tool definition object for 'create_table' as part of the exported tableTools array, which defines name, description, inputSchema, and handler.
    { name: "create_table", description: "Create a new table in a base with specified columns. Supports various column types including SingleSelect (with options), PhoneNumber, QrCode, and Barcode.", inputSchema: { type: "object", properties: { base_id: { type: "string", description: "The ID of the base/project", }, table_name: { type: "string", description: "Name of the new table", }, columns: { type: "array", description: "Array of column definitions", items: { type: "object", properties: { title: { type: "string", description: "Column display name", }, column_name: { type: "string", description: "Column name in database", }, 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", }, pk: { type: "boolean", description: "Is primary key", }, rqd: { type: "boolean", description: "Is required field", }, unique: { type: "boolean", description: "Is unique constraint", }, ai: { type: "boolean", description: "Is auto increment", }, meta: { type: "object", description: "Additional metadata for specific column types (e.g., options for SingleSelect/MultiSelect, reference columns for QrCode/Barcode)", }, }, required: ["title", "uidt"], }, }, }, required: ["base_id", "table_name", "columns"], }, handler: async ( client: NocoDBClient, args: { base_id: string; table_name: string; columns: any[]; }, ) => { const table = await client.createTable( args.base_id, args.table_name, args.columns, ); return { table: { id: table.id, table_name: table.table_name, title: table.title, type: table.type, enabled: table.enabled, created_at: table.created_at, updated_at: table.updated_at, }, message: `Table '${table.title}' created successfully`, }; }, },
  • src/index.ts:55-73 (registration)
    In the main MCP server file, tableTools (including create_table) is imported and spread into allTools, which is then used to register the tools list handler for the MCP protocol.
    const allTools = [ ...databaseTools, ...tableTools, ...recordTools, ...viewTools, ...queryTools, ...attachmentTools, ]; // Register handlers server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: allTools.map((tool) => ({ name: tool.name, description: tool.description, inputSchema: tool.inputSchema, })), }; });
  • src/index.ts:75-103 (registration)
    The MCP call tool handler that dispatches to the specific tool handler (like create_table's) based on name from allTools.
    server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; const tool = allTools.find((t) => t.name === name); if (!tool) { throw new McpError(ErrorCode.MethodNotFound, `Tool ${name} not found`); } try { const result = await tool.handler(nocodb, args); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { if (error instanceof NocoDBError) { throw new McpError( ErrorCode.InternalError, `NocoDB error: ${error.message}`, error.details, ); } throw error; } });

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