dataflowr-CLI、API和MCP服务器,用于深度学习自主学习课程
 
这 深度学习DIY 该课程通过动手笔记本从头开始教授PyTorch——张量、autodiff、CNN、RNN、Transformers、VAE和扩散模型。课程资源:
- 数据流/笔记本电脑 --所有实用笔记本(PyTorch基础→ 扩散模型)
- 数据流/gpu_llm_flash-attention --使用Triton从头开始实施FlashAttention-2
- dataflowr/llm控制生成 --LLM的结构化生成、元生成和自校正
- dataflowr/llm效率 -用于minGPT的KV缓存和LoRA
- 数据流/记录 --从课堂讲稿中提取318个概念笔记,带时间戳的引文和交叉引用
该软件包将课程公开为CLI、REST API和MCP服务器,以便AI代理可以导航和教授它。
快速开始使用Claude Code
选项1--托管服务器(无需安装): 添加一个 .mcp.json 指向共享实例的项目根目录下的文件:
{
"mcpServers": {
"dataflowr": {
"type": "http",
"url": "https://dataflowr.paris.inria.fr/mcp"
}
}
}选项2——本地服务器: 自己运行它 uv (首次使用时下载):
{
"mcpServers": {
"dataflowr": {
"type": "stdio",
"command": "uv",
"args": ["run", "--with", "dataflowr[mcp]", "python", "-m", "dataflowr.mcp_server"]
}
}
}当您打开文件夹时,Claude Code会自动拾取此信息。
要预先批准所有数据流工具(无每次调用提示),还可以添加 .claude/settings.json:
{
"permissions": {
"allow": ["mcp__dataflowr"]
}
}对于全局允许(所有项目),将其添加到 ~/.claude/settings.json.
______________________________________________________________________
安装
# with uv (recommended)
uv pip install dataflowr # CLI only
uv pip install dataflowr[api] # CLI + REST API
uv pip install dataflowr[mcp] # CLI + MCP server
uv pip install dataflowr[all] # everything
# with pip
pip install dataflowr
pip install dataflowr[mcp]或来源:
git clone https://github.com/dataflowr/dataflowr-tools
cd dataflowr-tools
uv pip install -e ".[all]"______________________________________________________________________
命令行界面
# Course overview
dataflowr info
# List all modules
dataflowr modules list
# Filter by session, tag, or GPU requirement
dataflowr modules list --session 7
dataflowr modules list --tag attention
dataflowr modules list --gpu
# Full module details (with notebook links)
dataflowr module 12
# Fetch notebook content from GitHub
dataflowr notebook 12 # practical (default)
dataflowr notebook 12 --kind intro
dataflowr notebook 12 --no-code # markdown only
# Fetch course website page text (raw markdown from dataflowr/website)
dataflowr page 12
# Fetch lecture slides (from dataflowr/slides)
dataflowr slides 12
# Fetch quiz questions (from dataflowr/quiz)
dataflowr quiz 2a
dataflowr quiz 3
# Browse transcript knowledge base (318 concept notes from lectures)
dataflowr transcripts search "backprop"
dataflowr transcripts get "training loop"
# Compare catalog against website + slides repos
dataflowr sync
# Search by keyword
dataflowr search "attention transformer"
dataflowr search "generative"
# Sessions
dataflowr sessions list
dataflowr sessions get 7
# Homeworks
dataflowr homeworks list
dataflowr homeworks get 1
# JSON output (pipe-friendly)
dataflowr modules list --json | jq '.[] | select(.session == 9)'
dataflowr module 18b --json______________________________________________________________________
REST API
uvicorn dataflowr.api:app --reload
# → http://localhost:8000
# → http://localhost:8000/docs (Swagger UI)终点:
| 方法 | 路径 | 描述 |
|---|---|---|
| 得到 | / | 课程概述 |
| 得到 | /modules | 列出所有模块(?session=, ?tag=, ?gpu=) |
| 得到 | /modules/{id} | 按ID获取模块 |
| 得到 | /modules/{id}/notebooks | 获取模块的笔记本(?kind=) |
| 得到 | /modules/{id}/notebooks/{kind}/content | 从GitHub获取笔记本单元格(?include_code=) |
| 得到 | /modules/{id}/slides | 从数据流/幻灯片中获取讲座幻灯片内容 |
| 得到 | /modules/{id}/quiz | 从数据流/测验中获取测验问题 |
| 得到 | /modules/{id}/page | 从数据流/网站获取模块源代码标记 |
| 得到 | /catalog/sync | 将目录与网站+幻灯片库进行比较 |
| 得到 | /sessions | 列出所有会话 |
| 得到 | /sessions/{n} | 获取模块会话 |
| 得到 | /homeworks | 列出所有家庭作业 |
| 得到 | /homeworks/{id} | 通过ID获取作业 |
| 得到 | /search?q=... | 搜索模块 |
| 得到 | /transcripts/search?q=... | 搜索成绩单概念笔记 |
| 得到 | /transcripts/{concept} | 获取成绩单概念笔记 |
示例:
curl http://localhost:8000/modules/12
curl http://localhost:8000/sessions/7
curl http://localhost:8000/search?q=diffusion
curl "http://localhost:8000/modules?session=9&gpu=true"
curl "http://localhost:8000/modules?tag=attention"
curl "http://localhost:8000/modules/12/notebooks/practical/content?include_code=false"
curl http://localhost:8000/modules/12/page
curl http://localhost:8000/modules/2a/quiz
curl http://localhost:8000/modules/3/quiz
curl "http://localhost:8000/transcripts/search?q=backprop"
curl http://localhost:8000/transcripts/training%20loop______________________________________________________________________
MCP服务器(用于AI代理)
使该课程可供Claude、Cursor、VS Code和其他MCP兼容代理本地使用。 建立在 官方MCP Python SDK (FastMCP)。
标准传输(本地--Claude桌面、光标、VS代码、Claude代码)
python -m dataflowr.mcp_serverHTTP传输(远程/共享部署)
python -m dataflowr.mcp_server --http
# → POST http://localhost:8001/mcp (or $PORT if set)______________________________________________________________________
客户端配置
克劳德代码(VSCode扩展或CLI)
添加一个 .mcp.json 文件在 项目的根 (作业仓库、笔记本文件夹等):
{
"mcpServers": {
"dataflowr": {
"type": "stdio",
"command": "uv",
"args": ["run", "--with", "dataflowr[mcp]", "python", "-m", "dataflowr.mcp_server"]
}
}
}当您打开文件夹时,Claude Code会自动拾取此信息。无需全局安装-- uv 下载 dataflowr[mcp] 第一次使用。
要预先批准所有数据流工具(无每次调用提示),还可以添加 .claude/settings.json:
{
"permissions": {
"allow": ["mcp__dataflowr"]
}
}或者在全球范围内注册(每个项目都有):
claude mcp add --scope user dataflowr -- uv run --with dataflowr[mcp] python -m dataflowr.mcp_server克劳德桌面版
编辑 ~/.claude/claude_desktop_config.json (macOS/Linux)或 %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"dataflowr": {
"command": "python",
"args": ["-m", "dataflowr.mcp_server"]
}
}
}随着 uv (无需全局安装):
{
"mcpServers": {
"dataflowr": {
"command": "uv",
"args": ["run", "--with", "dataflowr[mcp]", "python", "-m", "dataflowr.mcp_server"]
}
}
}光标
编辑 .cursor/mcp.json 在你的项目的根(或 ~/.cursor/mcp.json 全球):
{
"mcpServers": {
"dataflowr": {
"command": "python",
"args": ["-m", "dataflowr.mcp_server"]
}
}
}VS代码
编辑 .vscode/mcp.json 在项目的根本:
{
"servers": {
"dataflowr": {
"type": "stdio",
"command": "python",
"args": ["-m", "dataflowr.mcp_server"]
}
}
}远程/HTTP(自托管)
如果使用运行自己的实例 --http,将客户端指向URL:
{
"mcpServers": {
"dataflowr": {
"type": "http",
"url": "http://localhost:8001/mcp"
}
}
}______________________________________________________________________
推荐的工作流程
1. search_modules "attention" → find relevant modules by keyword
2. get_module "12" → full details, notebook links, prerequisites
3. get_page_content "12" → read the lecture notes
4. get_notebook_content "12" → work through the exercises
5. get_quiz_content "12" → self-test your understanding
6. search_transcripts "attention" → find concept notes from lecture transcripts
7. get_transcript_note "training loop" → read timestamped quotes and cross-references如需个性化学习计划,请使用 learning_path 使用目标模块进行提示。
______________________________________________________________________
暴露于代理的工具
| 工具 | 说明 |
|---|---|
list_modules | 列出模块,可按会话/标签/GPU过滤 |
get_module | 模块的完整细节 |
search_modules | 跨标题、描述和标签的关键字搜索 |
list_sessions | 列出所有会话 |
get_session | 会话+所有模块内容 |
get_notebook_url | 笔记本电脑的GitHub/Colab链接 |
list_homeworks | 所有作业 |
get_homework | 家庭作业的全部细节 |
get_slide_content | 从数据流/幻灯片中获取讲座幻灯片 |
get_quiz_content | 从数据流/测验中获取测验问题 |
check_quiz_answer | 验证学生的测验答案 |
get_notebook_content | 从GitHub获取实际的笔记本单元格 |
get_notebook_exercises | 只获取练习提示+骨架代码 |
get_page_content | 从数据流/网站获取模块源代码标记 |
get_course_overview | 作为背景的完整课程结构 |
get_prerequisites | 给定模块的先决条件模块 |
suggest_next | 完成一个模块后要学习什么 |
sync_catalog | 将目录与网站+幻灯片库进行比较 |
search_transcripts | 从课堂讲稿中模糊搜索318个概念笔记 |
get_transcript_note | 获取成绩单概念笔记的完整内容 |
向代理人暴露的提示
| 提示 | 参数 | 描述 |
|---|---|---|
explain_module | module_id | 辅导课——模块的苏格拉底式解释 |
quiz_student | module_id | 互动测验,一次一个问题 |
debug_help | module_id | 实用笔记本的引导调试帮助 |
learning_path | target_module_id, known_modules | 目标模块的个性化先决条件链 |
______________________________________________________________________
示例问题
一旦连接,代理可以回答以下问题:
- *“在处理扩散模型之前,我应该研究什么?”*
- *“给我microGPT笔记本电脑的Colab链接。”*
- *“哪个环节涉及注意力机制?”*
- *“生成建模模块都是什么?”*
- *“给我看Flash Attention作业任务。”*
- *“对模块3——损失函数进行测试。”*
- *“我被模块2b中的反向传播练习卡住了。请帮我调试一下。”*
- *“从头开始,为我构建一条通往模块18b(扩散模型)的学习路径。”*
- *“教授对训练循环说了什么?给我看看成绩单上的引文。”*
______________________________________________________________________
Python API
from dataflowr import COURSE
# Get a module
module = COURSE.get_module("12")
print(module.title) # "Attention and Transformers"
print(module.description)
print(module.notebooks)
# Search
results = COURSE.search("attention")
# Get a session
modules = COURSE.get_session_modules(7)
# Navigate the full catalog
for module in COURSE.modules.values():
if module.requires_gpu:
print(f"Module {module.id}: {module.title}")______________________________________________________________________
设计原则
- 只有内容,没有执行。 该包公开了课程结构和链接。运行笔记本留在学生手中。
- 代理人友好。 所有输出都是文本优先。MCP服务器呈现markdown,以便代理可以在响应中直接使用它。
- 核心没有外部依赖关系。 目录、型号和CLI仅适用于
pydantic,typer,以及rich.API需要fastapi;MCP服务器需要mcp. - 唯一的真相来源。
catalog.py是课程发展时唯一需要更新的地方。
