Black-Litterman Portfolio Optimization MCP Server
Project description
Black-Litterman Portfolio Optimization MCP Server
Black-Litterman portfolio optimization MCP server for AI agents
Works with Claude Desktop, Windsurf IDE, Google ADK, and any MCP-compatible AI
Features
- Portfolio Optimization - Calculate optimal weights using Black-Litterman model
- Investor Views - Express views like "AAPL will return 10%" or "NVDA will outperform MSFT"
- Backtesting - Validate strategies with historical data
- VaR Warnings - Auto-warn on overly optimistic predictions using EGARCH model
- Multiple Assets - S&P 500, NASDAQ 100, ETF, Crypto, and custom data support
Quick Start (Claude Desktop)
Step 1: Find uvx path
Run in terminal:
which uvx
# Example output: /Users/USERNAME/.local/bin/uvx
If uvx is not installed:
curl -LsSf https://astral.sh/uv/install.sh | sh
Step 2: Configure Claude Desktop
Config file location:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
File content (replace with your uvx path):
{
"mcpServers": {
"black-litterman": {
"command": "/Users/USERNAME/.local/bin/uvx",
"args": ["black-litterman-mcp"]
}
}
}
Step 3: Restart Claude Desktop
Cmd+Q (macOS) or fully quit and restart
Step 4: Use
Ask Claude:
"Optimize a portfolio with AAPL, MSFT, GOOGL. I think AAPL will return 10%."
First run: S&P 500 data auto-downloads (~30 seconds)
Tip: Want charts or dashboards? Just ask: "Show me a dashboard with the results" or "Create a visualization of the portfolio weights"
Example Use Cases
Try these prompts with Claude:
Basic Optimization + Visualization
"Optimize a portfolio with AAPL, MSFT, GOOGL. I think NVDA will outperform AAPL by 20%, confidence 0.8. Show me a dashboard."
Backtesting with Benchmark
"Backtest my portfolio for 3 years and compare with SPY."
Strategy Comparison
"Compare buy_and_hold, passive_rebalance, and risk_managed strategies for this portfolio."
Correlation Analysis
"Analyze the correlation between NVDA, AMD, and INTC."
Sensitivity Analysis
"Create a portfolio with AAPL and MSFT. I expect AAPL to return 15%. Run sensitivity analysis with confidence levels 0.3, 0.5, 0.7, 0.9."
Other Installation Methods
Windsurf IDE
.windsurf/mcp_config.json:
{
"mcpServers": {
"black-litterman": {
"command": "/Users/USERNAME/.local/bin/uvx",
"args": ["black-litterman-mcp"]
}
}
}
From Source (Developers)
git clone https://github.com/irresi/bl-view-mcp.git
cd bl-view-mcp
make install
make download-data # S&P 500 data
make test-simple
Docker
docker build -t bl-mcp .
docker run -p 5000:5000 -v $(pwd)/data:/app/data bl-mcp
Web UI (Testing)
# Terminal 1: MCP server
make server-http
# Terminal 2: Web UI
make web-ui
Open http://localhost:8000 in browser
Supported Datasets
| Dataset | Tickers | Description |
|---|---|---|
snp500 |
~500 | S&P 500 constituents (default) |
nasdaq100 |
~100 | NASDAQ 100 constituents |
etf |
~130 | Popular ETFs |
crypto |
~100 | Cryptocurrencies |
custom |
- | User-uploaded data |
PyPI install: S&P 500 data auto-downloads on first run
Source install: Download additional datasets manually
make download-data # S&P 500 (default)
make download-nasdaq100 # NASDAQ 100
make download-etf # ETF
make download-crypto # Crypto
MCP Tools
optimize_portfolio_bl
Calculate optimal portfolio weights using Black-Litterman model.
optimize_portfolio_bl(
tickers=["AAPL", "MSFT", "GOOGL"],
period="1Y",
views={"P": [{"AAPL": 1}], "Q": [0.10]}, # AAPL expected 10% return
confidence=0.7,
investment_style="balanced" # aggressive / balanced / conservative
)
Views examples:
# Absolute view: "AAPL will return 10%"
views = {"P": [{"AAPL": 1}], "Q": [0.10]}
# Relative view: "NVDA will outperform AAPL by 20%"
views = {"P": [{"NVDA": 1, "AAPL": -1}], "Q": [0.20]}
VaR Warning: When predicted returns exceed 40%, EGARCH-based VaR analysis is automatically included in the warnings field.
backtest_portfolio
Validate portfolio strategy with historical data.
backtest_portfolio(
tickers=["AAPL", "MSFT", "GOOGL"],
weights={"AAPL": 0.4, "MSFT": 0.35, "GOOGL": 0.25},
period="3Y",
strategy="passive_rebalance", # buy_and_hold / passive_rebalance / risk_managed
benchmark="SPY"
)
calculate_var_egarch
Calculate VaR for individual stocks using EGARCH(1,1) model.
calculate_var_egarch(
ticker="NVDA",
period="3Y",
confidence_level=0.95
)
upload_price_data
Upload external data (international stocks, custom assets, etc.).
upload_price_data(
ticker="005930.KS", # Samsung Electronics
prices=[
{"date": "2024-01-02", "close": 78000.0},
{"date": "2024-01-03", "close": 78500.0},
...
],
source="custom"
)
upload_price_data_from_file
Load price data from CSV/Parquet files.
upload_price_data_from_file(
ticker="CUSTOM_INDEX",
file_path="/path/to/data.csv",
date_column="Date",
close_column="Close"
)
list_available_tickers
Query available tickers.
list_available_tickers(search="AAPL") # Search
list_available_tickers(dataset="snp500") # S&P 500 only
list_available_tickers(dataset="custom") # Custom data
Documentation
| Document | Description |
|---|---|
| QUICKSTART.md | 5-minute start guide |
| CONTRIBUTING.md | Developer guide |
| TESTING.md | Testing guide |
| docs/WINDSURF_SETUP.md | Windsurf IDE setup |
| docs/ARCHITECTURE.md | Technical architecture |
Tech Stack
- MCP Server: FastMCP
- Optimization: PyPortfolioOpt
- Risk Model: arch (EGARCH)
- Data: yfinance, ccxt (crypto)
License
MIT License - LICENSE
Troubleshooting
"spawn uvx ENOENT" / "uv binary not found"
Claude Desktop may not recognize system PATH. Use absolute path:
which uvx
# Use the output path in config
"Data file not found"
Source install:
make download-data
PyPI install: Auto-downloads on first run (~30 seconds).
"uv: command not found"
curl -LsSf https://astral.sh/uv/install.sh | sh
Need more help?
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file black_litterman_mcp-0.3.0.tar.gz.
File metadata
- Download URL: black_litterman_mcp-0.3.0.tar.gz
- Upload date:
- Size: 1.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
289dfa0f12e5157af1da4ae46f1361be7c3b5dbf890a2a7315ad89e68bb06b68
|
|
| MD5 |
a0e90a2476964dd944ce69654ae1c4fc
|
|
| BLAKE2b-256 |
5cde682a4aa92eea681e6c05e21cc5dfcd5f7213c8d53a85b26d41779fd0557f
|
Provenance
The following attestation bundles were made for black_litterman_mcp-0.3.0.tar.gz:
Publisher:
publish.yml on irresi/bl-view-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
black_litterman_mcp-0.3.0.tar.gz -
Subject digest:
289dfa0f12e5157af1da4ae46f1361be7c3b5dbf890a2a7315ad89e68bb06b68 - Sigstore transparency entry: 720880346
- Sigstore integration time:
-
Permalink:
irresi/bl-view-mcp@bc5d27c73ca4837a52e104daad11fe6503f3a6db -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/irresi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bc5d27c73ca4837a52e104daad11fe6503f3a6db -
Trigger Event:
release
-
Statement type:
File details
Details for the file black_litterman_mcp-0.3.0-py3-none-any.whl.
File metadata
- Download URL: black_litterman_mcp-0.3.0-py3-none-any.whl
- Upload date:
- Size: 42.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3174aef837017b3eccdda9346703d47e620ba05dc7ac0d8cb0be0c34c0aa72fc
|
|
| MD5 |
f654af500e922b460a450df69249a654
|
|
| BLAKE2b-256 |
6433cb0309465d313a36814dd07444d6f7fc78c093dbb1b6ac808bb1879f9baa
|
Provenance
The following attestation bundles were made for black_litterman_mcp-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on irresi/bl-view-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
black_litterman_mcp-0.3.0-py3-none-any.whl -
Subject digest:
3174aef837017b3eccdda9346703d47e620ba05dc7ac0d8cb0be0c34c0aa72fc - Sigstore transparency entry: 720880347
- Sigstore integration time:
-
Permalink:
irresi/bl-view-mcp@bc5d27c73ca4837a52e104daad11fe6503f3a6db -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/irresi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bc5d27c73ca4837a52e104daad11fe6503f3a6db -
Trigger Event:
release
-
Statement type: