Skip to main content
Glama
UAEpro

Smart MCP Server

by UAEpro
README.md
# Smart MCP Server šŸš€

**Intelligent SQL Database Interface with Natural Language Support**

A production-ready [FastMCP 2](https://github.com/jlowin/fastmcp) server that connects to **any SQL database** (MySQL, PostgreSQL, SQLite, SQL Server, Oracle, etc.) and converts natural language questions into SQL queries using AI.

---

## ✨ Features

- šŸ”Œ **Universal Database Support**: MySQL, PostgreSQL, SQLite, SQL Server, Oracle, MariaDB
- 🧠 **Natural Language to SQL**: Ask questions in plain English, get SQL results
- šŸ” **Auto-Schema Detection**: Automatically scans and understands your database structure
- šŸ›”ļø **Safety First**: Read-only by default, blocks dangerous operations
- ⚔ **FastMCP 2 Powered**: Modern, efficient MCP server implementation
- šŸŽÆ **Zero Configuration**: Works with any schema without prior setup
- šŸ”§ **Extensible**: Clean, documented code for easy customization

---

## šŸ“š Documentation

**All documentation is organized in the [docs/](docs/) folder with priority numbers for easy reading order.**

### Quick Links:
- **[docs/00_READ_ME_FIRST.md](docs/00_READ_ME_FIRST.md)** - šŸ“– **Start here!**
- **[docs/01_QUICKSTART.md](docs/01_QUICKSTART.md)** - šŸš€ Get running in 5 minutes
- **[docs/02_DATABASE_DOCUMENTATION_GUIDE.md](docs/02_DATABASE_DOCUMENTATION_GUIDE.md)** - Document your DB for better queries
- **[docs/03_PRODUCTION_SECURITY.md](docs/03_PRODUCTION_SECURITY.md)** - šŸ”’ **Security guide (CRITICAL)**

**→ See [docs/00_READ_ME_FIRST.md](docs/00_READ_ME_FIRST.md) for complete reading order**

---

## šŸš€ Quick Start

### 1. Crate Environment
```bash
python3 -m venv .venv
```
#### On Linux/Mac:
```bash
source .venv/bin/activate
```
##### On Windows:

```bash
.venv\Scripts\activate
```


### 2. Install Dependencies
```bash
pip install -r requirements.txt
```

### 3. Edit config.yaml with LLM connector and Database Connector
you can also setup the key from .env file

### 4. Run the automatic database Schema generator
```bash
python generate_schema.py
```

### 5. Run the Server
```bash
python main.py
```

you might need to edit the main.py in the main function to change the MCP starting protocol


---

## šŸŽÆ Example Queries

Try these natural language questions:

```
"Show me all customers"
"What are the top 5 most expensive products?"
"Show me orders with customer names"
"What is the total revenue by category?"
"List customers who placed orders in the last 30 days"
```

---

## šŸ› ļø Tech Stack

- **FastMCP 2** - MCP server framework
- **SQLAlchemy 2.x** - Universal database adapter
- **OpenAI API** - Natural language processing
- **Python 3.8+** - Core language

---

## šŸ“¦ Project Structure

```
SmartMCP/
ā”œā”€ā”€ main.py                  # Server entry point
ā”œā”€ā”€ config.yaml              # Configuration
ā”œā”€ā”€ requirements.txt         # Dependencies
ā”œā”€ā”€ example_database.py      # Sample data generator
ā”œā”€ā”€ test_setup.py           # Setup verification
ā”œā”€ā”€ db/adapter.py           # Database connector
ā”œā”€ā”€ nlp/query_parser.py     # NL to SQL parser
ā”œā”€ā”€ mcp/tools.py            # MCP tool definitions
└── utils/schema.py         # Schema utilities
```

---

## šŸŽ“ Learn More

- **[QUICKSTART.md](QUICKSTART.md)** - Step-by-step setup guide
- **[ARCHITECTURE.md](ARCHITECTURE.md)** - System design deep dive
- **[PROJECT_SUMMARY.md](PROJECT_SUMMARY.md)** - Complete feature list
- **[README.md](README.md)** - Full documentation with examples

---

## šŸ”’ Safety Features

- āœ… Read-only by default
- āœ… Keyword blacklist (DROP, DELETE, etc.)
- āœ… SQL injection prevention
- āœ… Row limits (max 1000 per query)
- āœ… Environment variable for secrets

---

## šŸ“ License

MIT License - Free to use, modify, and distribute!

---

**Built with ā¤ļø and AI :P for the MCP community**