Enterprise Big Data Copilot

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.

Category
Visit Server

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.

LangSmith trace of a copilot pipeline run

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=inprocess for local development on Windows; use SSE on Linux/Docker.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured