Enterprise Big Data Copilot
Enterprise Big Data Copilot
自然言語の質問を、検証済みでスキーマ対応のTrino SQLに変換するAIコパイロット。RAG、MCPツール、ローカルLLM推論を使用します。
概要
Enterprise Big Data Copilotを使用すると、ユーザーは平易な英語でBig Dataプラットフォームにクエリを実行できます。LangGraphパイプラインが関連ドキュメント(RAG)とライブスキーマメタデータ(MCP)を取得し、ローカルLLM(Ollama)でSQLを生成し、安全性とスキーマのルールに照らして検証し、プラットフォームに到達可能な場合はTrinoで実行して実際の行を返します。
Related MCP server: Doris MCP Server
機能
Trino向けの自然言語Text-to-SQL生成
OllamaによるローカルLLM推論(クラウドAPI不要)
Trino / Hive / Icebergドキュメントに対するRAG検索(Qdrant)
ライブカタログメタデータに基づくスキーマ対応生成
SQL検証(読み取り専用SELECTの強制、構文チェック、スキーマ接地)と自動再生成ループ
Trinoからのベストエフォート型クエリ実行と結果取得
メタデータ、クエリ、プロファイリングツールを公開するModel Context Protocol(MCP)サーバー
Open WebUI向けOpenAI互換API
LangSmithによるエンドツーエンドのパイプライントレース
アーキテクチャ
flowchart LR
User --> API
API --> Agent
Agent --> RAG
RAG --> Qdrant
Agent --> LLM
Agent --> MCP
MCP --> Trino
Agent --> Validation
Agent --> Response
Response --> User技術スタック
技術 | 目的 |
Python + FastAPI | バックエンドおよびREST/OpenAI互換API |
LangGraph | パイプラインオーケストレーション(RAG → スキーマ → SQL → 検証 → 実行) |
Ollama | ローカルLLM( |
LangChain + Qdrant | RAGドキュメント検索 |
FastMCP | Model Context Protocolサーバー(ツール) |
LangSmith | パイプラインのトレースとモニタリング |
Trino | SQLクエリエンジン(TPCHデモカタログ) |
Open WebUI | チャットUI(オプション) |
Docker | コンテナ化されたインフラストラクチャ |
プロジェクト構造
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はじめに
前提条件
Python 3.11または3.12(3.13はサポートされていません)
Docker + Docker Compose
GPUはオプション(OllamaはCPUで実行可能)
インストール
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設定
cp .env.example .env主要な変数(デフォルトはローカル開発で動作します):
変数 | 説明 |
| LLMサーバーとモデル( |
| 埋め込みモデル( |
| Qdrantベクトルデータベース |
| Trino(デフォルトカタログ |
|
|
|
|
| 検証済みSQLをTrinoで実行 |
|
|
| お使いのLangSmith APIキー(空の場合はトレース無効) |
| LangSmithプロジェクト名(デフォルト |
実行
# 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使用方法
自然言語で質問します:
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"}'レスポンスには、生成されたSQL、説明、信頼スコア、警告、そして実行が有効な場合は結果の行が含まれます:
{
"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}
}その他のエンドポイント: GET /api/v1/schema(カタログ一覧)、GET /api/v1/health、POST /v1/chat/completions(OpenAI互換、Open WebUIで使用)。
テスト
pytestテストスイートは密閉型で、ライブスタックなしで実行されます(146テスト)。
トレースとモニタリング
すべてのパイプラインクエリ(RAG検索、スキーマ参照、SQL生成、検証
ループ、実行)は、LangSmith でトレースできます。
無料アカウントを作成し、APIキーを取得して、以下を設定します:
LANGCHAIN_TRACING_V2=true、LANGCHAIN_API_KEY=<your key>、およびオプションで
LANGCHAIN_PROJECT=copilot。キーが設定されていない間はトレースはオフのままです。

Docker
docker compose でフルスタックを実行します:
サービス | コンテナ | ポート |
Ollama |
| 11434 |
Qdrant |
| 6333 |
Trino |
| 8080 |
Open WebUI |
| 3000 |
Copilot API |
| 8000 |
MCP Server |
| 8001 |
名前付きボリュームは、Ollamaモデル、Qdrantデータ、Open WebUIデータを永続化します。ollamaボリュームはexternalとして宣言されています。存在しない場合は一度作成してください:
docker volume create ollama
docker compose up -d
docker compose ps
docker compose logs -f copilot-api
docker compose downWindowsに関する注意: 実際のSSE上のMCPは、Windowsのイベントループで不安定になることがあります。Windowsでのローカル開発では
MCP_TRANSPORT=inprocessのままにし、Linux/DockerではSSEを使用してください。
This server cannot be deployed
Maintenance
Related MCP Connectors
Query your warehouse or a CSV with Claude/ChatGPT over MCP, governed by table-level ACL + audit.
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Query, join, profile, clean and convert CSV/JSON/Parquet with server-side DuckDB over MCP.
Related MCP Servers
- AlicenseBqualityDmaintenanceProvides AI models with structured access to Trino's distributed SQL query engine, enabling LLMs to directly query and analyze data stored in Trino databases.310MIT
- AlicenseNot gradedqualityFmaintenanceEnables natural language querying of Apache Doris databases via LLM-powered SQL generation, execution, and metadata management through the MCP protocol.9Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables listing and querying Trino tables via MCP, supporting arbitrary SQL queries against a Trino cluster.MIT
- FlicenseAqualityAmaintenanceNatural language to SQL engine with multi-connector support (PostgreSQL, MySQL, Snowflake, BigQuery, DuckDB), document QA, semantic caching, and self-hosted MCP server.931 PyPI4-