Skip to main content
Glama
ZztIsolation

HDU Academic System MCP Server

by ZztIsolation

HDU教务处MCP服务器

一个用于杭州电子科技大学教务处系统的MCP (Model Context Protocol) 服务器,支持自动登录和课程表获取功能。

项目概述

本项目实现了一个MCP服务器,允许AI助手通过用户提供的学号和密码登录杭电教务处系统,并获取相关的学术信息,如课程表等。

主要功能

  • 教务处登录: 支持通过学号和密码登录杭电SSO系统

  • 🚧 课程表获取: 获取当前学期或指定学期的课程表信息

  • 🔒 会话管理: 自动处理登录状态和Cookie管理

  • 📊 结构化数据: 返回JSON格式的结构化课程信息

技术架构

核心技术栈

  • TypeScript: 主要开发语言

  • @modelcontextprotocol/sdk: MCP协议实现

  • axios: HTTP客户端,用于网络请求

  • cheerio: HTML解析,用于提取页面信息

  • tough-cookie: Cookie管理

  • axios-cookiejar-support: Axios的Cookie支持

项目结构

hdu-jwc-mcp/
├── src/
│   ├── index.ts              # MCP服务器主入口
│   ├── hdu-jwc-client.ts     # 教务处客户端核心逻辑
│   └── test-login.ts         # 登录功能测试脚本
├── dist/                     # 编译输出目录
├── package.json              # 项目配置和依赖
├── tsconfig.json             # TypeScript配置
└── README.md                 # 项目文档

构建过程

环境要求

  • Node.js >= 18.0.0

  • npm >= 8.0.0

安装依赖

npm install

编译项目

# 一次性编译
npm run build

# 开发模式(监听文件变化)
npm run dev

运行服务器

npm start

功能详解

1. 登录功能 (hdu_login)

功能描述: 使用学号和密码登录杭电教务处系统

输入参数:

  • username (string): 学号

  • password (string): 密码

返回结果:

{
  "success": true,
  "message": "登录成功",
  "userInfo": {
    "name": "学生姓名",
    "studentId": "学号"
  }
}

