mirror of
https://github.com/beilunyang/moemail.git
synced 2026-09-05 23:36:37 +08:00
feat(cli,mcp): extract @moemail/core and add MCP server; release 1.0.0
Extract the HTTP client and config into a new @moemail/core package shared by the CLI and a new @moemail/mcp server, so both frontends talk to the same MoeMail API through one code path. - core: api client (now throws typed ConfigError/AuthError/PermissionError/ QuotaError instead of process.exit), config, msToIso, and a transport- agnostic pollForNewMessage helper. - cli: consume @moemail/core; route command errors through a shared fail() that preserves exit codes (config/auth = 2, else = 1). Bump to 1.0.0. - mcp: new stdio MCP server exposing 8 tools (create/list/read/wait/send/ delete); wait_for_email is bounded and returns a timeout status to retry. Configured via MOEMAIL_API_KEY / MOEMAIL_API_URL env. Release 1.0.0. Docs: - Fix packages/cli/README.md (config set, send --content not --body, full flag table). - Add MCP section to both root READMEs; complete the CLI command list (send, list, message-level delete). - SKILL.md: --json works before or after the subcommand. - Ignore bun.lock in package gitignores. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+54
-1
@@ -30,6 +30,7 @@
|
||||
<a href="#Webhook 集成">Webhook 集成</a> •
|
||||
<a href="#OpenAPI">OpenAPI</a> •
|
||||
<a href="#cli-工具">CLI 工具</a> •
|
||||
<a href="#mcp-服务器">MCP 服务器</a> •
|
||||
<a href="#环境变量">环境变量</a> •
|
||||
<a href="#Github OAuth App 配置">Github OAuth App 配置</a> •
|
||||
<a href="#Google OAuth App 配置">Google OAuth App 配置</a> •
|
||||
@@ -807,13 +808,25 @@ moemail config set api-key YOUR_API_KEY
|
||||
# 创建临时邮箱
|
||||
moemail create --domain moemail.app --expiry 1h --json
|
||||
|
||||
# 列出邮箱
|
||||
moemail list --json
|
||||
|
||||
# 列出邮箱内的邮件
|
||||
moemail list --email-id <id> --json
|
||||
|
||||
# 等待新邮件(轮询)
|
||||
moemail wait --email-id <id> --timeout 120 --json
|
||||
|
||||
# 读取邮件内容
|
||||
moemail read --email-id <id> --message-id <id> --json
|
||||
|
||||
# 删除邮箱
|
||||
# 从临时地址发件
|
||||
moemail send --email-id <id> --to user@example.com --subject "你好" --content "正文内容" --json
|
||||
|
||||
# 删除单封邮件
|
||||
moemail delete --email-id <id> --message-id <id>
|
||||
|
||||
# 删除整个邮箱
|
||||
moemail delete --email-id <id>
|
||||
```
|
||||
|
||||
@@ -837,6 +850,46 @@ CONTENT=$(moemail read --email-id $EMAIL_ID --message-id $MSG_ID --json)
|
||||
|
||||
详细文档见 [packages/cli/README.md](packages/cli/README.md)。
|
||||
|
||||
## MCP 服务器
|
||||
|
||||
MoeMail 同时提供 [MCP](https://modelcontextprotocol.io) 服务器,让任意支持 MCP 的客户端
|
||||
(Claude Desktop、Cursor、Cline 等)无需调用 CLI 即可原生使用临时邮箱工具。
|
||||
|
||||
### 工具
|
||||
|
||||
| 工具 | 说明 |
|
||||
|------|------|
|
||||
| `create_email` | 创建临时邮箱(`1h` / `24h` / `3d` / `permanent`) |
|
||||
| `list_emails` | 列出该 API Key 下的邮箱 |
|
||||
| `list_messages` | 列出邮箱内的邮件 |
|
||||
| `read_message` | 读取邮件完整内容(文本 / HTML) |
|
||||
| `wait_for_email` | 轮询等待新邮件(有时间上限;超时返回 `status: "timeout"` 可再次调用续等) |
|
||||
| `send_email` | 从临时地址发件 |
|
||||
| `delete_email` | 删除邮箱 |
|
||||
| `delete_message` | 删除单封邮件 |
|
||||
|
||||
### 配置
|
||||
|
||||
在 MCP 客户端配置中加入该服务器(例如 Claude Desktop 的 `claude_desktop_config.json`),
|
||||
凭证通过环境变量传入:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"moemail": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@moemail/mcp"],
|
||||
"env": {
|
||||
"MOEMAIL_API_KEY": "你的_API_KEY",
|
||||
"MOEMAIL_API_URL": "https://moemail.app"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
详细文档见 [packages/mcp/README.md](packages/mcp/README.md)。
|
||||
|
||||
## 环境变量
|
||||
|
||||
本项目使用以下环境变量:
|
||||
|
||||
Reference in New Issue
Block a user