UNPKG

mcp-quickbase

Version:

Work with Quickbase via Model Context Protocol

119 lines 3.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CreateTableTool = void 0; const base_1 = require("../base"); const logger_1 = require("../../utils/logger"); const logger = (0, logger_1.createLogger)('CreateTableTool'); /** * Tool for creating a new table in a Quickbase application */ class CreateTableTool extends base_1.BaseTool { /** * Constructor * @param client Quickbase client */ constructor(client) { super(client); this.name = 'create_table'; this.description = 'Creates a new table in a Quickbase application'; /** * Parameter schema for create_table */ this.paramSchema = { type: 'object', properties: { app_id: { type: 'string', description: 'The ID of the application' }, name: { type: 'string', description: 'Name of the table' }, description: { type: 'string', description: 'Description of the table' }, fields: { type: 'array', description: 'List of field definitions', items: { type: 'object', properties: { name: { type: 'string' }, type: { type: 'string' }, description: { type: 'string' }, properties: { type: 'object' } }, required: ['name', 'type'] } }, options: { type: 'object', description: 'Additional options for table creation' } }, required: ['app_id', 'name'] }; } /** * Run the create_table tool * @param params Tool parameters * @returns Created table details */ async run(params) { logger.info('Creating new table in Quickbase application', { appId: params.app_id, tableName: params.name }); const { app_id, name, description, fields, options } = params; // Prepare request body const body = { name, description: description || '' }; // Add fields if provided if (fields && fields.length > 0) { body.fields = fields.map(field => ({ fieldType: field.type, label: field.name, description: field.description || '', ...(field.properties || {}) })); } // Add any additional options if (options) { Object.assign(body, options); } // Create the table const response = await this.client.request({ method: 'POST', path: `/tables?appId=${app_id}`, body }); if (!response.success || !response.data) { logger.error('Failed to create table', { error: response.error, appId: app_id, tableName: name }); throw new Error(response.error?.message || 'Failed to create table'); } const table = response.data; logger.info('Successfully created table', { tableId: table.id, appId: app_id, tableName: table.name }); return { tableId: table.id, name: table.name, description: table.description, fields: table.fields, created: table.created, ...table }; } } exports.CreateTableTool = CreateTableTool; //# sourceMappingURL=create_table.js.map