对话和闪卡MCP服务器
MCP服务器,分析教育对话以识别缺失的先决条件概念,并提供有针对性的抽认卡建议。该系统执行多阶段对话分析,以检测表面问题之外的潜在知识差距。
演示
在演示视频中,我们展示了一个场景,其中一名学生询问有关Jensen不等式和高斯分布的问题。虽然这些似乎是不同的主题,但我们的对话分析系统发现,这两个问题都源于对均值和方差概念的根本误解。潜在概念检测器成功地提取了这一在两个表面主题中都造成困难的共同先决条件,并推荐了相关的抽认卡来解决根本的知识差距。该系统完全实现为MCP插件,便于与现有的教育聊天机器人集成。
https://github.com/user-attachments/assets/b21a7079-4e31-4207-b181-a8743d468f67
建筑
该系统由两个主要部分组成:
- MCP服务器(TypeScript) -为MCP工具提供输入验证并处理通信协议(stdio用于本地Claude Desktop,HTTP用于远程访问)
- Python Flask API -实现对话分析逻辑、异步任务管理和从CSV数据中检索闪存卡
目录结构
├── src/
│ ├── mcp_server/ # TypeScript MCP server
│ │ ├── index.ts # Main entry point
│ │ ├── server.ts # MCP server configuration
│ │ ├── httpServer.ts # HTTP transport for remote access with OpenAI Playground
│ │ ├── tools/ # MCP tool implementations
│ │ ├── clients/ # Python API client
│ │ ├── config/
│ │ └── logging/
│ └── python_api/ # Flask API backend
│ ├── app/
│ │ ├── api/ # REST API endpoints
│ │ ├── domain/
│ │ │ ├── summarization/ # Dialogue analysis
│ │ │ └── flashcard/ # Flashcard retrieval
│ │ └── config.py
│ └── Dockerfile
├── data/
│ ├── flashcards.csv # Educational flashcard database
│ └── dialogues.csv # Dialogue analysis results
├── docker-compose.yml
└── package.json 安装和设置
npm install
npm run build
cd src/python_api
pip install -r requirements.txt
python -m gunicorn --config gunicorn.conf.py app:app与本地客户端(Claude Desktop)集成
将MCP服务器添加到客户端的config.json中
{
"dialogue-flashcards": {
"command": "/path/to/your/node",
"args": [
"/path/to/your/mcp-dialogue-flashcard/dist/index.js"
],
"env": {
"PY_API_BASE_URL": "http://127.0.0.1:8081/api/v1"
}
}
}与远程客户端(OpenAI Playground)集成
运行httpserver
export PORT=3000
export PY_API_BASE_URL=http://127.0.0.1:8081/api/v1
node dist/httpServer.js
ngrok http 3000 #if NAT traversal neededMCP工具
服务器提供四个MCP工具用于对话分析和抽认卡检索, 为了避免聊天机器人超时和多个请求重试,耗时的对话摘要工具辅以两个助手查询/等待对话摘要
start_dialogue_summary
启动异步对话分析并返回任务ID以跟踪进度。
输入:
{
"dialogue": [
{"role": "student", "message": "I don't understand Jensen's inequality"},
{"role": "tutor", "message": "Can you explain what you know about convex functions?"}
],
"user_id": 0
}输出:
{
"task_id": "uuid-string",
"status": "started",
"message": "Task created and processing started"
}query/wait_summary
检查对话分析任务的当前状态和进度。
输入:
{
"task_id": "uuid-string",
}输出:
{
"task_id": "uuid-string"
"timeout": 300,
"message": "Processing Latent Refinement Loop (2/3)"
}retrieve_flashcard
按概念名称检索教育抽认卡(如果超过阈值,#TODO将根据概念嵌入的余弦相似性返回top1匹配)
输入:
{
"concept": "mean_and_variance"
}输出:
{
"concept": "mean_and_variance",
"question": "What are the mean and variance of a random variable?",
"answer": "The mean is the expected value, variance measures spread around the mean..."
}扩展对话摘要逻辑
对话分析管道位于 src/python_api/app/domain/summarization/ 并遵循多阶段的工作流程:
- 生成→ 判断→ 细化循环→ 闪存卡生成→ 结果保存
