Skip to main content
Glama
README.md
# lexueMCP

`lexueMCP` 把北理工新乐学教师端的信息和操作提供为本地 MCP 工具。它使用专用 Google Chrome 配置,由教师在学校页面登录。当前为面向 macOS 上 Codex 的公开开发版,能力和真实验收进度见 [能力目录](CAPABILITIES.md)。

## 在本机接入 Codex

需要 macOS、Node.js 22 或更高版本、Google Chrome、Codex 桌面端和可登录的新乐学教师账号。

在 `lexueMCP` 项目目录执行:

```sh
npm ci
codex mcp add lexuemcp -- "$(command -v node)" "$PWD/src/main.js"
```

在 Codex 桌面端新建对话或重启桌面应用以加载配置。也可以从设置里的 MCP 服务器添加 STDIO 服务,以 Node 的绝对路径为命令,`src/main.js` 的绝对路径为参数。若系统默认工具超时不足,可为这一个服务器将 `tool_timeout_sec` 调到 `120`。

若终端里的 `codex` 提示现有配置不兼容,可用桌面 MCP 设置,或把命令里的 `codex` 换成桌面安装包内的 CLI。ChatGPT 默认安装路径下为 `/Applications/ChatGPT.app/Contents/Resources/codex-cli/bin/codex`。

在对话里让 Codex 调用 `lexue_open_login`。如果专用 Chrome 显示北理工登录页,请在页面完成登录。之后可以调用 `lexue_list_courses`、`lexue_get_course` 等。专用 Chrome 窗口可以保持打开。

可以先让 Codex 查找课程并列出学期与课程编号,再读取指定学期的作业。`lexue_capabilities` 可随时查询工具的验收状态。

浏览器登录配置默认在 `~/Library/Application Support/lexueMCP/chrome`。可用 `LEXUE_PROFILE_DIR` 指定独立位置。Chrome 配置不能放在源码目录内,也不共用日常 Chrome 的数据目录。一个配置目录同一时间由一个服务进程使用。若提示 `PROFILE_IN_USE`,结束上一个使用该配置的 Codex 会话后重试。

本地文件上传工具接收用户指定的绝对路径。新建作业和课件默认以保存为目的,把 `publish` 设为 `true` 才选择发布。课程公告的保存可能直接发布。删除工具需要确定课程、模块、精确标题和用户确认。若收到 `WRITE_OUTCOME_UNKNOWN`,先查看页面结果,再决定是否重试。

## 验证

```sh
npm test
```

测试覆盖真实 MCP STDIO 握手和用模拟页面运行浏览器适配。模拟测试不连接学校账号、不访问真实学生数据。真实平台结果以 [能力目录](CAPABILITIES.md) 为准。

## 许可证

源码以 [MIT 许可证](LICENSE) 公开。

## 技术参考

- [Playwright 持久浏览器配置](https://playwright.dev/docs/api/class-browsertype#browser-type-launch-persistent-context)
- [Codex MCP 配置](https://learn.chatgpt.com/docs/extend/mcp)
- [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk)

TDQS

B3.3/5.0

Scored across 19 tools

Disambiguation4/5

Most tools map clearly to a distinct resource and action, such as list_courses, create_assignment, or download_attachment. Some overlap exists because get_activity and delete_activity apply generically to assignments, courseware, and announcements, while other tools are resource-specific, but the descriptions mostly clarify the boundaries.

Naming Consistency4/5

The tool set consistently uses the lexue_ prefix and snake_case, mostly following a verb_noun pattern. Minor deviations like lexue_capabilities (noun-only) and mixed verbs such as save/create/update/upload keep it from being perfectly uniform.

Tool Count4/5

At 19 tools, the set is somewhat large but still reasonable for an LMS automation server covering courses, members, assignments, courseware, announcements, attachments, login, and section reading. Most tools have a clear role, though a few generic activity tools add some surface area.

Completeness3/5

The server covers broad read access and core write operations for courses, assignments, announcements, and courseware. However, notable lifecycle gaps remain: no course deletion, no member enrollment management, no submission grading, no courseware update, and no write operations for many readable sections such as discussions, tests, or grades.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues