Mortgage MCP Server
Provides mortgage calculation tools, including monthly payment, amortization schedules, lump sum payments, and extra monthly payments for real estate agents and AI assistants.
README
Mortgage MCP Server
A Model Context Protocol (MCP) server that provides mortgage calculation tools for real estate agents and AI assistants.
Features
- Monthly Payment Calculation: Calculate fixed monthly payments for mortgages
- Amortization Schedules: Generate complete payment schedules with principal/interest breakdown
- Lump Sum Payments: Model the impact of lump sum payments on loan payoff
- Extra Monthly Payments: Calculate accelerated payoff with extra payments
- Structured Logging: Full observability with
structlog - Type Safety: 100% typed with Python 3.13+
- Clean Architecture: Domain → Services → MCP Server layers
Quick Start
Installation
# Create environment
python3.13 -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -e ".[dev]"
Running the Server
python -m mortgage_mcp_server.server
Running with Docker
The server can run in a Docker container for easier deployment and isolation.
Build the image:
# Using the build script (recommended)
chmod +x build.sh
./build.sh
# Or using docker directly
docker build -t mortgage-mcp-server:latest .
Run the container:
docker run -i mortgage-mcp-server:latest
The -i (interactive) flag is required — it keeps stdin open for MCP stdio communication with VSCode/Claude.
Using Docker Compose:
docker-compose up --build
For full Docker setup and VSCode integration details, see DOCKER.md.
Example: Calculate Monthly Payment
Using the MCP protocol, call the calculate_monthly_payment tool:
{
"principal": 350000,
"annual_interest_rate": 6.5,
"loan_term_years": 30
}
Returns:
{
"principal": "350000",
"annual_interest_rate": "6.5",
"loan_term_years": 30,
"monthly_payment": "2208.84"
}
Architecture
src/mortgage_mcp_server/
├── domain/ # Pure mortgage calculation logic
│ └── mortgage.py # Core math (monthly payment, amortization, etc.)
├── schemas/ # Pydantic models for validation
│ └── loan.py # Input/output schemas
├── services/ # Application orchestration
│ └── calculator.py # Service layer coordinating domain + I/O
├── server.py # MCP server exposing tools
└── logging.py # Centralized structlog configuration
Design Principles
- Domain Layer: Pure functions with no I/O, fully typed, comprehensive docstrings
- Services Layer: Orchestrates domain logic, validates at boundaries, uses Pydantic
- MCP Server: Exposes tools via Model Context Protocol
- Logging: Structured events via
structlogfor observability
Available Tools
calculate_monthly_payment
Calculate the fixed monthly payment for a mortgage.
Parameters:
principal(number): Loan amount in dollarsannual_interest_rate(number): Annual rate as percentage (e.g., 6.5)loan_term_years(integer): Loan term in years
Returns: Monthly payment amount
get_amortization_schedule
Get the complete amortization schedule.
Parameters:
principal(number): Loan amountannual_interest_rate(number): Annual rate as percentageloan_term_years(integer): Loan term in years
Returns: Full schedule with payment-by-payment breakdown
calculate_with_lump_sum
Model the impact of a lump sum payment at a specific month.
Parameters:
principal(number): Loan amountannual_interest_rate(number): Annual rateloan_term_years(integer): Loan termmonthly_payment(number): Regular monthly paymentlump_sum_amount(number): Lump sum amountmonth_to_apply(integer): Which month to apply the lump sum
Returns: Updated amortization schedule
calculate_with_extra_payments
Model accelerated payoff with extra monthly payments.
Parameters:
principal(number): Loan amountannual_interest_rate(number): Annual rateloan_term_years(integer): Loan termmonthly_payment(number): Base monthly paymentextra_monthly_payment(number): Extra amount per monthnum_months_with_extra(integer): How many months to apply extra
Returns: Updated amortization schedule
Testing
# Run tests
pytest tests/
# Run with coverage
pytest --cov=src/mortgage_mcp_server tests/
# View coverage report
pytest --cov=src/mortgage_mcp_server --cov-report=html tests/
VSCode Integration
To use this MCP server with Claude in VSCode, add to your settings.json:
{
"claude.mcp.servers": {
"mortgage-calculator": {
"command": ".venv/bin/python",
"args": ["-m", "mortgage_mcp_server.server"],
"cwd": "/Users/jibbs/Documents/git-projects/mortgage-mcp-server",
"env": {
"PYTHONPATH": "src"
}
}
}
}
Or with Docker:
{
"claude.mcp.servers": {
"mortgage-calculator": {
"command": "docker",
"args": ["run", "-i", "mortgage-mcp-server:latest"],
"env": {
"PYTHONUNBUFFERED": "1"
}
}
}
}
After updating settings, restart VSCode. Claude will now have access to all 4 mortgage calculation tools.
Quality Assurance
# Lint
ruff check src/ tests/
# Format
ruff format src/ tests/
# Check formatting
ruff format --check src/ tests/
# Type check (when Ty is installed)
ty check
Development
This project follows clean architecture principles and the conventions in .github/copilot-instructions.md.
Key Conventions
- Python 3.13+ with strict type checking
- Ruff for linting and formatting
- Pytest for testing
- Pydantic for input validation
- Structlog for structured logging
- Decimal for precise financial calculations
Making Changes
- Implement in appropriate layer (domain/services/server)
- Add/update types (no
Anyunless justified) - Add docstrings to public APIs
- Write tests for new functionality
- Run quality checks:
ruff check . ruff format . pytest tests/ - Verify all checks pass before committing
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。