Enterprise Big Data Copilot
Enables natural-language queries on Trino big data platforms, generating validated, schema-aware SQL via RAG and local LLM inference, and exposes metadata, query, and profiling tools through MCP.
README
Enterprise Big Data Copilot
An AI copilot that turns natural-language questions into validated, schema-aware Trino SQL, using RAG, MCP tools, and local LLM inference.
Overview
Enterprise Big Data Copilot lets users query Big Data platforms in plain English. A LangGraph pipeline retrieves relevant documentation (RAG) and live schema metadata (MCP), generates SQL with a local LLM (Ollama), validates it against safety and schema rules, and — when the platform is reachable — executes it on Trino and returns real rows.
Features
- Natural-language Text-to-SQL generation for Trino
- Local LLM inference with Ollama (no cloud API required)
- RAG retrieval over Trino / Hive / Iceberg documentation (Qdrant)
- Schema-aware generation grounded in live catalog metadata
- SQL validation (read-only SELECT enforcement, parse check, schema grounding) with an automatic regeneration loop
- Best-effort query execution and result retrieval from Trino
- Model Context Protocol (MCP) server exposing metadata, query, and profiling tools
- OpenAI-compatible API for Open WebUI
- End-to-end pipeline tracing with LangSmith
Architecture
flowchart LR
User --> API
API --> Agent
Agent --> RAG
RAG --> Qdrant
Agent --> LLM
Agent --> MCP
MCP --> Trino
Agent --> Validation
Agent --> Response
Response --> User
Tech Stack
| Technology | Purpose |
|---|---|
| Python + FastAPI | Backend and REST/OpenAI-compatible API |
| LangGraph | Pipeline orchestration (RAG → schema → SQL → validate → execute) |
| Ollama | Local LLM (llama3.2) and embeddings (mxbai-embed-large) |
| LangChain + Qdrant | RAG document retrieval |
| FastMCP | Model Context Protocol server (tools) |
| LangSmith | Pipeline tracing and monitoring |
| Trino | SQL query engine (TPCH demo catalog) |
| Open WebUI | Chat UI (optional) |
| Docker | Containerized infrastructure |
Project Structure
app/
├── agent/ # SQL agent + prompts (Ollama)
├── api/ # REST + OpenAI-compatible endpoints
├── core/ # Config, models, exceptions, logging
├── formatter/ # Response formatting
├── mcp/ # MCP server, client, catalog services
├── orchestrator/ # LangGraph pipeline
├── rag/ # Ingestion and retrieval (Qdrant)
├── services/ # Trino client
└── validator/ # SQL validation
tests/ # pytest suite
docker/ # App image + Trino config
docs/ # RAG knowledge base
scripts/ # Document ingestion CLI
Getting Started
Prerequisites
- Python 3.11 or 3.12 (3.13 is not supported)
- Docker + Docker Compose
- GPU optional (Ollama can run on CPU)
Installation
git clone https://github.com/hani-ben-dhaou/Enterprise-Big-Data-Copilot.git
cd entreprise-bigdata-copilot
python -m venv .venv
# Windows: .venv\Scripts\activate | macOS/Linux: source .venv/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt # pytest
Configuration
cp .env.example .env
Key variables (defaults work for local dev):
| Variable | Description |
|---|---|
OLLAMA_BASE_URL / OLLAMA_MODEL |
LLM server and model (llama3.2) |
OLLAMA_EMBED_MODEL |
Embedding model (mxbai-embed-large) |
QDRANT_HOST / QDRANT_PORT |
Qdrant vector database |
TRINO_HOST / TRINO_PORT / TRINO_CATALOG / TRINO_SCHEMA |
Trino (default catalog tpch, schema tiny) |
MCP_TRANSPORT |
inprocess (default, recommended on Windows) or sse |
MCP_METADATA_SOURCE |
inmemory (demo catalog) or trino (live metadata) |
ENABLE_SQL_EXECUTION |
Run validated SQL on Trino |
LANGCHAIN_TRACING_V2 |
Set true to enable LangSmith tracing |
LANGCHAIN_API_KEY |
Your LangSmith API key (tracing stays off if empty) |
LANGCHAIN_PROJECT |
LangSmith project name (default copilot) |
Run
# 1. Start infrastructure (Ollama, Qdrant, Trino)
docker compose up -d
# 2. Pull models and ingest documentation (Qdrant must be up)
docker exec -it copilot-ollama ollama pull llama3.2
docker exec -it copilot-ollama ollama pull mxbai-embed-large
python scripts/ingest_docs.py
# 3. Start the API
uvicorn app.main:app --reload --port 8000
# 4. Optional: standalone MCP server (SSE on :8001)
python -m app.mcp.server
Usage
Ask a question in natural language:
curl -X POST http://localhost:8000/api/v1/query \
-H "Content-Type: application/json" \
-d '{"question":"Show me the top 10 customers by total revenue last month"}'
The response includes the generated SQL, an explanation, a confidence score, warnings, and — when execution is enabled — the result rows:
{
"question": "Show me the top 10 customers by total revenue last month",
"sql": "SELECT ...",
"explanation": "...",
"confidence": 0.92,
"warnings": [],
"dialect": "trino",
"results": [["42", "Acme", 98765.00]],
"execution": {"status": "ok", "columns": ["id", "name", "revenue"], "row_count": 1, "truncated": false}
}
Other endpoints: GET /api/v1/schema (list catalog), GET /api/v1/health, and POST /v1/chat/completions (OpenAI-compatible, used by Open WebUI).
Testing
pytest
The suite is hermetic and runs without a live stack (146 tests).
Tracing & Monitoring
Every pipeline query (RAG retrieval, schema lookup, SQL generation, validation
loops, execution) can be traced with LangSmith.
Create a free account, grab an API key, and set:
LANGCHAIN_TRACING_V2=true, LANGCHAIN_API_KEY=<your key>, and optionally
LANGCHAIN_PROJECT=copilot. Tracing stays off while no key is configured.

Docker
docker compose runs the full stack:
| Service | Container | Port |
|---|---|---|
| Ollama | copilot-ollama |
11434 |
| Qdrant | copilot-qdrant |
6333 |
| Trino | copilot-trino |
8080 |
| Open WebUI | copilot-webui |
3000 |
| Copilot API | copilot-api |
8000 |
| MCP Server | copilot-mcp |
8001 |
Named volumes persist Ollama models, Qdrant data, and Open WebUI data. The ollama volume is declared external — create it once if not present:
docker volume create ollama
docker compose up -d
docker compose ps
docker compose logs -f copilot-api
docker compose down
Windows note: MCP over real SSE can be flaky on the Windows event loop. Keep
MCP_TRANSPORT=inprocessfor local development on Windows; use SSE on Linux/Docker.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。