gzgs-xgxt-mcp
# gzgs-xgxt-mcp
广州工商学院「学生工作管理服务系统」(学工系统)的 **MCP 服务器**。
任何支持 MCP 的 AI 客户端都能直接调用:查身份、查菜单、查综测明细(含加分项和佐证材料)、查五进记录。
**不需要浏览器**,只要一份登录凭证。**全部只读**——没有封装任何写操作。
> ⚠️ **免责声明**
> 本项目为个人学习与自用工具,与广州工商学院及系统厂商无关。
> 它通过自动化方式访问你**本人**的账号数据,可能不符合学校信息系统的使用条款,请自行判断风险。
> 请勿用于越权获取他人数据、批量爬取或任何违规用途。**一切后果由使用者自行承担。**
---
## 一、19 个工具
### 登录(6 个)
| 工具 | 作用 |
|---|---|
| `xg_login_status` | 检查凭证是否有效,返回当前用户 / 角色 / 权限码数量 |
| `xg_login_token` | **推荐**:粘贴浏览器里的 `Xsfwpt-Token`,自动校验后保存 |
| `xg_login_browser` | **最省事**:从已开调试端口的本地浏览器自动抓取凭证 |
| `xg_login_captcha` | 拉图形验证码(返回 base64 图片 + uuid) |
| `xg_login_account` | 账号密码登录(需要验证码时配合上一个工具) |
| `xg_logout` | 调系统 `/logout` 并清除本地凭证 |
### 业务(13 个)
| 工具 | 作用 |
|---|---|
| `xg_me` | 我的身份、角色、全部权限码 |
| `xg_menu` | 后端按角色下发的**真实菜单树**(pc / m 两种) |
| `xg_semesters` | 学年学期列表(含"当前学期"标记) |
| `xg_comeva_batches` | 综测批次列表 |
| `xg_comeva_students` | 综测名单汇总(分数已转百分制) |
| `xg_comeva_detail` | **信息最全**:三维度全部加扣分项 + 佐证材料 + 课程成绩 + 四方评语 |
| `xg_comeva_class` | 全班批量明细 |
| `xg_wujin_list` | 五进记录(课室/图书馆/实验室/竞赛/体育馆/社会) |
| `xg_wujin_stats` | 五进统计看板数据 |
| `xg_suggestions` | 意见反馈列表 |
| `xg_dict` | 数据字典(解读枚举值) |
| `xg_my_classes` | 我的班级 |
| `xg_raw` | 直调任意 GET 接口(兜底) |
---
## 二、安装
```bash
git clone https://github.com/yjp-jdp/gzgs-xgxt-mcp.git
cd gzgs-xgxt-mcp
npm install
npm start # 直接起 stdio server
npm run smoke # 冒烟测试:起服务 → 列工具 → 跑一遍只读链路
```
需要 Node.js 18+。
---
## 三、登录
### 方式 1:粘贴 Token(最稳)
1. 浏览器登录学工系统
2. `F12` → **Application / 应用** → **Cookies** → 选 `https://usc.gzgs.edu.cn`
3. 找到 `Xsfwpt-Token`,复制它的值
4. 调 `xg_login_token(token: "...")`
### 方式 2:从浏览器自动抓(不用复制)
```bash
# 用带调试端口的浏览器打开学工系统并登录
msedge.exe --remote-debugging-port=9222 --user-data-dir=C:/Temp/xgxt-profile \
https://usc.gzgs.edu.cn/xgxt/platform-ui/index
```
然后在里面登录一次,再调 `xg_login_browser()`(默认读 `http://127.0.0.1:9222`)。
### 方式 3:账号密码
学校主入口是 **CAS 单点登录**,CAS 登录页本身带图形验证码,纯账号密码自动登录不可靠。所以:
- `xg_login_account` 走的是学工系统**自己的** `/login`(若学校给该账号开了本地登录才可用)
- 需要验证码时先 `xg_login_captcha` → 让人读出 → 再传 `code` + `uuid`
> **CAS 登录没有做自动化**:CAS 有验证码 + 支持企业微信扫码,硬碰需要 OCR,不稳定也不安全。需要 CAS 就走方式 1 / 2,登录一次即可。
---
## 四、凭证存放
```
~/.xgxt-mcp/token.json # 权限 600,只在本机
```
有效期由服务端决定(RuoYi 默认较短)。失效时任何工具都会返回
`登录已失效(被重定向)` 或 `code 401`,重新走一次登录即可。
---
## 五、接入 MCP 客户端
```json
{
"mcpServers": {
"xgxt": {
"command": "node",
"args": ["/绝对路径/gzgs-xgxt-mcp/src/server.mjs"]
}
}
}
```
DeepSeek Harness(`~/.dsh/cordis.patch.yml`):
```yaml
- insert:
- id: xgxt-mcp
name: "@deepseek-ai/dsh-mcp-client"
config:
serverName: xgxt
transport: stdio
command: 'C:/Program Files/nodejs/node.exe'
args:
- '/绝对路径/gzgs-xgxt-mcp/src/server.mjs'
toolCallTimeoutMs: 180000
```
---
## 六、字段口径(重要)
| 项目 | 说明 |
|---|---|
| 分数 | 网站存的是 **×100 的整数**(7000 = 70 分),本服务已统一 **除以 100** 转成百分制 |
| `studiesTheory` | **学业理论分**:课程学分加权平均分,直接用网站原值,不要自己从课程倒推 |
| `items` | 加扣分项目数组,每项含 `selfScore`(自评)/ `finalScore`(认定)/ `scored`(是否已评)/ `evidence`(佐证材料链接) |
| `evidence` | 阿里云 OSS 图片链接,多个用逗号分隔 |
| 综合总分 | 网站算法 ≈ `品行×0.35 + 学业×0.50 + 文体×0.15`;`xg_comeva_students` 直接返回网站的总分 |
---
## 七、只读边界
本 MCP **只封装了 GET 类查询接口**,没有做任何写操作:
- 不提交综测、不改分数、不审批
- 不删记录、不上传文件
- `xg_raw` 也只允许 GET
数据范围由服务端按角色控制——学生账号只能看到自己班,别指望用它越权拉别人的数据。
---
## 八、文件结构
```
gzgs-xgxt-mcp/
├── package.json
├── smoke.mjs # 冒烟测试(MCP 客户端)
└── src/
├── client.mjs # HTTP 客户端 + 登录 + 凭证存储
└── server.mjs # MCP 工具注册
```
- 接口前缀:`https://usc.gzgs.edu.cn/xgxt/platform-api`
- 登录凭证:Cookie `Xsfwpt-Token`,请求时以 `Authorization: Bearer <token>` 携带
---
## 相关项目
同一套学校系统工具集的其它仓库(各自独立、可单独安装):
- [gzgs-jwcli](https://github.com/yjp-jdp/gzgs-jwcli) — 教务系统:课表、成绩、考试、调课(MCP + CLI)
- [chaoxing-mcp](https://github.com/yjp-jdp/chaoxing-mcp) — 学习通:作业查询、附件上传、存草稿
- [waimaigo-mcp](https://github.com/yjp-jdp/waimaigo-mcp) — 校园外卖:菜单、报价、下单(不含支付)
## 许可
[MIT](LICENSE)
TDQS
Scored across 19 tools
The domain prefixes (login_*, comeva_*, wujin_*) make most tools clearly separable, and the three login paths (account/captcha, manual token, browser auto-grab) are explicitly differentiated by their preconditions. The main overlaps are xg_login_status vs xg_me (both return user identity, role and permission info) and xg_comeva_students vs xg_comeva_class (summary list vs per-student aggregation), which an agent could confuse without reading carefully.
Names follow a steady xg_<domain>_<resource> snake_case pattern with subsystem grouping (comeva, wujin, login). A few outliers break the pattern: bare nouns xg_me, xg_menu, xg_dict, xg_raw lack a domain segment, and xg_logout is verb-only, but the overall convention is still predictable.
19 tools is on the heavier side, but they map cleanly onto real subsystems: 6 auth, 5 identity/metadata, 4 综测, 2 五进, plus semesters and suggestions. Each tool has a concrete purpose, though the six login/identity tools are the one area that could be consolidated.
The surface covers the query lifecycle well: auth (captcha/login/token/browser/logout/status), identity (me/menu/dict/classes), semesters, 五进 records and stats, and the full 综测 chain from batches to per-student detail to class aggregation, with xg_raw as a GET-only escape hatch. Gaps are mostly write operations (no submissions, feedback creation, or score entry), which is consistent with the server's read-oriented design but limits it for any mutating workflow.