An AI agent that analyzes stocks and sectors using the Seeking Alpha API via MCP (Model Context Protocol).
🚀 Quick Start Guide - Get started in 5 minutes!
Language: Python 3.8+ | Protocol: MCP | APIs: Seeking Alpha, OpenAI, Anthropic
- 🔍 Query real-time stock information from Seeking Alpha
- 🤖 AI-powered analysis and summaries (OpenAI or Anthropic)
- 💬 Interactive chat mode for dynamic stock research
- 📊 Comprehensive data gathering from multiple Seeking Alpha endpoints
- 🚀 Built with Python for ease of use and extensibility
- 🎨 Beautiful terminal output with Rich library
- Python 3.8+ - Install from python.org
- pip - Comes with Python
- npx - Required for MCP server (comes with Node.js)
- API Keys (optional, for AI summaries):
- OpenAI API key OR
- Anthropic API key
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate # On macOS/Linux
# OR
venv\Scripts\activate # On Windows
# Install dependencies
pip install -r requirements.txt
# Test MCP connection
python test_mcp.py
# Analyze a stock
python main.py --symbol AAPLImportant: Use a virtual environment to avoid conflicts with system packages.
# Create virtual environment
python3 -m venv venv
# Activate it
source venv/bin/activate # macOS/Linux
# OR
venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txtThis installs:
mcp- Model Context Protocol SDKopenai- OpenAI API clientanthropic- Anthropic API clientpython-dotenv- Environment variable managementrich- Beautiful terminal formatting
Add this to your Cursor settings (~/.cursor/settings.json or Library/Application Support/Cursor/User/settings.json):
{
"mcpServers": {
"RapidAPI Hub - Seeking Alpha API": {
"command": "npx",
"args": [
"mcp-remote",
"https://mcp.rapidapi.com",
"--header",
"x-api-host: seeking-alpha-api.p.rapidapi.com",
"--header",
"x-api-key: 882d16763emsh6e0d8ed5eb83338p14d810jsna53fd0525bf8"
]
}
}
}For AI-powered summaries, edit the .env file:
# Uncomment and add your API key
OPENAI_API_KEY=sk-your-key-here
# OR use Anthropic
# ANTHROPIC_API_KEY=sk-ant-your-key-herenpm start -- --symbol AAPLnpm start -- --symbol TSLA --query "What are the latest earnings?"npm start -- --interactiveIn interactive mode:
- Type a stock symbol (e.g.,
AAPL,TSLA) to load its data - Ask questions about the current stock
- Type
exitto quit
Usage: python main.py [-h] [-s SYMBOL] [-q QUERY] [-i]
Options:
-h, --help Show help message and exit
-s, --symbol SYMBOL Stock ticker symbol (e.g., AAPL, TSLA)
-q, --query QUERY Specific question about the stock
-i, --interactive Start interactive chat mode
- MCP Integration: The agent connects to the Seeking Alpha API through the MCP server configured in Cursor
- Data Gathering: Automatically discovers and calls available Seeking Alpha API endpoints for the requested stock
- AI Analysis: Uses OpenAI or Anthropic to generate insightful summaries and answer questions
- Fallback Mode: Works without API keys by displaying raw data in structured format
Denoise/
├── src/
│ ├── main.ts # CLI entry point
│ ├── agent.ts # Stock analysis agent
│ └── mcp-client.ts # MCP protocol client
├── package.json # Node.js configuration
├── tsconfig.json # TypeScript configuration
├── .env.example # Environment variables template
└── README.md
$ python main.py --symbol AAPL
🔌 Connecting to Seeking Alpha API...
✓ Connected! Available tools: 5
📊 Analyzing AAPL...
📋 Analysis:
Apple Inc. (AAPL) is currently trading with strong fundamentals...
[AI-generated summary with key metrics and insights]$ python main.py --symbol NVDA --query "What is the P/E ratio?"
🔌 Connecting to Seeking Alpha API...
✓ Connected! Available tools: 5
📊 Analyzing NVDA...
🤔 Question: What is the P/E ratio?
📋 Analysis:
NVIDIA's current P/E ratio is approximately 95.3...
[Detailed analysis with context]$ python main.py --interactive
💬 Interactive Stock Analysis Mode
Type a stock symbol or ask questions. Type 'exit' to quit.
You: TSLA
📊 Loading data for TSLA...
Agent: Tesla Inc. (TSLA) is an electric vehicle manufacturer...
[Summary with key information]
You: What about their revenue growth?
Agent: Tesla's revenue has grown significantly...
[Detailed response based on fetched data]
You: exit
👋 Goodbye!Before running the agent, you can test the MCP connection:
python test_mcp.pyThis will list all available Seeking Alpha API tools and verify connectivity.
If you see connection errors:
- Run
python test_mcp.pyto diagnose - Check that npx is available:
which npx - Verify internet connection
- Test the MCP server manually:
npx mcp-remote https://mcp.rapidapi.com \ --header "x-api-host: seeking-alpha-api.p.rapidapi.com" \ --header "x-api-key: YOUR_KEY"
- Requires Python 3.8 or later
- Check version:
python --versionorpython3 --version - Use
python3ifpythonpoints to Python 2.x
- Verify your API key is in the
.envfile - Check the key format (should start with
sk-for OpenAI) - The agent works without API keys but provides less detailed analysis
- Run
pip install -r requirements.txt - Make sure you're in the project directory
- Try
pip3ifpipdoesn't work
- Verify the stock symbol is correct (NYSE/NASDAQ tickers)
- Some endpoints may require different parameter formats
- Check the Seeking Alpha API status
Run with verbose output:
python -u main.py --symbol AAPLFormat code (if using black):
pip install black
black *.pyApache License 2.0 - See LICENSE file for details
Contributions welcome! Please feel free to submit a Pull Request.
- Add sector analysis capabilities
- Support for comparing multiple stocks
- Historical data analysis and trends
- Export reports to PDF/JSON
- Real-time price alerts
- Portfolio tracking