mcp-quickbase
Version:
Work with Quickbase via Model Context Protocol
99 lines • 3.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.UpdateTableTool = void 0;
const base_1 = require("../base");
const logger_1 = require("../../utils/logger");
const logger = (0, logger_1.createLogger)('UpdateTableTool');
/**
* Tool for updating an existing table in a Quickbase application
*/
class UpdateTableTool extends base_1.BaseTool {
/**
* Constructor
* @param client Quickbase client
*/
constructor(client) {
super(client);
this.name = 'update_table';
this.description = 'Updates an existing Quickbase table';
/**
* Parameter schema for update_table
*/
this.paramSchema = {
type: 'object',
properties: {
table_id: {
type: 'string',
description: 'The ID of the table'
},
name: {
type: 'string',
description: 'New name for the table'
},
description: {
type: 'string',
description: 'New description for the table'
},
options: {
type: 'object',
description: 'Additional options for table update'
}
},
required: ['table_id']
};
}
/**
* Run the update_table tool
* @param params Tool parameters
* @returns Updated table details
*/
async run(params) {
logger.info('Updating Quickbase table', {
tableId: params.table_id
});
const { table_id, name, description, options } = params;
// At least one update field is required
if (!name && !description && (!options || Object.keys(options).length === 0)) {
throw new Error('At least one update field (name, description, or options) is required');
}
// Prepare request body with only the fields that are provided
const body = {};
if (name !== undefined) {
body.name = name;
}
if (description !== undefined) {
body.description = description;
}
// Add any additional options
if (options) {
Object.assign(body, options);
}
// Update the table
const response = await this.client.request({
method: 'POST',
path: `/tables/${table_id}`,
body
});
if (!response.success || !response.data) {
logger.error('Failed to update table', {
error: response.error,
tableId: table_id
});
throw new Error(response.error?.message || 'Failed to update table');
}
const table = response.data;
logger.info('Successfully updated table', {
tableId: table.id,
updates: Object.keys(body).join(', ')
});
return {
tableId: table.id,
name: table.name,
description: table.description,
updated: table.updated || new Date().toISOString(),
...table
};
}
}
exports.UpdateTableTool = UpdateTableTool;
//# sourceMappingURL=update_table.js.map