A high-precision corporate finance MCP (Model Context Protocol) server built with Rust for calculations and TypeScript for the interface layer.
┌─────────────────────────────────────────────────────────┐
│ MCP Client (Claude) │
└────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ TypeScript MCP Server │
│ (@modelcontextprotocol/sdk) │
└────────────────────┬────────────────────────────────────┘
│
▼ Zod Validation
┌─────────────────────────────────────────────────────────┐
│ napi-rs Bindings │
│ (packages/bindings/) │
└────────────────────┬────────────────────────────────────┘
│
▼ JSON Serialization
┌─────────────────────────────────────────────────────────┐
│ Rust Core Calculations │
│ (crates/corp-finance-core/) │
│ Using rust_decimal │
└─────────────────────────────────────────────────────────┘
corp-finance-mcp/
├── crates/
│ └── corp-finance-core/ # Rust calculations (rust_decimal for precision)
│ ├── src/
│ │ ├── wacc.rs # WACC calculator
│ │ ├── credit_metrics.rs # Credit analysis
│ │ ├── dcf.rs # DCF model
│ │ ├── debt_capacity.rs # Debt capacity analysis
│ │ ├── covenant.rs # Covenant compliance
│ │ ├── fundamentals/ # Phase 2: Fundamentals
│ │ │ ├── three_statement_model.rs
│ │ │ ├── equity_enterprise_bridge.rs
│ │ │ ├── diluted_shares.rs
│ │ │ └── accounting_flows.rs
│ │ └── valuation/ # Phase 2: Valuation
│ │ ├── football_field.rs
│ │ └── paper_lbo.rs
│ └── Cargo.toml
├── packages/
│ ├── bindings/ # napi-rs to expose Rust to Node
│ │ ├── src/lib.rs
│ │ └── Cargo.toml
│ └── mcp-server/ # TypeScript MCP server
│ ├── src/
│ │ ├── index.ts # MCP server entry point
│ │ ├── tools.ts # Tool handlers
│ │ └── schemas.ts # Zod validation schemas
│ └── package.json
├── Cargo.toml # Workspace root
└── package.json # npm workspace root
- wacc_calculator - Calculate Weighted Average Cost of Capital
- credit_metrics - Analyze credit metrics (leverage, coverage ratios)
- dcf_model - Discounted Cash Flow valuation
- debt_capacity - Calculate debt capacity based on EBITDA multiples
- covenant_compliance - Check debt covenant compliance
- three_statement_model - Build linked Income Statement, Balance Sheet, and Cash Flow projections
- equity_enterprise_bridge - Convert between Equity Value and Enterprise Value with bridge items
- diluted_shares - Calculate fully diluted shares using treasury stock method (options, RSUs, convertibles)
- accounting_flow - Analyze transaction impact across all three financial statements ("walk me through" questions)
- football_field - Create valuation range summary across DCF, Comps, and Precedents
- paper_lbo - Quick mental math LBO analysis with IRR calculation
MCP Request → Zod Validation → napi Binding → Rust Calculation → JSON → MCP Response
rust_decimal- High-precision decimal arithmeticserde- Serialization/deserializationthiserror- Error handling
napi-rs- Rust-Node.js bindings
@modelcontextprotocol/sdk- MCP protocol implementationzod- Runtime type validation
Rust owns all math, TypeScript owns the interface.
All financial calculations are performed in Rust using rust_decimal for precision. The TypeScript layer validates inputs with Zod and exposes tools via MCP.
# Install dependencies
npm install
# Build everything (Rust → Bindings → TypeScript)
npm run build# Run tests
npm test
# Watch mode for TypeScript
npm run devThe MCP server runs on stdio and can be used with any MCP client:
node packages/mcp-server/dist/index.js{
"equity_value": "700000",
"debt_value": "300000",
"cost_of_equity": "12.5",
"cost_of_debt": "6.0",
"tax_rate": "25.0"
}Response:
{
"wacc": "10.1",
"equity_weight": "0.7",
"debt_weight": "0.3",
"after_tax_cost_of_debt": "4.5"
}- Rust 1.70+
- Node.js 18+
- npm or pnpm
# 1. Build Rust core
cargo build --release
# 2. Build napi bindings
cd packages/bindings
npm run build
cd ../..
# 3. Build TypeScript server
cd packages/mcp-server
npm run build
cd ../..Or use the workspace command:
npm run buildMIT