mcp-quickbase
Version:
Work with Quickbase via Model Context Protocol
77 lines • 2.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigureCacheTool = void 0;
const base_1 = require("./base");
const logger_1 = require("../utils/logger");
const logger = (0, logger_1.createLogger)("ConfigureCacheTool");
/**
* Tool for configuring the caching behavior of the Quickbase connector
*/
class ConfigureCacheTool extends base_1.BaseTool {
/**
* Constructor
* @param client Quickbase client
* @param cacheService Cache service
*/
constructor(client, cacheService) {
super(client);
this.name = "configure_cache";
this.description = "Configures caching behavior for Quickbase operations";
/**
* Parameter schema for configure_cache
*/
this.paramSchema = {
type: "object",
properties: {
enabled: {
type: "boolean",
description: "Whether to enable caching (default: true)",
},
clear: {
type: "boolean",
description: "Whether to clear all existing caches (default: false)",
},
ttl: {
type: "number",
description: "Cache time-to-live in seconds",
},
},
required: [],
};
this.cacheService = cacheService;
}
/**
* Run the configure_cache tool
* @param params Tool parameters
* @returns Configuration result
*/
async run(params) {
logger.info("Configuring cache", params);
const result = {
cacheEnabled: this.cacheService.isEnabled(),
cacheCleared: false,
};
// Clear cache if requested
if (params.clear) {
this.cacheService.clear();
result.cacheCleared = true;
logger.info("Cache cleared");
}
// Enable/disable cache if specified
if (params.enabled !== undefined) {
this.cacheService.setEnabled(params.enabled);
result.cacheEnabled = params.enabled;
logger.info(`Cache ${params.enabled ? "enabled" : "disabled"}`);
}
// Set TTL if specified
if (params.ttl !== undefined && params.ttl > 0) {
// Here we would set TTL
// This requires extending the CacheService to support changing TTL
logger.info(`Cache TTL set to ${params.ttl} seconds`);
result.cacheTtl = params.ttl;
}
return result;
}
}
exports.ConfigureCacheTool = ConfigureCacheTool;
//# sourceMappingURL=configure_cache.js.map