calculate_federal_income_tax
Calculate federal income tax using taxable income and filing status for accurate tax planning and financial reporting.
Instructions
Calculate federal income tax based on taxable income and filing status
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filingStatus | No | single | |
| taxableIncome | Yes |
Implementation Reference
- src/python/tax_calculations.py:79-116 (handler)Core implementation of federal income tax calculation using progressive brackets for different filing statuses.def calculate_federal_income_tax(self, taxable_income: float, filing_status: str = 'single') -> Dict[str, float]: """Calculate federal income tax""" if filing_status == 'married_filing_jointly': brackets = self.federal_brackets_mfj else: brackets = self.federal_brackets_single tax_owed = 0 tax_calculation_detail = [] remaining_income = taxable_income prev_threshold = 0 for threshold, rate in brackets: if remaining_income <= 0: break taxable_at_rate = min(remaining_income, threshold - prev_threshold) tax_at_rate = taxable_at_rate * rate tax_owed += tax_at_rate if taxable_at_rate > 0: tax_calculation_detail.append({ 'income_range': f"${prev_threshold:,.0f} - ${min(threshold, prev_threshold + remaining_income):,.0f}", 'rate': f"{rate * 100:.1f}%", 'taxable_income': taxable_at_rate, 'tax': tax_at_rate }) remaining_income -= taxable_at_rate prev_threshold = threshold return { 'taxable_income': taxable_income, 'total_tax': round(tax_owed, 2), 'effective_rate': round(tax_owed / taxable_income * 100, 2) if taxable_income > 0 else 0, 'marginal_rate': round(next(rate for threshold, rate in brackets if taxable_income <= threshold) * 100, 2), 'calculation_detail': tax_calculation_detail }
- src/tools/tax-tools.ts:7-37 (registration)MCP tool registration including name, description, input schema, and handler that proxies to Python TaxCalculator.calculate_federal_income_tax.{ name: "calculate_federal_income_tax", description: "Calculate federal income tax based on taxable income and filing status", inputSchema: { type: "object", properties: { taxableIncome: { type: "number" }, filingStatus: { type: "string", enum: ["single", "married_filing_jointly", "married_filing_separately", "head_of_household"], default: "single" } }, required: ["taxableIncome"] }, handler: async (args: any): Promise<ToolResult> => { try { const result = await pythonBridge.callPythonFunction({ module: 'tax_calculations', function: 'TaxCalculator.calculate_federal_income_tax', args: [args.taxableIncome, args.filingStatus || 'single'] }); return result; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } } },
- src/tools/tax-tools.ts:10-21 (schema)Input schema defining taxableIncome (required number) and optional filingStatus enum.inputSchema: { type: "object", properties: { taxableIncome: { type: "number" }, filingStatus: { type: "string", enum: ["single", "married_filing_jointly", "married_filing_separately", "head_of_household"], default: "single" } }, required: ["taxableIncome"] },
- src/python/tax_calculations.py:51-69 (helper)2024 federal income tax brackets for single and married filing jointly, used by the calculator.self.federal_brackets_single = [ (11000, 0.10), (44725, 0.12), (95375, 0.22), (182050, 0.24), (231250, 0.32), (578125, 0.35), (float('inf'), 0.37) ] self.federal_brackets_mfj = [ (22000, 0.10), (89450, 0.12), (190750, 0.22), (364200, 0.24), (462500, 0.32), (693750, 0.35), (float('inf'), 0.37) ]