dcf_analysis
Perform Discounted Cash Flow valuation analysis to evaluate investment opportunities using cash flow data from Excel or CSV files.
Instructions
Perform Discounted Cash Flow (DCF) valuation analysis for investment evaluation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Path to the CSV or Excel file with cash flow data | |
| sheet | No | Sheet name for Excel files (optional) | |
| assumptions | No | DCF assumptions (optional) |
Implementation Reference
- The core handler function that implements the DCF analysis tool. It reads file data, applies default or provided assumptions, generates projected cash flows, computes NPV using HyperFormula engine, calculates terminal and enterprise value, and returns structured results or error.async dcfAnalysis(args: ToolArgs): Promise<ToolResponse> { const { filePath, sheet, assumptions = {} } = args; try { const data = await readFileContent(filePath, sheet); // Default DCF assumptions const dcfParams = { initialInvestment: assumptions.initialInvestment || -1000000, growthRate: assumptions.growthRate || 0.15, discountRate: assumptions.discountRate || 0.12, terminalMultiple: assumptions.terminalMultiple || 8, projectionYears: assumptions.projectionYears || 5, ...assumptions }; // Generate cash flow projections const cashFlows = []; let revenue = assumptions.startingRevenue || 1000000; for (let year = 1; year <= dcfParams.projectionYears; year++) { revenue *= (1 + dcfParams.growthRate); const cashFlow = revenue * 0.2; // 20% margin simplified cashFlows.push(cashFlow); } // Calculate NPV const npvFormula = `NPV(${dcfParams.discountRate}, ${cashFlows.join(',')})`; const mockContext: WorkbookContext = { getCellValue: () => 0, getNamedRangeValue: () => 0, getRangeValues: () => [], getSheetCellValue: () => 0, getSheetRangeValues: () => [] }; const npv = hyperFormulaEngine.evaluateFormula(npvFormula, mockContext); // Terminal value const terminalValue = cashFlows[cashFlows.length - 1] * dcfParams.terminalMultiple; const enterpriseValue = (typeof npv === 'number' ? npv : 0) + terminalValue + Math.abs(dcfParams.initialInvestment); return { content: [{ type: 'text', text: JSON.stringify({ success: true, model: 'DCF Analysis', assumptions: dcfParams, projections: { cashFlows, npv, terminalValue, enterpriseValue }, valuation: { enterpriseValue, equityValue: enterpriseValue, // Simplified valuePerShare: enterpriseValue / 1000000 // Simplified } }, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: error instanceof Error ? error.message : 'Unknown error', operation: 'dcf_analysis' }, null, 2) }] }; } }
- src/index.ts:396-422 (schema)The input schema definition for the dcf_analysis tool, defining parameters like filePath (required), sheet, and optional assumptions object with DCF-specific properties.name: 'dcf_analysis', description: 'Perform Discounted Cash Flow (DCF) valuation analysis for investment evaluation', inputSchema: { type: 'object', properties: { filePath: { type: 'string', description: 'Path to the CSV or Excel file with cash flow data' }, sheet: { type: 'string', description: 'Sheet name for Excel files (optional)' }, assumptions: { type: 'object', description: 'DCF assumptions (optional)', properties: { initialInvestment: { type: 'number', description: 'Initial investment amount (negative)' }, growthRate: { type: 'number', description: 'Annual growth rate (0.15 = 15%)' }, discountRate: { type: 'number', description: 'Discount rate/WACC (0.12 = 12%)' }, terminalMultiple: { type: 'number', description: 'Terminal value multiple (8x)' }, projectionYears: { type: 'number', description: 'Number of projection years' } } } }, required: ['filePath'] }
- src/index.ts:1231-1240 (registration)The switch case registration that maps the 'dcf_analysis' tool call to the financialHandler.dcfAnalysis method in the MCP server request handler.case 'dcf_analysis': return await this.financialHandler.dcfAnalysis(toolArgs); case 'budget_variance_analysis': return await this.financialHandler.budgetVarianceAnalysis(toolArgs); case 'ratio_analysis': return await this.financialHandler.ratioAnalysis(toolArgs); case 'scenario_modeling': return await this.financialHandler.scenarioModeling(toolArgs); case 'trend_analysis': return await this.financialHandler.trendAnalysis(toolArgs);