mcp-quickbase
Version:
Work with Quickbase via Model Context Protocol
96 lines • 3.17 kB
JavaScript
;
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. IMPORTANT: This only creates the table structure with system fields. To add custom fields, use the create_field tool after creating the table.";
/**
* 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",
},
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, options } = params;
// Prepare request body
const body = {
name,
description: description || "",
};
// 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