Data Science Agent MCP Server
Provides MCP-compatible tools for data analysis, including file reading, Python/SQL execution, and hypothesis testing. Enables autonomous data analysis agents to interact with a sandboxed environment.
README
Data Science Agent
Autonomous AI agent for data analysis — custom ReAct loop, sandboxed Python/SQL execution, hypothesis testing, MCP protocol, skill system, real-time streaming WebUI.
Features
Core Agent
- Custom ReAct Loop — No LangChain dependency. Full control over planning, tool dispatch, and error recovery
- Dynamic Tool Registry — Pluggable tools with JSON Schema definitions. Add new tools in one line
- Planner — Decomposes vague requests into structured analysis plans
- Streaming WebSocket — Real-time thought → tool → result flow
Analysis Capabilities
- Python Sandbox — Isolated subprocess execution with auto-imported pandas/numpy/matplotlib/seaborn/scipy
- SQL Executor — Auto-loads uploaded files into SQLite tables for JOIN/GROUP BY queries
- Hypothesis Testing Engine — 8 statistical tests (t-test, chi-square, ANOVA, Mann-Whitney U, Pearson/Spearman) with effect sizes (Cohen's d, η², Cramer's V)
- Multi-file Analysis — Cross-table JOIN and correlation analysis across multiple uploaded files
- Chart Generation — Auto-captured matplotlib/seaborn charts displayed inline
- Data Lineage Tracking — Trace any conclusion back to its source data and tool calls
Skill System
- 5 Pre-built Analysis Templates: Financial Analysis, User Segmentation, Anomaly Detection, Correlation Analysis, Time Series Analysis
- Multi-select — Combine multiple skills for comprehensive analysis
- Extensible — Add custom skills as JSON files in
skills/
MCP Protocol
- JSON-RPC 2.0 endpoint at
/mcp— tools/list, tools/call, resources/list - Compatible with any MCP client
- 6 tools exposed: file_reader, python_executor, sql_executor, hypothesis_test, skill_loader, finish
Memory & Persistence
- SQLite-backed sessions — Survives restarts and page refreshes
- Auto-titling — Sessions named after uploaded files
- Cleanup on delete — Removing a session deletes its files, reports, and database
Export
- Markdown / HTML / PDF / Jupyter Notebook (.ipynb) — full analysis pipeline as executable notebook
- Streaming chat UI with real-time step visualization
- Configurable LLM — Set API key/base URL/model via UI settings panel
Architecture
User → WebUI (Next.js) → FastAPI
├── ReAct Agent Core
├── Tool Registry (6 tools)
├── MCP Server (/mcp)
├── Skill Registry (5 templates)
├── Python Sandbox (subprocess)
├── SQL Executor (SQLite per session)
└── Memory (SQLite persistence)
Quick Start
Prerequisites
- Python 3.9+
- Node.js 22+
- LLM API key (OpenAI, DeepSeek, OpenRouter, etc.)
Setup
git clone <repo-url>
cd data-science-agent
# Backend
cp .env.example .env
# Edit .env with your API key
pip install -r requirements.txt
python -m uvicorn server.main:app --host 0.0.0.0 --port 8000
# Frontend (new terminal)
cd web
npm install
npm run dev
Open http://localhost:3000.
Usage Guide
1. 配置 API 点击右上角齿轮图标 → 填入 DeepSeek / OpenAI / OpenRouter 的 API Key、Base URL、Model → 保存
2. 上传数据 左侧「数据文件」区域拖拽或点击上传 CSV/Excel/JSON 文件。支持多个文件做关联分析。
3. 选择技能(可选) 聊天区顶部选择预置技能模板(财务分析、异常检测、相关性分析等),可多选组合。
4. 提问分析 输入框输入问题,发送。Agent 自动:探查数据 → 写代码 → 出图表 → 统计检验 → 生成报告
5. 查看结果
- 分析步骤和图表实时展示
- 完成后点「查看报告」看完整报告
- 点「数据血缘」追溯数据来源
- 下载 PDF / Markdown / Jupyter Notebook
Docker
docker compose up --build
CLI Usage
# Single analysis
python cli.py "Analyze sales trends by region" -f data.csv -o report.md
# Interactive mode
python cli.py -i
API
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/sessions |
Create session |
POST |
/api/sessions/{id}/upload |
Upload file |
POST |
/api/sessions/{id}/chat |
Send message |
WS |
/ws/{id} |
Streaming chat |
GET |
/api/sessions/{id}/report |
Download report (md/html/pdf) |
POST |
/mcp |
MCP JSON-RPC endpoint |
GET |
/api/skills |
List analysis skills |
Project Structure
├── agent/
│ ├── core/ # ReAct loop, planner
│ ├── llm/ # LLM client (OpenAI-compatible)
│ ├── tools/builtin/ # file_reader, python_executor, sql_executor,
│ │ # hypothesis_test, skill_loader, finish
│ ├── memory/ # Session context + SQLite store
│ ├── sandbox/ # Subprocess & Docker sandbox
│ ├── mcp/ # MCP protocol server
│ ├── skills/ # Skill registry
│ └── reporter/ # Markdown report generator
├── server/ # FastAPI app
├── web/ # Next.js frontend
├── skills/ # Skill template JSON files
├── cli.py # CLI entry point
└── docker-compose.yml
Key Design Decisions
- No LangChain — Full control over agent loop and tool dispatch
- MCP-native — Tools exposed via standard protocol, not proprietary API
- Hypothesis-driven — Beyond descriptive stats; every conclusion backed by statistical tests
- Lineage tracking — Every data point traceable to its source
- Skill templates — Reusable, validated analysis workflows
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。