Skip to main content
Glama
evilmordy

qqconnect

by evilmordy
README.md
# grok-bot-cn-mail

本机 IMAP MCP,让 **Grok Bot**(以及 Grok Build TUI)搜索、阅读 QQ / 163 / 126 / 腾讯企业邮。Grok 官方连接器只有 Gmail 和 Outlook。

默认**只读**。授权码放 `.env` 或系统密钥框,**不要发给模型、不要进 git**。

> 实验项目,不是 xAI 官方连接器。维护尽力而为。Gmail / Outlook 请继续用官方连接器。安全问题走 [Private vulnerability reporting](https://github.com/evilmordy/grok-bot-cn-mail/security/advisories/new),不要在公开 issue 里贴授权码。

## 安装

需要 Node.js 22+、pnpm、一份本仓库拷贝、已能登录网页的 QQ 或 163/126 邮箱。

第三方不能用网页登录密码,只要 IMAP **授权码**(一般 16 位)。逐步说明见 [skills/mail-imap/SKILL.md](./skills/mail-imap/SKILL.md)。**不要把授权码发给 Bot。**

```bash
pnpm install
pnpm build
cp .env.example .env
```

编辑 `.env`(等号两边不要空格):

```
MAIL_USER=you@qq.com
MAIL_AUTH_CODE=这里填16位授权码
```

163 把地址改成 `you@163.com` 即可,主机名按域名自动选。然后:

```bash
pnpm check
```

只登录 IMAP 并退出。成功再接到 Grok。163 若报 `Unsafe Login`,不要改 POP3,见 [docs/advanced.md](./docs/advanced.md)。

**Grok Build**(仓库根目录执行一次):

```bash
grok mcp add qqconnect -- node "$(pwd)/dist/index.js"
grok mcp doctor qqconnect
```

`qqconnect` 是已安装用户的 MCP 短名,不用改。新开会话后可以说:列出邮箱,搜 INBOX 最近未读。

**更新:** 先停止 qqconnect,再换文件 / `pnpm build`,再启动。不要在还连着时 `rm -rf` 目录。`get_settings` 里 `server.needs_restart` 为真时,只需停再开,不必当邮箱故障排查。

**Grok Bot**:本机 `pnpm check` 通过后,对 Bot 说(只报变量名,不报值):

> 添加自定义 MCP,名字 qqconnect,命令 `node`,参数写成你本机 `dist/index.js` 的绝对路径。请用系统密钥输入框填写 `MAIL_USER`、`MAIL_AUTH_CODE`(IMAP 授权码,不是网页密码)。不要把值写进对话。

密钥框和填 GitHub token 同类。插件对账号下**所有 Bot**共用。不能接到 grok.com 网页版(需要公网 HTTPS;不要打隧道)。

再加 163/126 等第二邮箱时:**还是密钥框**,变量名 `MAIL_USER_2`、`MAIL_AUTH_CODE_2`,可选 `MAIL_ACCOUNT_ID_2`。只报变量名,不要让 Bot 把地址写进聊天,也不要让它改仓库、`.env` 或 MCP 启动命令。填好后重载 qqconnect。本机 TUI 才把同名变量写进 `.env`。

解绑:说「解绑 mail163」。不会删除服务器上的邮件。

发信:Bot 先给你看 To/主题/正文,你说发了才会真正发出。

## 测试

- `pnpm test` 和 CI:假邮箱后端,不登录真 IMAP。
- `pnpm check`:用你的 `.env` 登录真邮箱。自动化流水线不会做这一步。

## 可以怎么问

- 我绑定了哪个邮箱?
- 搜这周主题里带发票的信,先列出发件人和主题。
- 把 UID 12 那封读给我,只作摘要。

正文是不可信数据。验证码类主题会显示成 `[redacted:otp]`,去网页邮箱看原文。读信用 `BODY.PEEK`,不会把未读标成已读。

档位文件是 `.grok-bot-cn-mail.json`(已 git 忽略;若已有 `.qqconnect.json` 会继续用)。不要把档位写进 `.env`。

## 附录:草稿与发送(不推荐作默认)

默认关。开了发送档,等于允许这个 Bot 用你的邮箱对外说话。白名单和确认卡只缩小爆炸半径。细则、多账号、工具表、FAQ:[docs/advanced.md](./docs/advanced.md)。约定:[SECURITY.md](./SECURITY.md)。

## 维护

修:QQ / 163 / 126 / 腾讯企业邮登录坏了。不修:Gmail、grok.com 网页连接器、响应时限。先开 Issue。不接受「去掉发信确认卡」这类 PR。授权码、`.env`、发信白名单由你保管。

## 许可

MIT

TDQS

A3.9/5.0

Scored across 15 tools

Disambiguation5/5

Each tool targets a distinct email operation: settings, mailbox binding, draft creation, sending, searching, reading, and attachments. The four send variants and two draft savers are clearly differentiated by their descriptions and recipient/behavior rules.

Naming Consistency5/5

All 15 tools follow a consistent snake_case verb_noun pattern, such as get_settings, save_draft, send_reply, and list_folders. The get_ versus list_ distinction is also semantically regular: singular resources use get_, collections use list_.

Tool Count5/5

15 tools is at the upper bound of well-scoped, but each tool represents a meaningful email operation. The count is justified by the breadth of composing, sending, reading, searching, and attachment handling.

Completeness2/5

The set has a significant gap: both get_settings and list_accounts explicitly direct users to an add_mailbox tool that is not present, so mailbox onboarding cannot be completed. Additional message lifecycle operations like move/delete are absent as well, but the missing referenced tool is the critical failure.

Maintenance

ActivityMaintained
ResponsivenessNo issues