UNPKG

@simonecoelhosfo/optimizely-mcp-server

Version:

Optimizely MCP Server for AI assistants with integrated CLI tools

66 lines • 2.79 kB
/** * 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