Stock Data MCP Server
Production-ready aggregated MCP server for stock market data combining Finnhub (fundamentals), Yahoo Finance (quotes/history), Tushare (China A-shares), and Futu OpenAPI (HK/US/CN Real-time).
Perfect for building value investing agents, financial analysis tools, and portfolio management systems.
π― Features
π 9 Powerful Tools
search_symbol - Search stocks across all markets
resolve_symbol - normalize symbols between Yahoo (0700.HK) and Futu (HK.00700) formats
get_quote - Real-time quotes (Futu Snapshot / Yahoo Delay)
get_history - Historical OHLCV data (Futu K-line / Yahoo History)
get_fundamentals - ROE, margins, ratios, valuations
get_financial_statements - Income/Balance/Cashflow statements
subscribe_quote - Subscribe to real-time pushes (Futu)
get_order_book - Real-time market depth (Futu)
get_ticker - Real-time trade ticks (Futu)
Intelligent Data Routing
Market | Primary | Fallback |
ππ° ζΈ―θ‘ | Futu OpenAPI | Yahoo Finance |
π¨π³ Aθ‘ | Tushare Pro | Yahoo Finance |
πΊπΈ ηΎθ‘ | Yahoo Finance | - |
Fundamentals/Financials:
China (A-shares): Tushare Pro.
Global: Finnhub.
Smart Caching: 5s for quotes, 1h for fundamentals, 24h for statements.
Multi-Market Support
Market | Symbol Format (Yahoo) | Futu Format | Examples |
πΊπΈ US Stocks |
|
| AAPL, MSFT |
ππ° Hong Kong |
|
| 0700.HK (HK.00700) |
π¨π³ Shanghai |
|
| 600519.SS (SH.600519) |
π¨π³ Shenzhen |
|
| 000001.SZ (SZ.000001) |
π¦ Installation
Prerequisites
Python 3.10+
Finnhub API Key (Free tier ok) - Register
Tushare Token (Optional, for A-share fundamentals) - Register
FutuOpenD (Optional, for Real-time HK/US/CN data)
Download and install FutuOpenD.
Login with your Futu account.
Keep it running (default port 11111).
Quick Start
Environment Variables
Create a .env file:
π Usage
Running the Server
Claude Desktop Integration
macOS Configuration:
Edit: ~/Library/Application Support/Claude/claude_desktop_config.json
π API Reference Examples
Real-time Quotes (Futu/Yahoo)
Order Book (Futu Only)
Historical Data
π§ Error Handling
Errors return structured JSON with specific codes:
PROVIDER_CONNECT_FAILED: FutuOpenD not reachable.HISTORY_NOT_AVAILABLE: Permission denied or no data.SUBSCRIPTION_LIMIT: Futu subscription quota exceeded.
π€ Contributing
To add a new provider:
Create
providers/new_provider.pyImplement provider interface
Add routing logic in
server.pyUpdate tests and README
π License
MIT
Production-ready aggregated MCP server for stock market data combining Finnhub (fundamentals) and Yahoo Finance (quotes/history).
Perfect for building value investing agents, financial analysis tools, and portfolio management systems.
π― Features
5 Powerful Tools
search_symbol - Search stocks across all markets
get_quote - Real-time quotes with 5s caching
get_history - Historical OHLCV data
get_fundamentals - ROE, margins, ratios, valuations
get_financial_statements - Income/Balance/Cashflow statements
Intelligent Data Routing
Quotes/History: Yahoo Finance (free, fast, no limits)
Fundamentals/Financials: Finnhub (professional-grade data)
Automatic Fallback: If primary source fails, tries backup
Smart Caching: 5s for quotes, 1h for fundamentals, 24h for statements
Multi-Market Support
Market | Symbol Format | Examples |
πΊπΈ US Stocks |
| AAPL, MSFT, GOOGL |
ππ° Hong Kong |
| 0700.HK (Tencent), 9988.HK (Alibaba) |
π¨π³ Shanghai |
| 600519.SS (Moutai), 600036.SS (CMB) |
π¨π³ Shenzhen |
| 000001.SZ (Pingan), 300750.SZ (CATL) |
π¦ Installation
Prerequisites
Python 3.10+
Finnhub API Key (free tier is fine)
Get yours at: https://finnhub.io/register
Free tier: 60 API calls/minute
Quick Start
Environment Variables
Create a .env file:
π Usage
Running the Server
Testing Locally
Claude Desktop Integration
macOS Configuration:
Edit: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows Configuration:
Edit: %APPDATA%\Claude\claude_desktop_config.json
After configuration:
Completely quit Claude Desktop
Restart Claude Desktop
The tools will appear in your conversations
π API Reference
1. search_symbol
Search for stock symbols across markets.
Input:
Output:
Data Source: Finnhub β Yahoo (fallback)
2. get_quote
Get real-time market data.
Input:
Output:
Data Source: Yahoo (default) β Finnhub (fallback) Cache: 5 seconds
3. get_history
Get historical OHLCV data.
Input:
Intervals: 1d (daily), 1wk (weekly), 1mo (monthly)
Output:
Data Source: Yahoo Finance Cache: 5 minutes
4. get_fundamentals
Get fundamental metrics (ROE, margins, ratios).
Input:
Output:
Data Source: Finnhub (requires API key) Cache: 1 hour
5. get_financial_statements
Get income statement, balance sheet, or cashflow.
Input:
Statement Types: income, balance, cashflow
Periods: annual, quarterly
Output:
Data Source: Finnhub (requires API key) Cache: 24 hours
ποΈ Architecture
Data Flow
π§ Error Handling
All errors return structured JSON:
Error Codes:
PROVIDER_TIMEOUT- Request timed outSYMBOL_NOT_FOUND- Invalid or unknown symbolINVALID_ARGUMENT- Bad input parametersPROVIDER_RATE_LIMIT- API rate limit hitPROVIDER_ERROR- Provider-specific errorMISSING_API_KEY- Finnhub key not configuredNO_DATA- No data available for request
π‘ Usage Examples with Claude
Once integrated, you can ask Claude:
π― Use Cases
Value Investing Analysis
Screen stocks by ROE, margins, debt ratios
Compare fundamentals across markets
Track historical performance metrics
Portfolio Management
Monitor real-time quotes for watchlist
Analyze sector allocations
Track dividend yields
Financial Research
Pull complete financial statements
Calculate custom metrics
Build valuation models
βοΈ Configuration
Cache TTL Settings
Adjust in .env:
Rate Limits
Finnhub Free Tier:
60 API calls/minute
30 calls/second
Best Practices:
Enable caching (default)
Batch similar requests
Use Yahoo for high-frequency quote checks
π Troubleshooting
"MISSING_API_KEY" error
Server not appearing in Claude Desktop
Check JSON syntax in config file
Use absolute paths (not
~or relative paths)Verify Python path with
which pythonin your venvCheck logs:
# macOS tail -f ~/Library/Logs/Claude/mcp*.log # Windows Get-Content $env:APPDATA\Claude\logs\mcp*.log -Wait
Symbol not found
Verify symbol format (e.g.,
0700.HKnot700.HK)Try searching first:
search_symbol("tencent")Check if market is supported
Rate limit exceeded
Increase cache TTL
Reduce request frequency
Consider Finnhub paid tier for higher limits
π Performance
Typical Response Times:
Quote (cached): <10ms
Quote (fresh): 200-500ms
History (1 year): 500-1000ms
Fundamentals (cached): <10ms
Fundamentals (fresh): 1-2s
Statements: 1-3s
Cache Hit Rates:
Quotes: ~80% (5s TTL)
Fundamentals: ~95% (1h TTL)
Statements: ~99% (24h TTL)
π Roadmap
v0.2 (Planned)
Symbol mapping table (watchlist.csv)
Company profile tool
News & sentiment data
Insider trading data
v0.3 (Future)
Alternative data sources (Alpha Vantage, IEX)
Crypto support
Options data
Technical indicators
π€ Contributing
This is a production-ready MVP. Extensions welcome!
To add a new provider:
Create
providers/new_provider.pyImplement provider interface
Add routing logic in
server.pyUpdate tests and README
π License
MIT
π Acknowledgments
Finnhub - Professional-grade financial data API
Yahoo Finance (yfinance) - Free historical data
MCP - Model Context Protocol by Anthropic
Built for value investors who code. ππ