@simonecoelhosfo/optimizely-mcp-server
Version:
Optimizely MCP Server for AI assistants with integrated CLI tools
66 lines ⢠2.79 kB
JavaScript
/**
* Get Flag History Tool - Individual Module
* @description Retrieves historical changes and audit trail for flags
* @since 2025-08-04
* @author Tool Modularization Team
*
* Migration Status: COMPLETED
* Original Method: Delegates to manageEntityLifecycle with operation "history"
* Complexity: MEDIUM
* Dependencies: logger, errorMapper, manageEntityLifecycle
*/
/**
* Creates the Get Flag History tool with injected dependencies
* @param deps - Injected dependencies (storage, logger, errorMapper, etc.)
* @returns Tool definition with handler
*/
export function createGetFlagHistoryTool(deps) {
return {
name: 'get_flag_history',
requiresCache: true,
category: 'analytics',
description: `š AUDIT TRAIL for specific flag changes and modifications
š¤ DECISION PATTERN:
⢠"What changed on this flag recently?" ā flag_key + recent dates
⢠"Who modified this flag?" ā flag_key only (full history)
⢠"Changes in specific period?" ā flag_key + start_date + end_date
š HISTORY DATA:
⢠Who made each change (user email)
⢠When changes occurred (timestamps)
⢠What was modified (enable/disable, traffic, variables)
⢠Before/after values for changes
ā” FILTERING OPTIONS:
⢠start_date + end_date ā Specific time range
⢠Omit dates ā Complete flag history
⢠ISO 8601 format required for date filters
š” EXAMPLES:
⢠Recent changes: {"project_id": "12345", "flag_key": "checkout-flow", "start_date": "2024-01-01T00:00:00Z"}`,
handler: async (args) => {
const { project_id, flag_key, start_date, end_date, per_page } = args;
if (!project_id || !flag_key) {
throw deps.errorMapper.toMCPError(new Error('Missing required parameters: project_id and flag_key'), { operation: 'Get flag history', tool: 'get_flag_history' });
}
try {
// Delegate to manageEntityLifecycle with "history" operation
const result = await deps.manageEntityLifecycle("history", "flag", undefined, String(flag_key), String(project_id), {
start_date: start_date,
end_date: end_date,
per_page: per_page,
});
return result;
}
catch (error) {
deps.logger.error({
error: error.message,
project_id,
flag_key
}, 'GetFlagHistory: Tool execution failed');
throw deps.errorMapper.toMCPError(error, {
operation: 'Get flag change history',
tool: 'get_flag_history'
});
}
}
};
}
//# sourceMappingURL=GetFlagHistory.js.map