# π 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>