Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@portfolio-mcpOptimize my tech_stocks portfolio for the maximum Sharpe ratio"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
portfolio-mcp
A portfolio analysis MCP server powered by mcp-refcache for building AI agent tools that handle financial data efficiently.
Features
Portfolio Management: Create, read, update, delete portfolios with persistent storage
Data Sources: Yahoo Finance (stocks/ETFs), CoinGecko (crypto), Synthetic (GBM simulation)
Analysis Tools: Returns, volatility, Sharpe ratio, Sortino ratio, VaR, drawdowns, correlations
Optimization: Efficient Frontier, Monte Carlo simulation, weight optimization
Reference-Based Caching: Large datasets cached via mcp-refcache to avoid context bloat
Installation
Using uv (recommended)
Using pip
Quick Start
Connect to Claude Desktop
Add to your Claude Desktop configuration (~/.config/claude/claude_desktop_config.json):
Basic Usage
Once connected, you can use natural language to:
Available Tools
Portfolio Management (6 tools)
create_portfolio- Create a new portfolio with symbols and weightsget_portfolio- Retrieve portfolio details and metricslist_portfolios- List all stored portfoliosdelete_portfolio- Remove a portfolioupdate_portfolio_weights- Modify portfolio weightsclone_portfolio- Create a copy with optional new weights
Analysis Tools (8 tools)
get_portfolio_metrics- Comprehensive metrics (return, volatility, Sharpe, Sortino, VaR)get_returns- Daily, log, or cumulative returnsget_correlation_matrix- Asset correlation analysisget_covariance_matrix- Variance-covariance structureget_individual_stock_metrics- Per-asset statisticsget_drawdown_analysis- Maximum drawdown and recovery analysiscompare_portfolios- Side-by-side portfolio comparison
Optimization Tools (4 tools)
optimize_portfolio- Optimize weights (max Sharpe, min volatility, target return/vol)get_efficient_frontier- Generate efficient frontier curverun_monte_carlo- Monte Carlo simulation for portfolio analysisapply_optimization- Apply optimization and update stored portfolio
Data Tools (8 tools)
generate_price_series- Generate synthetic GBM price datagenerate_portfolio_scenarios- Create multiple scenario datasetsget_sample_portfolio_data- Get sample data for testingget_trending_coins- Trending cryptocurrencies from CoinGeckosearch_crypto_coins- Search for crypto assetsget_crypto_info- Detailed cryptocurrency informationlist_crypto_symbols- Available crypto symbol mappingsget_cached_result- Retrieve cached large results by reference ID
Architecture
Reference-Based Caching
This server uses mcp-refcache to handle large results efficiently:
Large results are cached - When a tool returns data that exceeds the preview size, it's stored in the cache
References are returned - The tool returns a
ref_idand a preview/sample of the dataFull data on demand - Use
get_cached_result(ref_id=...)to retrieve the complete data
This prevents context window bloat when working with large datasets like price histories or Monte Carlo simulations.
Development
Prerequisites
Python 3.12+
uv (recommended) or pip
Setup
Running Locally
Configuration
Environment variables:
Variable | Description | Default |
| Logging level |
|
| Default cache TTL in seconds |
|
License
MIT License - see LICENSE for details.
Related Projects
mcp-refcache - Reference-based caching for MCP servers
fastmcp-template - Template this project was built from
FinQuant - Financial portfolio analysis library