Enterprise Big Data Copilot
企业大数据 Copilot
一个 AI 副驾驶,利用 RAG、MCP 工具和本地 LLM 推理,将自然语言问题转化为经过验证、感知模式的 Trino SQL。
概述
企业大数据 Copilot 让用户能够用通俗英语查询大数据平台。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 结果检索
模型上下文协议(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 | 模型上下文协议服务器(工具) |
LangSmith | 流水线追踪和监控 |
Trino | SQL 查询引擎(TPCH 演示目录) |
Open WebUI | 聊天界面(可选) |
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(默认目录 |
|
|
|
|
| 在 Trino 上运行验证后的 SQL |
| 设置为 |
| 您的 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=<您的密钥>,以及可选的 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 注意: 在 Windows 事件循环上,通过真实 SSE 的 MCP 可能不稳定。在 Windows 上进行本地开发时,请保持
MCP_TRANSPORT=inprocess;在 Linux/Docker 上使用 SSE。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
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 gradedqualityDmaintenanceEnables 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.92
Related MCP Connectors
The grounded data layer for any LLM: governed SQL, metrics, lineage and catalog over your data.
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
GibsonAI MCP server: manage your databases with natural language
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/hani-ben-dhaou/Enterprise-Big-Data-Copilot'
If you have feedback or need assistance with the MCP directory API, please join our Discord server