README.mdโข9.73 kB
# ๐ RL-MCP: Ryan's Model Context Protocol Server
[](https://python.org)
[](https://fastapi.tiangolo.com)
[](https://postgresql.org)
[](https://docker.com)
> ๐ฏ **A powerful, scalable Model Context Protocol (MCP) server built with modern Python technologies**
## ๐ What is RL-MCP?
RL-MCP is a robust **Model Context Protocol server** designed to provide AI models with structured access to external data and services. Think of it as a bridge ๐ that allows AI assistants to interact with your applications, databases, and APIs in a standardized, secure way.
### ๐ช Current Features
- ๐ **Secure Authentication** - Built-in auth system to protect your endpoints
- ๐ **RESTful API** - Clean, well-documented API endpoints with FastAPI
- ๐๏ธ **PostgreSQL Integration** - Robust database layer with SQLModel/SQLAlchemy
- ๐ณ **Docker Ready** - Fully containerized development and deployment
- ๐ **Database Migrations** - Alembic-powered schema management
- ๐ **Health Monitoring** - Built-in health checks and connection monitoring
- ๐จ **Interactive Docs** - Auto-generated API documentation
- ๐ ๏ธ **Development Tools** - Pre-commit hooks, linting, and formatting
## ๐ Stock Market Intelligence
> ๐ **Transform your applications with AI-powered financial intelligence**
RL-MCP includes a comprehensive **Stock Market Intelligence API** that combines cutting-edge AI with real-time financial data:
### ๐ง **AI-Powered Capabilities**
- **๐ Vector Search**: Semantic search across news, analysis, and market data using advanced NLP
- **๐ Sentiment Analysis**: Real-time sentiment scoring for news and market content
- **๐ค Smart Analysis**: AI-driven stock analysis with confidence scoring and recommendations
- **๐ฏ Relevance Scoring**: Intelligent content ranking and filtering
### ๐น **Real-Time Market Data**
- **๐ Live Pricing**: Current stock prices with change indicators and market metrics
- **๐ฐ News Intelligence**: Latest financial news with sentiment analysis from multiple sources
- **๐ Market Overview**: Comprehensive market summaries with top movers and trends
- **๐ฅ Trending Analysis**: Most active and discussed stocks based on data volume
### โก **High-Performance Architecture**
- **๐ Intelligent Caching**: Multi-layer caching for lightning-fast responses
- **๐ Background Processing**: Async data ingestion and processing
- **๐ Performance Monitoring**: Built-in health checks and cache statistics
- **๐ก๏ธ Enterprise-Ready**: Secure, scalable, and production-ready
### ๐ฏ **Use Cases**
- **๐ค AI Trading Assistants** - Portfolio analysis and trading signals
- **๐ Financial Research** - Market research and competitive intelligence
- **๐ฑ Investment Apps** - Smart notifications and educational content
- **๐ข Enterprise Systems** - Risk management and client reporting
### ๐ **Comprehensive Documentation**
Explore our detailed stock market API documentation:
- **๐ [Stock API Overview](docs/stock/README.md)** - Complete guide to stock market features
- **๐ [Vector Search Guide](docs/stock/vector-search.md)** - Advanced semantic search capabilities
- **๐ก [Use Cases & Examples](docs/stock/use-cases.md)** - Real-world applications and code samples
- **๐ [API Reference](docs/stock/api-reference.md)** - Complete endpoint documentation
### ๐ Future Vision
This MCP server is designed to be the **foundation** for AI-powered applications that need:
- ๐ค **AI Model Integration** - Seamless connection between AI models and your data
- ๐ **Plugin Architecture** - Extensible system for adding new capabilities
- ๐ก **Real-time Communication** - WebSocket support for live data streaming
- ๐ **Multi-tenant Support** - Serve multiple clients with isolated data
- ๐ **Advanced Search** - Vector search and semantic querying capabilities
- ๐ **Analytics Dashboard** - Monitor usage, performance, and insights
## ๐ ๏ธ Technology Stack
- **๐ Backend**: Python 3.12 + FastAPI
- **๐๏ธ Database**: PostgreSQL with SQLModel
- **๐ณ Containerization**: Docker + Docker Compose
- **๐ Migrations**: Alembic
- **๐งช Code Quality**: Black, isort, pylint, pre-commit hooks
- **๐ Documentation**: Auto-generated OpenAPI/Swagger docs
- **๐ง AI/ML**: Sentence Transformers, Vector Search, Sentiment Analysis
## ๐ Quick Start
### Prerequisites
- ๐ณ Docker and Docker Compose
- ๐ Python 3.12+ (for local development)
- ๐บ Homebrew (macOS) or equivalent package manager
### ๐ฏ One-Command Setup
Get up and running in seconds! Our setup script handles everything:
```bash
make setup-environment
```
This magical command will:
- ๐ง Install all required dependencies
- ๐ Create and configure a Python virtual environment
- ๐ณ Set up Docker containers
- ๐ฆ Install all Python packages
- โ
Verify everything is working
### ๐โโ๏ธ Running the Application
#### ๐ณ Docker Development (Recommended)
```bash
# Build and start all services
make up
# Or run in background
docker compose up -d
```
Your services will be available at:
- ๐ **API Server**: http://localhost:8000
- ๐ **API Docs**: http://localhost:8000/docs
- ๐ **Stock API**: http://localhost:8000/v1/stock
- ๐๏ธ **Database Admin**: http://localhost:8080 (Adminer)
#### ๐ Local Development
```bash
# Activate virtual environment
source venv/bin/activate
# Start the api and db at port 8000
make up
```
## ๐ API Documentation
Once running, explore the interactive API documentation:
- **๐ Swagger UI**: http://localhost:8000/docs
- **๐ ReDoc**: http://localhost:8000/redoc
- **๐ OpenAPI Spec**: http://localhost:8000/openapi.json
### ๐ Authentication
All API endpoints require authentication. Include your auth token in requests:
```bash
curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:8000/v1/item
```
### ๐ Stock API Quick Example
```bash
# Search for Tesla battery technology insights
curl -X POST "http://localhost:8000/v1/stock/search" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"query": "Tesla battery technology innovations",
"symbols": ["TSLA"],
"similarity_threshold": 0.8,
"limit": 10
}'
# Get current Apple stock price
curl -H "Authorization: Bearer YOUR_TOKEN" \
"http://localhost:8000/v1/stock/price/AAPL"
# Get market summary
curl -H "Authorization: Bearer YOUR_TOKEN" \
"http://localhost:8000/v1/stock/market/summary"
```
## ๐๏ธ Database Management
### ๐ Creating Migrations
When you modify database models:
```bash
MSG="Add new awesome feature" make migration
```
### ๐๏ธ Database Commands
```bash
# Start the api and db at port 8000
make up
# Check database health
curl http://localhost:8000/health
```
## ๐ ๏ธ Development Workflow
### ๐ฆ Managing Dependencies
```bash
# Regenerate requirements.txt with latest versions
make regen-requirements
```
### ๐งน Cleanup
```bash
# Remove all containers and volumes
make clean
```
### ๐ Code Quality
Pre-commit hooks automatically run:
- ๐จ **Black** - Code formatting
- ๐ **isort** - Import sorting
- ๐ **Pylint** - Code linting
## ๐๏ธ Project Structure
```
rl-mcp/
โโโ ๐ app/ # Main application code
โ โโโ ๐ api/ # API layer
โ โ โโโ ๐ v1/ # API version 1
โ โ โโโ ๐ base/ # Base models and tables
โ โ โโโ ๐ item/ # Item management endpoints
โ โ โโโ ๐ stock/ # ๐ Stock market intelligence
โ โ โโโ ๐ services/ # AI services (vector search, market data)
โ โ โโโ ๐ routes_stock.py # Stock API endpoints
โ โ โโโ ๐ models_stock.py # Data models
โ โ โโโ ๐ controllers_stock.py # Business logic
โ โโโ ๐ databases/ # Database configuration
โ โโโ ๐ main.py # Application entry point
โโโ ๐ docs/ # ๐ Comprehensive documentation
โ โโโ ๐ stock/ # Stock API documentation
โโโ ๐ docker/ # Docker configurations
โโโ ๐ migrations/ # Database migrations
โโโ ๐ scripts/ # Utility scripts
โโโ ๐ utilities/ # Helper utilities
โโโ ๐ Makefile # Development commands
```
## ๐ค Contributing
We welcome contributions! ๐
1. ๐ด Fork the repository
2. ๐ฟ Create a feature branch
3. โจ Make your changes
4. ๐งช Run tests and linting
5. ๐ Submit a pull request
## ๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
## ๐ Support
Having issues? ๐ค
- ๐ Check the [API Documentation](http://localhost:8000/docs)
- ๐ Explore [Stock API Documentation](docs/stock/README.md)
- ๐ Open an [Issue](https://github.com/rlefko/rl-mcp/issues)
- ๐ฌ Start a [Discussion](https://github.com/rlefko/rl-mcp/discussions)
---
<div align="center">
**๐ Built with โค๏ธ for the future of AI-powered applications**
*Ready to revolutionize how AI models interact with your data? Let's build something amazing together!* โจ
**๐ Featuring comprehensive stock market intelligence with AI-powered semantic search, real-time data, and intelligent caching** ๐ค๐น
</div>