An MCP (Model Context Protocol) tool that provides stock market data and trading capabilities using the yfinance library, specifically adapted for Claude Desktop.
An MCP (Model Context Protocol) tool that provides stock market data and trading capabilities using the yfinance library, specifically adapted for Claude Desktop.
Credit: This project was inspired by mcp-stocks by Luigi Ajah, which is a similar implementation for Cursor. This adaptation modifies the original concept to work with Claude Desktop.
For a detailed guide on setting up and using this tool, check out our Medium tutorial: Tutorial: Using Claude Desktop with YFinance Trader MCP Tool to Access Real-Time Stock Market Data
Ensure you have Python 3.10 or higher installed
Install dependencies:
pip install -r requirements.txt
{
"mcpServers": {
"yfinance-trader": {
"command": "py",
"args": ["-3.13", "path/to/your/main.py"]
}
}
}
Get real-time stock quote information:
{
"symbol": "AAPL",
"price": 150.25,
"change": 2.5,
"changePercent": 1.67,
"volume": 1234567,
"timestamp": "2024-03-20T10:30:00"
}
Get company information and key metrics:
{
"name": "Apple Inc.",
"sector": "Technology",
"industry": "Consumer Electronics",
"marketCap": 2500000000000,
"peRatio": 25.4,
"forwardPE": 24.2,
"dividendYield": 0.65,
"52WeekHigh": 182.94,
"52WeekLow": 124.17
}
Get historical daily price data:
{
"symbol": "AAPL",
"timeSeriesDaily": [
{
"date": "2024-03-20T00:00:00",
"open": 150.25,
"high": 152.30,
"low": 149.80,
"close": 151.75,
"volume": 12345678
}
// ... more data points
]
}
Search for stocks and other securities:
{
"results": [
{
"symbol": "AAPL",
"name": "Apple Inc.",
"type": "EQUITY",
"exchange": "NASDAQ"
}
// ... more results
]
}
Get analyst recommendations for a stock:
{
"symbol": "AAPL",
"recommendations": [
{
"period": "2024-03-15T00:00:00",
"strongBuy": 15,
"buy": 20,
"hold": 8,
"sell": 2,
"strongSell": 0
}
// ... more periods
]
}
Get insider trading information:
{
"symbol": "AAPL",
"transactions": [
{
"date": "2024-03-15T00:00:00",
"insider": "John Doe",
"position": "Director",
"transactionType": "Buy",
"shares": 1000,
"value": 150250.00,
"url": "https://finance.yahoo.com/...",
"text": "Purchase of 1000 shares",
"startDate": "2024-03-15",
"ownership": "Direct"
}
// ... more transactions
]
}
You can ask Claude Desktop questions like:
Limited cryptocurrency data is available using special ticker formats:
All tools include proper error handling and will return an error message if something goes wrong:
{
"error": "Failed to fetch quote for INVALID_SYMBOL"
}
If the MCP server is not working in Claude Desktop:
MIT License