课程管理服务器

一个用于管理学生课程和作业信息的服务器,提供课程查询、按周或课程代码过滤以及生成ICS日历文件的功能。

  • by Joregesosa
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 Joregesosa/course-assistant-mcp-server

使用说明

MCP学生服务器

用于管理课程和学生任务信息的MCP(Model Context Protocol)服务器。提供用于查询课程、按周筛选或课程代码以及生成ICS文件以与日历集成的工具。

🚀 特点

  • MCP 资源:每个学生访问课程信息
  • MCP工具:
    • get_filtered_courses:按代码和/或周查询和筛选课程
    • build_ics_file:生成ICS文件以将任务导入日历
  • API REST用于Web集成的:Endpoints Fastapi
  • 检查员MCP:与MCP检查工具兼容

📋 要求

  • Python 3.8以上
  • Conda(推荐用于环境管理)

🛠️ 安装

1.克隆存储库

git clone <repository-url>
cd mcp-student-server

2.创建和激活Conda环境

conda create -n mcp-student python=3.11
conda activate mcp-student

3.安装依赖项

pip install -r requirements.txt

4.配置环境变量(可选)

cp .env.example .env
# Editar .env según necesidades

🚀 使用

STDIO模式(MCP检查员)

要以STDIO模式运行服务器并使用MCP检查器测试它:

npx @modelcontextprotocol/inspector python src/main.py

这将在您的浏览器中打开一个Web界面,您可以在其中:

  • 查看可用资源
  • 测试MCP工具
  • 检查服务器的响应

Web服务器模式(FASTAPI)

要作为Web服务器运行:

uvicorn src.main:app --reload --host 0.0.0.0 --port 8000

服务器将位于:

  • APIhttp://localhost:8000
  • SSE端点:http://localhost:8000/sse
  • 消息终结点:http://localhost:8000/messages

CLI模式(Python Direct)

python src/main.py

📁 项目结构

mcp-student-server/
├── src/
│   ├── main.py                  # Entry point principal
│   ├── config.py                # Configuración
│   ├── models/                  # Modelos de datos Pydantic
│   │   ├── course.py
│   │   └── student.py
│   ├── services/                # Lógica de negocio
│   │   ├── course_service.py
│   │   └── calendar_service.py
│   ├── mcp/                     # Componentes MCP
│   │   ├── server.py
│   │   ├── resources.py
│   │   └── tools.py
│   ├── routes/                  # Rutas FastAPI
│   │   └── mcp_routes.py
│   ├── utils/                   # Utilidades
│   │   └── date_utils.py
│   └── data/                    # Datos de ejemplo
│       └── example_data.json
├── api/                         # Entry point para Vercel
│   └── index.py
├── requirements.txt
├── .env.example
└── README.md

🔧 可用的MCP工具

get_filtered_courses

为特定学生检索和筛选课程。

参数:

  • student_id (必填):学生ID
  • course_code (可选):要筛选的课程代码(例如:“CSE270”)
  • week (可选):要过滤的周数(例如:“1”、“2”)

使用示例:

{
  "student_id": "12345",
  "course_code": "CSE270",
  "week": "2"
}

build_ics_file

生成包含课程任务的ICS文件。

参数:

  • student_id (必填):学生ID
  • course_code (可选):要筛选的课程代码
  • week (可选):要过滤的周数

使用示例:

{
  "student_id": "12345",
  "course_code": "CSE270"
}

🌐 MCP 资源

学生://{student_id}/课程

访问特定学生课程的动态URI。

示例:

  • students://12345/courses
  • students://example/courses

📦 依赖关系

  • fastapi:框架网站
  • uvicornASGI服务器
  • mcp:模型上下文协议SDK
  • icalendar:生成ICS文件
  • pytz:时区管理
  • sse-starlette:服务器发送的事件
  • pydantic:数据验证

🚢 部署

维塞尔

该项目配置为通过 vercel.json:

# Deploy a Vercel
vercel --prod

档案馆 vercel.json 配置部署以使用 src/main.py 直接。

🧪 测试(即将)

pytest tests/

📝 注释

  • 建议使用Conda进行环境管理
  • 示例数据在 src/data/example_data.json
  • 对于开发,使用模式 --reload 秘鲁玉米
  • 服务器支持STDIO和HTTP/SSE模式

📄 许可证

[指定许可证]

👥 贡献

[捐款说明]