UNPKG

mcp-quickbase

Version:

Work with Quickbase via Model Context Protocol

101 lines 3.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UpdateAppTool = void 0; const base_1 = require("../base"); const logger_1 = require("../../utils/logger"); const logger = (0, logger_1.createLogger)("UpdateAppTool"); /** * Tool for updating an existing Quickbase application */ class UpdateAppTool extends base_1.BaseTool { /** * Constructor * @param client Quickbase client */ constructor(client) { super(client); this.name = "update_app"; this.description = "Updates an existing Quickbase application"; /** * Parameter schema for update_app */ this.paramSchema = { type: "object", properties: { app_id: { type: "string", description: "The ID of the application", }, name: { type: "string", description: "New name for the application", }, description: { type: "string", description: "New description for the application", }, options: { type: "object", description: "Additional options for app update", }, }, required: ["app_id"], }; } /** * Run the update_app tool * @param params Tool parameters * @returns Updated application details */ async run(params) { logger.info("Updating Quickbase application", { appId: params.app_id, }); const { app_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 application const response = await this.client.request({ method: "POST", path: `/apps/${app_id}`, body, }); if (!response.success || !response.data) { logger.error("Failed to update application", { error: response.error, appId: app_id, }); throw new Error(response.error?.message || "Failed to update application"); } const app = response.data; logger.info("Successfully updated application", { appId: app.id, updates: Object.keys(body).join(", "), }); return { appId: app.id, name: app.name, description: app.description, updated: app.updated || new Date().toISOString(), ...app, }; } } exports.UpdateAppTool = UpdateAppTool; //# sourceMappingURL=update_app.js.map