UNPKG

@spaik/mcp-server-roi

Version:

MCP server for AI ROI prediction and tracking with Monte Carlo simulations

777 lines 30.4 kB
import { z } from 'zod'; import { createLogger } from '../utils/logger.js'; import { FINANCIAL_CONSTANTS } from '../core/calculators/financial-utils.js'; // Industry-specific use case patterns export const IndustryUseCaseSchema = z.object({ name: z.string(), category: z.string(), volume: z.number().min(0), currentCost: z.number().min(0), currentTime: z.number().min(0), // minutes automationPotential: z.enum(['low', 'medium', 'high']), // Industry-specific fields industryMetrics: z.record(z.string(), z.any()).optional() }); // Base calculator interface export class IndustryCalculator { industryName; logger; constructor(industryName) { this.industryName = industryName; this.logger = createLogger({ service: `${this.industryName}Calculator` }); } /** * Calculate automation percentage based on potential */ getAutomationPercentage(potential) { const map = { low: 0.25, medium: 0.60, high: 0.85 }; return map[potential]; } /** * Calculate time reduction based on automation */ calculateTimeReduction(automationPercentage, processType) { // Base reduction from automation let reduction = automationPercentage * 0.8; // Adjust based on process type const processMultipliers = { 'data_entry': 0.95, 'document_processing': 0.90, 'customer_service': 0.75, 'analysis': 0.70, 'decision_making': 0.60 }; const multiplier = processMultipliers[processType] || 0.75; return reduction * multiplier; } } /** * Retail Industry Calculator */ export class RetailCalculator extends IndustryCalculator { constructor() { super('Retail'); } calculateROI(useCase) { const automationPct = this.getAutomationPercentage(useCase.automationPotential); const timeReduction = this.calculateTimeReduction(automationPct, useCase.category); // Retail-specific calculations const laborCostPerHour = 15; // Retail average const overheadMultiplier = 1.3; // Benefits, training, etc. // Calculate benefits const laborSavings = useCase.volume * (useCase.currentTime / 60) * laborCostPerHour * overheadMultiplier * timeReduction; const transactionCostSavings = useCase.volume * useCase.currentCost * automationPct; // Retail-specific: Customer satisfaction improvement const customerSatisfactionValue = this.calculateCustomerSatisfactionValue(useCase, automationPct); // Retail-specific: Inventory optimization const inventoryOptimizationValue = this.calculateInventoryValue(useCase); const monthlyBenefit = laborSavings + transactionCostSavings + customerSatisfactionValue + inventoryOptimizationValue; // Implementation costs const baseCost = 25000; // Lower for retail const complexityMultiplier = useCase.volume > 10000 ? 1.5 : 1.0; const implementationCost = baseCost * complexityMultiplier; // Time to value is typically faster in retail const timeToValue = useCase.automationPotential === 'high' ? 2 : 4; // Confidence based on use case maturity in retail const confidenceMap = { 'pos_automation': 0.90, 'inventory_management': 0.85, 'customer_service': 0.80, 'pricing_optimization': 0.75, 'supply_chain': 0.70 }; const confidenceScore = confidenceMap[useCase.category] || 0.75; return { monthlyBenefit, implementationCost, timeToValue, confidenceScore, specificMetrics: { laborSavings, transactionCostSavings, customerSatisfactionValue, inventoryOptimizationValue, laborHoursPerMonth: useCase.volume * (useCase.currentTime / 60), laborToSalesRatio: this.calculateLaborToSalesRatio(useCase) } }; } generateRecommendations(companySize, currentChallenges) { const recommendations = []; // Base recommendations for all retail recommendations.push({ name: 'Automated Inventory Management', category: 'inventory_management', volume: companySize === 'small' ? 1000 : 10000, currentCost: 0.5, currentTime: 5, automationPotential: 'high', industryMetrics: { stockoutReduction: 0.7, overStockReduction: 0.5 } }); recommendations.push({ name: 'Customer Service Chatbot', category: 'customer_service', volume: companySize === 'small' ? 500 : 5000, currentCost: 3, currentTime: 10, automationPotential: 'medium', industryMetrics: { firstContactResolution: 0.6, customerSatisfactionIncrease: 0.15 } }); // Size-specific recommendations if (companySize === 'large' || companySize === 'enterprise') { recommendations.push({ name: 'Dynamic Pricing Optimization', category: 'pricing_optimization', volume: 50000, currentCost: 0.1, currentTime: 2, automationPotential: 'high', industryMetrics: { revenueIncrease: 0.05, marginImprovement: 0.03 } }); } // Challenge-specific recommendations if (currentChallenges?.includes('staff_turnover')) { recommendations.push({ name: 'Automated Staff Scheduling', category: 'workforce_management', volume: 200, currentCost: 50, currentTime: 120, automationPotential: 'high', industryMetrics: { overtimeReduction: 0.3, staffSatisfaction: 0.25 } }); } return recommendations; } getIndustryKPIs() { return [ { name: 'Labor-to-Sales Ratio', description: 'Labor costs as percentage of sales', unit: '%', benchmarkValue: 12, importance: 'critical' }, { name: 'Conversion Rate', description: 'Percentage of visitors who make a purchase', unit: '%', benchmarkValue: 3.5, importance: 'high' }, { name: 'Inventory Turnover', description: 'How many times inventory is sold per year', unit: 'times/year', benchmarkValue: 8, importance: 'critical' }, { name: 'Customer Retention Rate', description: 'Percentage of customers who return', unit: '%', benchmarkValue: 65, importance: 'high' } ]; } calculateCustomerSatisfactionValue(useCase, automationPct) { // Faster service = happier customers = more sales const satisfactionIncrease = automationPct * 0.15; const averageTransactionValue = 50; // Retail average const additionalTransactions = useCase.volume * satisfactionIncrease * 0.1; const profitMargin = 0.3; return additionalTransactions * averageTransactionValue * profitMargin; } calculateInventoryValue(useCase) { if (useCase.category !== 'inventory_management') return 0; const metrics = useCase.industryMetrics || {}; const inventoryValue = useCase.volume * 100; // Average item value const carryingCost = 0.25 / 12; // 25% annual carrying cost const stockoutCost = 50; // Lost sales per stockout const carryingSavings = inventoryValue * carryingCost * (metrics.overStockReduction || 0.3); const stockoutSavings = useCase.volume * 0.05 * stockoutCost * (metrics.stockoutReduction || 0.5); return carryingSavings + stockoutSavings; } calculateLaborToSalesRatio(useCase) { const laborCost = useCase.volume * (useCase.currentTime / 60) * 15 * 1.3; const estimatedSales = useCase.volume * 50; // Average transaction value return (laborCost / estimatedSales) * 100; } } /** * Healthcare Industry Calculator */ export class HealthcareCalculator extends IndustryCalculator { constructor() { super('Healthcare'); } calculateROI(useCase) { const automationPct = this.getAutomationPercentage(useCase.automationPotential); const timeReduction = this.calculateTimeReduction(automationPct, useCase.category); // Healthcare-specific calculations const clinicalLaborCost = 75; // Higher for clinical staff const adminLaborCost = 35; const laborCost = useCase.category.includes('clinical') ? clinicalLaborCost : adminLaborCost; // Calculate benefits const laborSavings = useCase.volume * (useCase.currentTime / 60) * laborCost * timeReduction; const transactionCostSavings = useCase.volume * useCase.currentCost * automationPct; // Healthcare-specific: Compliance and error reduction const complianceValue = this.calculateComplianceValue(useCase, automationPct); const patientSafetyValue = this.calculatePatientSafetyValue(useCase, automationPct); const monthlyBenefit = laborSavings + transactionCostSavings + complianceValue + patientSafetyValue; // Implementation costs (higher due to regulations) const baseCost = 75000; const complianceMultiplier = 1.5; // HIPAA, etc. const implementationCost = baseCost * complianceMultiplier; // Time to value is longer in healthcare const timeToValue = useCase.automationPotential === 'high' ? 6 : 9; // Confidence adjusted for healthcare const confidenceScore = useCase.category.includes('clinical') ? 0.65 : 0.75; return { monthlyBenefit, implementationCost, timeToValue, confidenceScore, specificMetrics: { laborSavings, transactionCostSavings, complianceValue, patientSafetyValue, patientImpact: this.calculatePatientImpact(useCase), regulatoryRisk: useCase.category.includes('clinical') ? 'high' : 'medium' } }; } generateRecommendations(companySize, currentChallenges) { const recommendations = []; // Universal healthcare recommendations recommendations.push({ name: 'Prior Authorization Automation', category: 'administrative', volume: companySize === 'small' ? 200 : 2000, currentCost: 25, currentTime: 30, automationPotential: 'high', industryMetrics: { approvalTime: 2, // days denialReduction: 0.3 } }); recommendations.push({ name: 'Patient Appointment Scheduling AI', category: 'patient_engagement', volume: companySize === 'small' ? 500 : 5000, currentCost: 5, currentTime: 10, automationPotential: 'medium', industryMetrics: { noShowReduction: 0.25, utilizationIncrease: 0.15 } }); // Size-specific if (companySize === 'large' || companySize === 'enterprise') { recommendations.push({ name: 'Clinical Decision Support System', category: 'clinical_ai', volume: 10000, currentCost: 0, currentTime: 15, automationPotential: 'medium', industryMetrics: { diagnosticAccuracy: 0.95, timeToDecision: 0.5 } }); } // Challenge-specific if (currentChallenges?.includes('nurse_shortage')) { recommendations.push({ name: 'Nurse Workload Optimization', category: 'workforce_clinical', volume: 1000, currentCost: 0, currentTime: 20, automationPotential: 'medium', industryMetrics: { patientLoadBalance: 0.85, overtimeReduction: 0.4 } }); } return recommendations; } getIndustryKPIs() { return [ { name: 'Patient Satisfaction Score', description: 'HCAHPS or similar patient experience metric', unit: 'score', benchmarkValue: 4.2, importance: 'critical' }, { name: 'Readmission Rate', description: '30-day readmission percentage', unit: '%', benchmarkValue: 15.5, importance: 'critical' }, { name: 'Revenue Cycle Days', description: 'Days from service to payment', unit: 'days', benchmarkValue: 45, importance: 'high' }, { name: 'Clinical Quality Score', description: 'Composite quality metric', unit: 'score', benchmarkValue: 85, importance: 'critical' } ]; } calculateComplianceValue(useCase, automationPct) { // Reduced compliance violations and associated penalties const averagePenalty = 50000 / 12; // Annual penalty spread monthly const violationReduction = automationPct * 0.7; const complianceRisk = useCase.category.includes('clinical') ? 0.1 : 0.05; return averagePenalty * complianceRisk * violationReduction; } calculatePatientSafetyValue(useCase, automationPct) { if (!useCase.category.includes('clinical')) return 0; // Value of prevented medical errors const errorRate = 0.03; // 3% baseline error rate const errorCost = 5000; // Average cost per error const errorReduction = automationPct * 0.6; return useCase.volume * errorRate * errorCost * errorReduction; } calculatePatientImpact(useCase) { // Number of patients positively impacted if (useCase.category.includes('clinical')) { return useCase.volume; } else if (useCase.category.includes('patient_')) { return useCase.volume * 0.8; } else { return useCase.volume * 0.3; } } } /** * Manufacturing Industry Calculator */ export class ManufacturingCalculator extends IndustryCalculator { constructor() { super('Manufacturing'); } calculateROI(useCase) { const automationPct = this.getAutomationPercentage(useCase.automationPotential); const timeReduction = this.calculateTimeReduction(automationPct, useCase.category); // Manufacturing-specific calculations const operatorCost = 25; const engineerCost = 50; const laborCost = useCase.category.includes('engineering') ? engineerCost : operatorCost; // Calculate benefits const laborSavings = useCase.volume * (useCase.currentTime / 60) * laborCost * timeReduction; const transactionCostSavings = useCase.volume * useCase.currentCost * automationPct; // Manufacturing-specific: Downtime prevention const downtimeValue = this.calculateDowntimeValue(useCase, automationPct); const qualityValue = this.calculateQualityValue(useCase, automationPct); const safetyValue = this.calculateSafetyValue(useCase, automationPct); const monthlyBenefit = laborSavings + transactionCostSavings + downtimeValue + qualityValue + safetyValue; // Implementation costs const baseCost = 50000; const integrationMultiplier = 1.3; // OT/IT integration const implementationCost = baseCost * integrationMultiplier; // Time to value const timeToValue = useCase.automationPotential === 'high' ? 4 : 6; // Confidence score const confidenceScore = 0.80; // Manufacturing AI is mature return { monthlyBenefit, implementationCost, timeToValue, confidenceScore, specificMetrics: { laborSavings, transactionCostSavings, downtimeValue, qualityValue, safetyValue, oeeImprovement: this.calculateOEEImprovement(useCase, automationPct), throughputIncrease: timeReduction * 0.7 } }; } generateRecommendations(companySize, currentChallenges) { const recommendations = []; // Universal manufacturing recommendations recommendations.push({ name: 'Predictive Maintenance AI', category: 'maintenance', volume: companySize === 'small' ? 50 : 500, currentCost: 500, currentTime: 240, automationPotential: 'high', industryMetrics: { downtimeReduction: 0.7, maintenanceCostReduction: 0.3 } }); recommendations.push({ name: 'Quality Control Computer Vision', category: 'quality', volume: companySize === 'small' ? 1000 : 50000, currentCost: 0.5, currentTime: 2, automationPotential: 'high', industryMetrics: { defectDetection: 0.99, falsePositiveRate: 0.01 } }); // Size-specific if (companySize !== 'small') { recommendations.push({ name: 'Production Planning Optimization', category: 'planning', volume: 200, currentCost: 100, currentTime: 480, automationPotential: 'medium', industryMetrics: { scheduleOptimization: 0.25, changeoverReduction: 0.2 } }); } // Challenge-specific if (currentChallenges?.includes('supply_chain')) { recommendations.push({ name: 'Supply Chain Visibility AI', category: 'supply_chain', volume: 500, currentCost: 50, currentTime: 60, automationPotential: 'medium', industryMetrics: { stockoutReduction: 0.6, leadTimeReduction: 0.2 } }); } return recommendations; } getIndustryKPIs() { return [ { name: 'Overall Equipment Effectiveness (OEE)', description: 'Availability × Performance × Quality', unit: '%', benchmarkValue: 65, importance: 'critical' }, { name: 'First Pass Yield', description: 'Percentage of units passing quality first time', unit: '%', benchmarkValue: 95, importance: 'high' }, { name: 'Unplanned Downtime', description: 'Hours of unplanned production stops', unit: 'hours/month', benchmarkValue: 20, importance: 'critical' }, { name: 'Safety Incident Rate', description: 'Incidents per 100 workers per year', unit: 'rate', benchmarkValue: 3.2, importance: 'critical' } ]; } calculateDowntimeValue(useCase, automationPct) { if (useCase.category !== 'maintenance') return 0; const productionValuePerHour = 10000; // Average manufacturing line const currentDowntimeHours = 20; // Monthly average const downtimeReduction = automationPct * 0.7; return currentDowntimeHours * productionValuePerHour * downtimeReduction; } calculateQualityValue(useCase, automationPct) { if (!useCase.category.includes('quality')) return 0; const defectRate = 0.02; // 2% baseline const defectCost = 50; // Cost per defect const defectReduction = automationPct * 0.8; return useCase.volume * defectRate * defectCost * defectReduction; } calculateSafetyValue(useCase, automationPct) { // Value of prevented safety incidents const incidentRate = 0.001; // Per operation const incidentCost = 25000; // Average incident cost const safetyImprovement = automationPct * 0.5; return useCase.volume * incidentRate * incidentCost * safetyImprovement / 12; } calculateOEEImprovement(useCase, automationPct) { // OEE improvement based on use case type const improvements = { 'maintenance': 0.10, 'quality': 0.08, 'planning': 0.06, 'monitoring': 0.05 }; const baseImprovement = improvements[useCase.category] || 0.03; return baseImprovement * automationPct; } } /** * Financial Services Industry Calculator */ export class FinancialServicesCalculator extends IndustryCalculator { constructor() { super('Financial Services'); } calculateROI(useCase) { const automationPct = this.getAutomationPercentage(useCase.automationPotential); const timeReduction = this.calculateTimeReduction(automationPct, useCase.category); // Financial services specific const analystCost = 60; const operationsCost = 40; const laborCost = useCase.category.includes('analysis') ? analystCost : operationsCost; // Calculate benefits const laborSavings = useCase.volume * (useCase.currentTime / 60) * laborCost * timeReduction; const transactionCostSavings = useCase.volume * useCase.currentCost * automationPct; // Finance-specific: Risk reduction and fraud prevention const riskReductionValue = this.calculateRiskReductionValue(useCase, automationPct); const fraudPreventionValue = this.calculateFraudPreventionValue(useCase, automationPct); const complianceValue = this.calculateFinanceComplianceValue(useCase, automationPct); const monthlyBenefit = laborSavings + transactionCostSavings + riskReductionValue + fraudPreventionValue + complianceValue; // Implementation costs const baseCost = 100000; // Higher for financial services const securityMultiplier = 1.4; // Additional security requirements const implementationCost = baseCost * securityMultiplier; // Time to value const timeToValue = 6; // Longer due to regulations // Confidence score const confidenceScore = 0.85; // High - proven in finance return { monthlyBenefit, implementationCost, timeToValue, confidenceScore, specificMetrics: { laborSavings, transactionCostSavings, riskReductionValue, fraudPreventionValue, complianceValue, processingSpeed: timeReduction * 100, accuracyImprovement: automationPct * 0.99 } }; } generateRecommendations(companySize, currentChallenges) { const recommendations = []; // Universal finance recommendations recommendations.push({ name: 'Fraud Detection AI', category: 'fraud_prevention', volume: companySize === 'small' ? 10000 : 1000000, currentCost: 0.1, currentTime: 0.5, automationPotential: 'high', industryMetrics: { fraudDetectionRate: 0.95, falsePositiveReduction: 0.7 } }); recommendations.push({ name: 'Automated KYC/AML Compliance', category: 'compliance', volume: companySize === 'small' ? 100 : 5000, currentCost: 25, currentTime: 45, automationPotential: 'high', industryMetrics: { complianceTime: 10, accuracyRate: 0.98 } }); // Size-specific if (companySize === 'large' || companySize === 'enterprise') { recommendations.push({ name: 'Algorithmic Trading Optimization', category: 'trading_analysis', volume: 50000, currentCost: 1, currentTime: 0.1, automationPotential: 'high', industryMetrics: { executionImprovement: 0.02, latencyReduction: 0.9 } }); } return recommendations; } getIndustryKPIs() { return [ { name: 'Cost-to-Income Ratio', description: 'Operating costs as percentage of income', unit: '%', benchmarkValue: 55, importance: 'critical' }, { name: 'Fraud Loss Rate', description: 'Fraud losses as percentage of transactions', unit: '%', benchmarkValue: 0.05, importance: 'critical' }, { name: 'Straight-Through Processing Rate', description: 'Transactions processed without manual intervention', unit: '%', benchmarkValue: 85, importance: 'high' }, { name: 'Regulatory Compliance Score', description: 'Compliance audit score', unit: 'score', benchmarkValue: 95, importance: 'critical' } ]; } calculateRiskReductionValue(useCase, automationPct) { // Value of reduced operational and credit risk const riskExposure = useCase.volume * useCase.currentCost * 0.02; // 2% risk const riskReduction = automationPct * 0.6; return riskExposure * riskReduction; } calculateFraudPreventionValue(useCase, automationPct) { if (!useCase.category.includes('fraud')) return 0; const fraudRate = 0.001; // 0.1% baseline const averageFraudLoss = 2000; const fraudPrevention = automationPct * 0.9; return useCase.volume * fraudRate * averageFraudLoss * fraudPrevention; } calculateFinanceComplianceValue(useCase, automationPct) { // Reduced compliance costs and penalties const complianceCostPerTransaction = 2; const penaltyRisk = 0.001; const averagePenalty = 100000 / 12; const complianceSavings = useCase.volume * complianceCostPerTransaction * automationPct * 0.5; const penaltySavings = useCase.volume * penaltyRisk * averagePenalty * automationPct; return complianceSavings + penaltySavings; } } /** * Factory for creating industry-specific calculators */ export class IndustryCalculatorFactory { static calculators = new Map([ ['retail', new RetailCalculator()], ['healthcare', new HealthcareCalculator()], ['manufacturing', new ManufacturingCalculator()], ['financial_services', new FinancialServicesCalculator()] ]); static getCalculator(industry) { const calculator = this.calculators.get(industry.toLowerCase()); if (!calculator) { // Return a generic calculator for unknown industries return new GenericCalculator(industry); } return calculator; } static getSupportedIndustries() { return Array.from(this.calculators.keys()); } } /** * Generic calculator for unsupported industries */ class GenericCalculator extends IndustryCalculator { calculateROI(useCase) { const automationPct = this.getAutomationPercentage(useCase.automationPotential); const timeReduction = this.calculateTimeReduction(automationPct, 'generic'); // Generic calculations const laborSavings = useCase.volume * (useCase.currentTime / 60) * FINANCIAL_CONSTANTS.DEFAULT_HOURLY_RATE * timeReduction; const transactionCostSavings = useCase.volume * useCase.currentCost * automationPct; const monthlyBenefit = laborSavings + transactionCostSavings; const implementationCost = FINANCIAL_CONSTANTS.IMPLEMENTATION_COST_PER_USE_CASE; return { monthlyBenefit, implementationCost, timeToValue: 4, confidenceScore: 0.65, specificMetrics: { laborSavings, transactionCostSavings } }; } generateRecommendations(companySize) { return [{ name: 'Process Automation', category: 'automation', volume: 1000, currentCost: 5, currentTime: 15, automationPotential: 'medium' }]; } getIndustryKPIs() { return [{ name: 'Efficiency Ratio', description: 'Output per unit of input', unit: 'ratio', benchmarkValue: 1.5, importance: 'medium' }]; } } //# sourceMappingURL=industry-calculators.js.map