实现原理:

  1. 访问SSO登录页面 (https://sso.hdu.edu.cn/login)

  2. 解析页面获取必要的隐藏字段 (lt, execution, _eventId)

  3. 构造登录表单数据并提交

  4. 处理重定向和登录状态验证

  5. 提取用户信息

2. 课程表获取功能 (get_course_schedule)

功能描述: 获取指定学期的课程表信息(需要先登录)

输入参数:

  • semester (string, 可选): 学期标识,默认为当前学期

返回结果:

{
  "success": true,
  "message": "获取成功",
  "courses": [
    {
      "courseName": "课程名称",
      "teacher": "任课教师",
      "time": "上课时间",
      "location": "上课地点",
      "weeks": "上课周次"
    }
  ],
  "semester": "2024-2025-1"
}

当前状态: 🚧 开发中 - 需要进一步分析教务处课表页面结构

使用方式

作为MCP服务器使用

  1. 启动服务器:

    npm start
  2. 在支持MCP的AI客户端中配置:

    {
      "mcpServers": {
        "hdu-jwc": {
          "command": "node",
          "args": ["/path/to/hdu-jwc-mcp/dist/index.js"]
        }
      }
    }
  3. 使用工具:

    • 调用 hdu_login 工具进行登录

    • 调用 get_course_schedule 工具获取课程表

独立测试使用

  1. 修改测试脚本: 编辑 src/test-login.ts,填入真实的学号和密码:

    const username = 'your_student_id';
    const password = 'your_password';
  2. 运行测试:

    npm run build
    node dist/test-login.js

开发迭代过程

第一阶段:项目初始化 ✅

  • 创建基本项目结构

  • 配置TypeScript和构建环境

  • 设置MCP服务器框架

  • 添加必要的依赖包

第二阶段:登录功能实现 ✅

  • 分析杭电SSO登录流程

  • 实现HTTP客户端和Cookie管理

  • 处理登录表单提交和重定向

  • 添加错误处理和状态验证

  • 创建测试脚本验证功能

第三阶段:课程表功能 🚧

  • 分析教务处课程表页面结构

  • 实现课程表数据解析

  • 支持不同学期的课程表获取

  • 优化数据格式和错误处理

第四阶段:功能完善 📋

  • 添加更多教务处功能(成绩查询、考试安排等)

  • 优化错误处理和用户体验

  • 添加配置文件支持

  • 完善文档和使用示例

注意事项

安全性

  • 🔐 用户凭据仅在内存中临时存储,不会持久化

  • 🛡️ 使用HTTPS确保数据传输安全

  • ⚠️ 请妥善保管学号和密码,避免在公共环境中使用

使用限制

  • 📚 仅支持杭州电子科技大学教务处系统

  • 🕒 依赖于教务处网站结构,如有变更可能需要更新

  • 🔄 建议适度使用,避免对教务处服务器造成过大负载

故障排除

登录失败常见原因:

  1. 用户名或密码错误

  2. 教务处系统维护或不可用

  3. 网络连接问题

  4. 验证码或其他安全措施

调试方法:

  1. 检查控制台错误输出

  2. 验证网络连接

  3. 确认教务处网站是否正常访问

  4. 使用测试脚本进行独立测试

贡献指南

欢迎提交Issue和Pull Request来改进这个项目!

开发环境设置

  1. Fork本仓库

  2. 克隆到本地:git clone <your-fork-url>

  3. 安装依赖:npm install

  4. 开始开发:npm run dev

提交规范

  • 使用清晰的提交信息

  • 遵循现有的代码风格

  • 添加必要的测试和文档

许可证

MIT License - 详见 LICENSE 文件

更新日志

v1.0.0 (当前版本)

  • ✅ 实现基本的MCP服务器框架

  • ✅ 完成杭电SSO登录功能

  • 🚧 课程表获取功能开发中

  • 📝 完善项目文档


免责声明: 本项目仅供学习和研究使用,请遵守学校相关规定,合理使用教务处系统资源。

Available Tools

2 tools
get_course_scheduleB

获取课程表(需要先登录)

ParametersJSON Schema
NameRequiredDescriptionDefault
semesterNo学期(可选,默认为当前学期)

TDQS

B3.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it mentions the login requirement, it doesn't describe what the tool returns (e.g., format, structure), error conditions, or other behavioral traits like rate limits or permissions needed beyond login. This is a significant gap for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence in Chinese that conveys the core purpose and key prerequisite without any wasted words. It is appropriately sized and front-loaded with essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., schedule format, data structure), which is critical for a 'get' operation. The login prerequisite is helpful, but more behavioral context is needed for adequate completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with the parameter 'semester' documented as optional with a default. The description adds no additional parameter information beyond what the schema provides, so it meets the baseline of 3 where the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as '获取课程表' (get course schedule), which is a specific verb+resource combination. However, it doesn't differentiate from its sibling tool 'hdu_login' beyond mentioning the login prerequisite, which is more of a usage guideline than a distinction of purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states '需要先登录' (requires login first), providing clear context about prerequisites. However, it doesn't specify when to use this tool versus alternatives or any exclusions, leaving some guidance gaps.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

hdu_loginC

登录杭电教务处系统

ParametersJSON Schema
NameRequiredDescriptionDefault
passwordYes密码
usernameYes学号

TDQS

C2.6/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While '登录' (login) implies authentication and potential session creation, the description doesn't disclose what happens after login, whether sessions persist, what permissions are granted, or any rate limits/constraints. For an authentication tool with zero annotation coverage, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise - a single phrase that directly states the tool's purpose. There's no wasted language or unnecessary elaboration. However, the extreme brevity borders on under-specification rather than optimal conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For an authentication tool with no annotations and no output schema, the description is insufficient. It doesn't explain what successful login enables, what the return value contains, or what subsequent operations might be available. The combination of authentication complexity and lack of structured documentation requires more descriptive context than provided.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 100% description coverage with clear parameter documentation ('密码' for password, '学号' for student ID). The description adds no additional parameter semantics beyond what's already in the schema. With high schema coverage, the baseline score of 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '登录杭电教务处系统' clearly states the action (login) and target system (Hangzhou Dianzi University academic affairs system), providing a specific verb+resource. However, it doesn't differentiate from the sibling tool 'get_course_schedule' which appears to be a different operation entirely, so it lacks sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. There's no mention of prerequisites, when authentication is needed, or relationship to the sibling tool. It simply states what the tool does without contextual usage information.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 2 tool updatesv1.0.0
    • First observedget_course_schedule
    • First observedhdu_login

TDQS

C2.9/5.0
Disambiguation5/5

The two tools have clearly distinct purposes: one handles authentication (hdu_login) and the other retrieves data (get_course_schedule). There is no overlap in functionality, and the dependency relationship (login required for schedule) is logically clear, preventing misselection.

Naming Consistency4/5

The tool names follow a consistent verb_noun pattern (hdu_login and get_course_schedule), with both using snake_case. The slight deviation is that 'hdu_login' includes a domain prefix, but this is minor and does not break readability or predictability.

Tool Count2/5

With only 2 tools, this server feels under-scoped for an academic system. While login and schedule retrieval are core functions, typical academic systems would include more operations (e.g., get_grades, register_courses, view_notices), making this set too thin for the apparent domain.

Completeness2/5

The tool surface is severely incomplete for an academic system. It covers authentication and one data retrieval function, but lacks essential operations like viewing grades, managing registrations, or accessing announcements. This will likely cause agent failures when trying to perform common academic tasks.

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Latest Blog Posts

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/ZztIsolation/McpOfSystem'

If you have feedback or need assistance with the MCP directory API, please join our Discord server