Skip to main content
Glama
README.md
# ๐Ÿš€ RL-MCP: Ryan's Model Context Protocol Server

[![Python](https://img.shields.io/badge/Python-3.12-blue.svg)](https://python.org)
[![FastAPI](https://img.shields.io/badge/FastAPI-0.115.12-green.svg)](https://fastapi.tiangolo.com)
[![PostgreSQL](https://img.shields.io/badge/PostgreSQL-Latest-blue.svg)](https://postgresql.org)
[![Docker](https://img.shields.io/badge/Docker-Compose-blue.svg)](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>