mcp-quickbase
Version:
Work with Quickbase via Model Context Protocol
82 lines • 2.69 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetFieldTool = void 0;
const base_1 = require("../base");
const logger_1 = require("../../utils/logger");
const logger = (0, logger_1.createLogger)("GetFieldTool");
/**
* Tool for retrieving detailed information about a single field by ID
*/
class GetFieldTool extends base_1.BaseTool {
/**
* Constructor
* @param client Quickbase client
*/
constructor(client) {
super(client);
this.name = "get_field";
this.description = "Retrieves detailed information about a single field in a Quickbase table by its field ID";
/**
* Parameter schema for get_field
*/
this.paramSchema = {
type: "object",
properties: {
table_id: {
type: "string",
description: "The ID of the Quickbase table containing the field",
},
field_id: {
type: "string",
description: "The ID of the field to retrieve",
},
},
required: ["table_id", "field_id"],
};
}
/**
* Run the get_field tool
* @param params Tool parameters
* @returns Field information
*/
async run(params) {
const { table_id, field_id } = params;
logger.info("Retrieving field from Quickbase table", {
tableId: table_id,
fieldId: field_id,
});
// Get the field
const response = await this.client.request({
method: "GET",
path: `/fields/${field_id}?tableId=${table_id}`,
});
if (!response.success || !response.data) {
logger.error("Failed to retrieve field", {
error: response.error,
tableId: table_id,
fieldId: field_id,
});
throw new Error(response.error?.message || "Failed to retrieve field");
}
const field = response.data;
logger.info("Successfully retrieved field", {
fieldId: field.id,
tableId: table_id,
label: field.label,
fieldType: field.fieldType,
});
return {
fieldId: field.id,
label: field.label,
fieldType: field.fieldType,
description: field.description,
required: field.required,
unique: field.unique,
properties: field.properties,
tableId: table_id,
...field,
};
}
}
exports.GetFieldTool = GetFieldTool;
//# sourceMappingURL=get_field.js.map