@bencibro/tempmail-mcp 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GUIDE.md +286 -0
- package/GUIDE.zh-CN.md +287 -0
- package/LICENSE +21 -0
- package/README.md +308 -0
- package/README.zh-CN.md +308 -0
- package/dist/base-provider.d.ts +21 -0
- package/dist/base-provider.d.ts.map +1 -0
- package/dist/base-provider.js +36 -0
- package/dist/base-provider.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +519 -0
- package/dist/index.js.map +1 -0
- package/dist/provider-manager.d.ts +36 -0
- package/dist/provider-manager.d.ts.map +1 -0
- package/dist/provider-manager.js +67 -0
- package/dist/provider-manager.js.map +1 -0
- package/dist/providers/auto-register.d.ts +45 -0
- package/dist/providers/auto-register.d.ts.map +1 -0
- package/dist/providers/auto-register.js +249 -0
- package/dist/providers/auto-register.js.map +1 -0
- package/dist/providers/catchmail.d.ts +20 -0
- package/dist/providers/catchmail.d.ts.map +1 -0
- package/dist/providers/catchmail.js +79 -0
- package/dist/providers/catchmail.js.map +1 -0
- package/dist/providers/guerrillamail.d.ts +21 -0
- package/dist/providers/guerrillamail.d.ts.map +1 -0
- package/dist/providers/guerrillamail.js +114 -0
- package/dist/providers/guerrillamail.js.map +1 -0
- package/dist/providers/mail-cx.d.ts +30 -0
- package/dist/providers/mail-cx.d.ts.map +1 -0
- package/dist/providers/mail-cx.js +154 -0
- package/dist/providers/mail-cx.js.map +1 -0
- package/dist/providers/mail-tm.d.ts +16 -0
- package/dist/providers/mail-tm.d.ts.map +1 -0
- package/dist/providers/mail-tm.js +109 -0
- package/dist/providers/mail-tm.js.map +1 -0
- package/dist/providers/maildrop.d.ts +22 -0
- package/dist/providers/maildrop.d.ts.map +1 -0
- package/dist/providers/maildrop.js +88 -0
- package/dist/providers/maildrop.js.map +1 -0
- package/dist/providers/one-secmail.d.ts +22 -0
- package/dist/providers/one-secmail.d.ts.map +1 -0
- package/dist/providers/one-secmail.js +98 -0
- package/dist/providers/one-secmail.js.map +1 -0
- package/dist/types.d.ts +96 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +33 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +100 -0
- package/dist/utils.js.map +1 -0
- package/package.json +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
# TempMail MCP
|
|
2
|
+
|
|
3
|
+
**[English](./README.md)** | [中文](./README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
A [Model Context Protocol](https://modelcontextprotocol.io) server that provides **temporary email** services for AI agents, enabling closed-loop verification of email-based registration flows.
|
|
6
|
+
|
|
7
|
+
> **For AI agents:** Read the [AI Guide](./GUIDE.md) for tool-by-tool instructions, decision trees, and workflow patterns.
|
|
8
|
+
> **AI 代理指南:** 阅读 [中文指南](./GUIDE.zh-CN.md) 获取工具使用说明、决策树和工作流模式。
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- **Multi-provider aggregation** — 6 temp-mail providers behind one unified interface
|
|
13
|
+
- **No API key required** for 4 out of 6 providers (Mail.tm, Guerrilla Mail, 1secmail, Catchmail)
|
|
14
|
+
- **Auto-registration** — automatically obtain MailDrop and mail.cx API keys via pure HTTP API calls (no browser needed)
|
|
15
|
+
- **Verification code extraction** — automatically extracts OTP/verification codes from incoming emails
|
|
16
|
+
- **Wait-for-email** — blocking/long-poll until a matching email arrives
|
|
17
|
+
- **Session management** — tracks created mailboxes in-memory for the MCP session
|
|
18
|
+
- **Zero heavy dependencies** — no Puppeteer, no Playwright, just Node.js built-in modules
|
|
19
|
+
|
|
20
|
+
## Supported Providers
|
|
21
|
+
|
|
22
|
+
| Provider | API Key | Free Tier | Special Features |
|
|
23
|
+
|----------|---------|-----------|-------------------|
|
|
24
|
+
| **Mail.tm** | No | 8 QPS | Full REST API, account-based |
|
|
25
|
+
| **Guerrilla Mail** | No | Unlimited | Session-based, 60-min expiry, custom username |
|
|
26
|
+
| **1secmail** | No | Unlimited | Simplest API, implicit mailbox |
|
|
27
|
+
| **Catchmail** | No | 1 req/s | Custom domains via MX records |
|
|
28
|
+
| **MailDrop** | Yes (auto-obtainable) | 300 req/day | Claim-based mailboxes, RSA pubkey auth |
|
|
29
|
+
| **Mail.cx** | Yes (auto-obtainable) | 500 req/day | Long-poll, SSE push, magic-link auth |
|
|
30
|
+
|
|
31
|
+
> **Tip:** Use the `auto_register` tool to automatically obtain MailDrop and mail.cx API keys — no manual signup needed.
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
### From npm (when published)
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install -g tempmail-mcp
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### From source
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
git clone https://github.com/your-username/tempmail-mcp.git
|
|
45
|
+
cd tempmail-mcp
|
|
46
|
+
npm install
|
|
47
|
+
npm run build
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Configuration
|
|
51
|
+
|
|
52
|
+
### Environment Variables
|
|
53
|
+
|
|
54
|
+
| Variable | Required | Description |
|
|
55
|
+
|----------|----------|-------------|
|
|
56
|
+
| `MAILDROP_API_KEY` | No | API key for MailDrop. Auto-obtainable via `auto_register` tool. |
|
|
57
|
+
| `MAILCX_API_TOKEN` | No | API token for Mail.cx. Auto-obtainable via `auto_register` tool. |
|
|
58
|
+
|
|
59
|
+
### Claude Desktop / Cursor / MCP Client Config
|
|
60
|
+
|
|
61
|
+
Add to your MCP client configuration (e.g. `claude_desktop_config.json`):
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"mcpServers": {
|
|
66
|
+
"tempmail": {
|
|
67
|
+
"command": "npx",
|
|
68
|
+
"args": ["-y", "tempmail-mcp"],
|
|
69
|
+
"env": {
|
|
70
|
+
"MAILDROP_API_KEY": "your-maildrop-api-key",
|
|
71
|
+
"MAILCX_API_TOKEN": "your-mailcx-api-token"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
If you only need the free providers (no API keys), simply omit the `env` block.
|
|
79
|
+
|
|
80
|
+
**Don't have an API key?** Use the `auto_register` tool to automatically obtain a free MailDrop or mail.cx API key — **no browser needed**, pure HTTP API calls. See [Auto-Register](#auto_register) below.
|
|
81
|
+
|
|
82
|
+
## Available Tools
|
|
83
|
+
|
|
84
|
+
### `list_providers`
|
|
85
|
+
|
|
86
|
+
List all available temporary email providers and their capabilities.
|
|
87
|
+
|
|
88
|
+
### `get_domains`
|
|
89
|
+
|
|
90
|
+
Get the list of available email domains for a given provider.
|
|
91
|
+
|
|
92
|
+
- **provider** (optional, default `"mail.tm"`): Provider name.
|
|
93
|
+
|
|
94
|
+
### `create_mailbox`
|
|
95
|
+
|
|
96
|
+
Create a new temporary email mailbox.
|
|
97
|
+
|
|
98
|
+
- **provider** (optional, default `"mail.tm"`): Provider name.
|
|
99
|
+
- **username** (optional): Preferred username (local part).
|
|
100
|
+
- **domain** (optional): Preferred domain.
|
|
101
|
+
|
|
102
|
+
### `get_messages`
|
|
103
|
+
|
|
104
|
+
Get the list of received emails for a mailbox.
|
|
105
|
+
|
|
106
|
+
- **address**: The temporary email address.
|
|
107
|
+
|
|
108
|
+
### `get_message`
|
|
109
|
+
|
|
110
|
+
Get the full content of a specific email.
|
|
111
|
+
|
|
112
|
+
- **address**: The temporary email address.
|
|
113
|
+
- **messageId**: The message ID (from `get_messages`).
|
|
114
|
+
|
|
115
|
+
### `wait_for_email`
|
|
116
|
+
|
|
117
|
+
Block until a matching email arrives. Returns the first matching message.
|
|
118
|
+
|
|
119
|
+
- **address**: The temporary email address.
|
|
120
|
+
- **subjectContains** (optional): Filter by subject substring.
|
|
121
|
+
- **fromContains** (optional): Filter by sender substring.
|
|
122
|
+
- **timeoutMs** (optional, default `60000`): Timeout in ms.
|
|
123
|
+
- **pollIntervalMs** (optional, default `3000`): Poll interval in ms.
|
|
124
|
+
|
|
125
|
+
### `get_verification_code`
|
|
126
|
+
|
|
127
|
+
Wait for a verification email and automatically extract the verification code.
|
|
128
|
+
|
|
129
|
+
- **address**: The temporary email address.
|
|
130
|
+
- **subjectContains** (optional): Filter (e.g. `"verification"`, `"confirm"`, `"code"`).
|
|
131
|
+
- **fromContains** (optional): Filter by sender.
|
|
132
|
+
- **timeoutMs** (optional, default `60000`): Timeout in ms.
|
|
133
|
+
|
|
134
|
+
### `list_mailboxes`
|
|
135
|
+
|
|
136
|
+
List all temporary mailboxes created in this session.
|
|
137
|
+
|
|
138
|
+
### `delete_mailbox`
|
|
139
|
+
|
|
140
|
+
Delete a temporary mailbox and all its messages.
|
|
141
|
+
|
|
142
|
+
- **address**: The temporary email address.
|
|
143
|
+
|
|
144
|
+
### `auto_register`
|
|
145
|
+
|
|
146
|
+
Automatically register an account and obtain an API key/token for a provider. **Pure HTTP API — no browser, no Puppeteer.**
|
|
147
|
+
|
|
148
|
+
#### `maildrop`
|
|
149
|
+
|
|
150
|
+
Uses RSA key generation + HTTP API:
|
|
151
|
+
|
|
152
|
+
1. Generates an RSA 2048 keypair (Node.js `crypto` module)
|
|
153
|
+
2. `POST /api/register.php` with the public key
|
|
154
|
+
3. Signs `timestamp-username` to create a passcode
|
|
155
|
+
4. `POST /api/login.php` to authenticate
|
|
156
|
+
5. `POST /api/account/keys.php` to create an API key (`md_...`)
|
|
157
|
+
|
|
158
|
+
#### `mail.cx`
|
|
159
|
+
|
|
160
|
+
Uses magic-link sign-in flow:
|
|
161
|
+
|
|
162
|
+
1. Creates a temp mailbox via mail.tm (no API key needed)
|
|
163
|
+
2. `POST /v1/auth/magic-link/request` to send a magic link to the temp email
|
|
164
|
+
3. Polls mail.tm for the magic link email
|
|
165
|
+
4. `POST /v1/auth/magic-link/verify` with the token — **returns the API token directly** (`tm_live_...`)
|
|
166
|
+
|
|
167
|
+
**Parameters:**
|
|
168
|
+
|
|
169
|
+
- **provider** (required): `"maildrop"` or `"mail.cx"`
|
|
170
|
+
- **tokenName** (optional, default `"tempmail-mcp"`): Name for the token (mail.cx only).
|
|
171
|
+
- **username** (optional): Username for the account (maildrop only).
|
|
172
|
+
- **timeoutMs** (optional, default `120000`): Overall timeout in milliseconds.
|
|
173
|
+
|
|
174
|
+
Returns the API key/token and automatically registers the provider in the current session. To make it permanent, set the corresponding environment variable (`MAILDROP_API_KEY` or `MAILCX_API_TOKEN`).
|
|
175
|
+
|
|
176
|
+
## Usage Examples
|
|
177
|
+
|
|
178
|
+
### Auto-Register to Get a Free API Key
|
|
179
|
+
|
|
180
|
+
**MailDrop** (fast, ~2 seconds):
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
1. auto_register (provider: "maildrop")
|
|
184
|
+
→ { apiKey: "md_...", email: "tmp_xxx@maildrop.cc", ... }
|
|
185
|
+
|
|
186
|
+
2. [Set MAILDROP_API_KEY=md_... in your MCP config]
|
|
187
|
+
|
|
188
|
+
3. list_providers
|
|
189
|
+
→ Now includes "maildrop" in the provider list!
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**mail.cx** (~15-30 seconds, waits for email):
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
1. auto_register (provider: "mail.cx")
|
|
196
|
+
→ { apiKey: "tm_live_...", email: "abc@emalupe.com", ... }
|
|
197
|
+
|
|
198
|
+
2. [Set MAILCX_API_TOKEN=tm_live_... in your MCP config]
|
|
199
|
+
|
|
200
|
+
3. list_providers
|
|
201
|
+
→ Now includes "mail.cx" in the provider list!
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Both providers are automatically available in the current session after registration — no restart needed.
|
|
205
|
+
|
|
206
|
+
### Typical Registration Verification Flow
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
1. create_mailbox (provider: "mail.tm")
|
|
210
|
+
→ { address: "abc123@somedomain.com", ... }
|
|
211
|
+
|
|
212
|
+
2. [Register on target website using the temp email address]
|
|
213
|
+
|
|
214
|
+
3. get_verification_code (address: "abc123@somedomain.com", subjectContains: "verification")
|
|
215
|
+
→ { code: "829451", from: "noreply@example.com", subject: "Your verification code", ... }
|
|
216
|
+
|
|
217
|
+
4. [Enter the code on the target website to complete registration]
|
|
218
|
+
|
|
219
|
+
5. delete_mailbox (address: "abc123@somedomain.com")
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Manual Email Checking
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
1. create_mailbox (provider: "guerrillamail", username: "mytest")
|
|
226
|
+
→ { address: "mytest@guerrillamailblock.com", ... }
|
|
227
|
+
|
|
228
|
+
2. get_messages (address: "mytest@guerrillamailblock.com")
|
|
229
|
+
→ { count: 2, messages: [{ id: "1", from: "...", subject: "..." }, ...] }
|
|
230
|
+
|
|
231
|
+
3. get_message (address: "mytest@guerrillamailblock.com", messageId: "1")
|
|
232
|
+
→ { id: "1", from: "...", subject: "...", bodyText: "...", bodyHtml: "..." }
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Development
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
# Install dependencies
|
|
239
|
+
npm install
|
|
240
|
+
|
|
241
|
+
# Build
|
|
242
|
+
npm run build
|
|
243
|
+
|
|
244
|
+
# Run locally
|
|
245
|
+
node dist/index.js
|
|
246
|
+
|
|
247
|
+
# Watch mode
|
|
248
|
+
npm run dev
|
|
249
|
+
|
|
250
|
+
# Test auto-registration
|
|
251
|
+
node test-auto-register-api.mjs maildrop # Test MailDrop only
|
|
252
|
+
node test-auto-register-api.mjs mailcx # Test mail.cx only
|
|
253
|
+
node test-auto-register-api.mjs all # Test both
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Architecture
|
|
257
|
+
|
|
258
|
+
```
|
|
259
|
+
┌──────────────────────────────────────────────────────┐
|
|
260
|
+
│ MCP Client (Claude) │
|
|
261
|
+
│ │ │
|
|
262
|
+
│ stdio / Streamable HTTP │
|
|
263
|
+
│ ▼ │
|
|
264
|
+
│ ┌──────────────────────┐ │
|
|
265
|
+
│ │ TempMail MCP Server │ │
|
|
266
|
+
│ │ │ │
|
|
267
|
+
│ │ ┌─── Tools ───────┐ │ │
|
|
268
|
+
│ │ │ create_mailbox │ │ │
|
|
269
|
+
│ │ │ get_messages │ │ │
|
|
270
|
+
│ │ │ wait_for_email │ │ │
|
|
271
|
+
│ │ │ get_verification │ │ │
|
|
272
|
+
│ │ │ auto_register │ │ │
|
|
273
|
+
│ │ │ ... │ │ │
|
|
274
|
+
│ │ └──────────────────┘ │ │
|
|
275
|
+
│ └──────────┬───────────┘ │
|
|
276
|
+
│ │ │
|
|
277
|
+
│ ┌──────────▼───────────┐ │
|
|
278
|
+
│ │ Provider Manager │ │
|
|
279
|
+
│ │ (adapter pattern) │ │
|
|
280
|
+
│ └──────────┬───────────┘ │
|
|
281
|
+
│ │ │
|
|
282
|
+
│ ┌────────┬────────┼────────┬──────────┐ │
|
|
283
|
+
│ ▼ ▼ ▼ ▼ ▼ │
|
|
284
|
+
│ Mail.tm Guerrilla 1secmail Catchmail MailDrop │
|
|
285
|
+
│ Mail Mail.cx │
|
|
286
|
+
└──────────────────────────────────────────────────────┘
|
|
287
|
+
|
|
288
|
+
Auto-Register Flow (pure HTTP, no browser):
|
|
289
|
+
┌───────────────┐ ┌───────────────┐
|
|
290
|
+
│ MailDrop │ │ mail.cx │
|
|
291
|
+
│ │ │ │
|
|
292
|
+
│ RSA keygen │ │ mail.tm temp │
|
|
293
|
+
│ ↓ │ │ mailbox │
|
|
294
|
+
│ POST register│ │ ↓ │
|
|
295
|
+
│ ↓ │ │ POST magic │
|
|
296
|
+
│ RSA sign │ │ link request │
|
|
297
|
+
│ ↓ │ │ ↓ │
|
|
298
|
+
│ POST login │ │ Poll for email│
|
|
299
|
+
│ ↓ │ │ ↓ │
|
|
300
|
+
│ POST create │ │ POST verify │
|
|
301
|
+
│ API key │ │ → API token │
|
|
302
|
+
│ → md_... │ │ → tm_live_... │
|
|
303
|
+
└───────────────┘ └───────────────┘
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## License
|
|
307
|
+
|
|
308
|
+
MIT
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
# TempMail MCP
|
|
2
|
+
|
|
3
|
+
[English](./README.md) | **[中文](./README.zh-CN.md)**
|
|
4
|
+
|
|
5
|
+
一个 [Model Context Protocol](https://modelcontextprotocol.io) 服务器,为 AI 代理提供**临时邮箱**服务,实现邮件注册验证的闭环。
|
|
6
|
+
|
|
7
|
+
> **AI 代理指南:** 阅读 [中文指南](./GUIDE.zh-CN.md) 获取工具使用说明、决策树和工作流模式。
|
|
8
|
+
> **For AI agents:** Read the [AI Guide](./GUIDE.md) for tool-by-tool instructions, decision trees, and workflow patterns.
|
|
9
|
+
|
|
10
|
+
## 特性
|
|
11
|
+
|
|
12
|
+
- **多服务商聚合** — 6 个临时邮箱服务商统一接口
|
|
13
|
+
- **4 个免费服务商无需 API Key**(Mail.tm、Guerrilla Mail、1secmail、Catchmail)
|
|
14
|
+
- **自动注册** — 通过纯 HTTP API 调用自动获取 MailDrop 和 mail.cx 的 API Key(无需浏览器)
|
|
15
|
+
- **验证码提取** — 自动从收到的邮件中提取 OTP/验证码
|
|
16
|
+
- **等待邮件** — 阻塞/长轮询直到收到匹配的邮件
|
|
17
|
+
- **会话管理** — 在内存中跟踪当前会话创建的邮箱
|
|
18
|
+
- **零重型依赖** — 无 Puppeteer、无 Playwright,仅使用 Node.js 内置模块
|
|
19
|
+
|
|
20
|
+
## 支持的服务商
|
|
21
|
+
|
|
22
|
+
| 服务商 | 需要 API Key | 免费额度 | 特性 |
|
|
23
|
+
|----------|---------|-----------|-------------------|
|
|
24
|
+
| **Mail.tm** | 否 | 8 QPS | 完整 REST API,基于账号 |
|
|
25
|
+
| **Guerrilla Mail** | 否 | 无限制 | 基于会话,60 分钟过期,自定义用户名 |
|
|
26
|
+
| **1secmail** | 否 | 无限制 | 最简 API,隐式邮箱 |
|
|
27
|
+
| **Catchmail** | 否 | 1 req/s | 通过 MX 记录自定义域名 |
|
|
28
|
+
| **MailDrop** | 是(可自动获取) | 300 次/天 | 认领式邮箱,RSA 公钥认证 |
|
|
29
|
+
| **Mail.cx** | 是(可自动获取) | 500 次/天 | 长轮询,SSE 推送,magic-link 认证 |
|
|
30
|
+
|
|
31
|
+
> **提示:** 使用 `auto_register` 工具自动获取 MailDrop 和 mail.cx 的 API Key — 无需手动注册。
|
|
32
|
+
|
|
33
|
+
## 安装
|
|
34
|
+
|
|
35
|
+
### 从 npm 安装(发布后)
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install -g tempmail-mcp
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 从源码安装
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
git clone https://github.com/your-username/tempmail-mcp.git
|
|
45
|
+
cd tempmail-mcp
|
|
46
|
+
npm install
|
|
47
|
+
npm run build
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 配置
|
|
51
|
+
|
|
52
|
+
### 环境变量
|
|
53
|
+
|
|
54
|
+
| 变量 | 是否必需 | 说明 |
|
|
55
|
+
|----------|----------|-------------|
|
|
56
|
+
| `MAILDROP_API_KEY` | 否 | MailDrop 的 API Key。可通过 `auto_register` 工具自动获取。 |
|
|
57
|
+
| `MAILCX_API_TOKEN` | 否 | Mail.cx 的 API Token。可通过 `auto_register` 工具自动获取。 |
|
|
58
|
+
|
|
59
|
+
### Claude Desktop / Cursor / MCP 客户端配置
|
|
60
|
+
|
|
61
|
+
将以下内容添加到你的 MCP 客户端配置中(如 `claude_desktop_config.json`):
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"mcpServers": {
|
|
66
|
+
"tempmail": {
|
|
67
|
+
"command": "npx",
|
|
68
|
+
"args": ["-y", "tempmail-mcp"],
|
|
69
|
+
"env": {
|
|
70
|
+
"MAILDROP_API_KEY": "你的-maildrop-api-key",
|
|
71
|
+
"MAILCX_API_TOKEN": "你的-mailcx-api-token"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
如果只需要免费服务商(无需 API Key),直接省略 `env` 块即可。
|
|
79
|
+
|
|
80
|
+
**没有 API Key?** 使用 `auto_register` 工具自动获取免费的 MailDrop 或 mail.cx API Key — **无需浏览器**,纯 HTTP API 调用。参见下方的[自动注册](#auto_register)。
|
|
81
|
+
|
|
82
|
+
## 可用工具
|
|
83
|
+
|
|
84
|
+
### `list_providers`
|
|
85
|
+
|
|
86
|
+
列出所有可用的临时邮箱服务商及其能力。
|
|
87
|
+
|
|
88
|
+
### `get_domains`
|
|
89
|
+
|
|
90
|
+
获取指定服务商的可用邮箱域名列表。
|
|
91
|
+
|
|
92
|
+
- **provider**(可选,默认 `"mail.tm"`):服务商名称。
|
|
93
|
+
|
|
94
|
+
### `create_mailbox`
|
|
95
|
+
|
|
96
|
+
创建一个新的临时邮箱。
|
|
97
|
+
|
|
98
|
+
- **provider**(可选,默认 `"mail.tm"`):服务商名称。
|
|
99
|
+
- **username**(可选):首选用户名(邮箱本地部分)。
|
|
100
|
+
- **domain**(可选):首选域名。
|
|
101
|
+
|
|
102
|
+
### `get_messages`
|
|
103
|
+
|
|
104
|
+
获取邮箱收到的邮件列表。
|
|
105
|
+
|
|
106
|
+
- **address**:临时邮箱地址。
|
|
107
|
+
|
|
108
|
+
### `get_message`
|
|
109
|
+
|
|
110
|
+
获取特定邮件的完整内容。
|
|
111
|
+
|
|
112
|
+
- **address**:临时邮箱地址。
|
|
113
|
+
- **messageId**:邮件 ID(来自 `get_messages`)。
|
|
114
|
+
|
|
115
|
+
### `wait_for_email`
|
|
116
|
+
|
|
117
|
+
阻塞直到收到匹配的邮件。返回第一条匹配的邮件。
|
|
118
|
+
|
|
119
|
+
- **address**:临时邮箱地址。
|
|
120
|
+
- **subjectContains**(可选):按邮件主题子串过滤。
|
|
121
|
+
- **fromContains**(可选):按发件人子串过滤。
|
|
122
|
+
- **timeoutMs**(可选,默认 `60000`):超时时间(毫秒)。
|
|
123
|
+
- **pollIntervalMs**(可选,默认 `3000`):轮询间隔(毫秒)。
|
|
124
|
+
|
|
125
|
+
### `get_verification_code`
|
|
126
|
+
|
|
127
|
+
等待验证邮件并自动提取验证码。
|
|
128
|
+
|
|
129
|
+
- **address**:临时邮箱地址。
|
|
130
|
+
- **subjectContains**(可选):过滤器(如 `"verification"`、`"confirm"`、`"code"`)。
|
|
131
|
+
- **fromContains**(可选):按发件人过滤。
|
|
132
|
+
- **timeoutMs**(可选,默认 `60000`):超时时间(毫秒)。
|
|
133
|
+
|
|
134
|
+
### `list_mailboxes`
|
|
135
|
+
|
|
136
|
+
列出当前会话中创建的所有临时邮箱。
|
|
137
|
+
|
|
138
|
+
### `delete_mailbox`
|
|
139
|
+
|
|
140
|
+
删除临时邮箱及其所有邮件。
|
|
141
|
+
|
|
142
|
+
- **address**:临时邮箱地址。
|
|
143
|
+
|
|
144
|
+
### `auto_register`
|
|
145
|
+
|
|
146
|
+
自动注册账号并获取服务商的 API Key/Token。**纯 HTTP API — 无浏览器、无 Puppeteer。**
|
|
147
|
+
|
|
148
|
+
#### `maildrop`
|
|
149
|
+
|
|
150
|
+
使用 RSA 密钥生成 + HTTP API:
|
|
151
|
+
|
|
152
|
+
1. 生成 RSA 2048 密钥对(Node.js `crypto` 模块)
|
|
153
|
+
2. `POST /api/register.php` 提交公钥注册账号
|
|
154
|
+
3. 签名 `timestamp-username` 生成 passcode
|
|
155
|
+
4. `POST /api/login.php` 登录认证
|
|
156
|
+
5. `POST /api/account/keys.php` 创建 API Key(`md_...`)
|
|
157
|
+
|
|
158
|
+
#### `mail.cx`
|
|
159
|
+
|
|
160
|
+
使用 magic-link 登录流程:
|
|
161
|
+
|
|
162
|
+
1. 通过 mail.tm 创建临时邮箱(无需 API Key)
|
|
163
|
+
2. `POST /v1/auth/magic-link/request` 发送 magic link 到临时邮箱
|
|
164
|
+
3. 轮询 mail.tm 等待 magic link 邮件
|
|
165
|
+
4. `POST /v1/auth/magic-link/verify` 提交 token — **直接返回 API Token**(`tm_live_...`)
|
|
166
|
+
|
|
167
|
+
**参数:**
|
|
168
|
+
|
|
169
|
+
- **provider**(必填):`"maildrop"` 或 `"mail.cx"`
|
|
170
|
+
- **tokenName**(可选,默认 `"tempmail-mcp"`):Token 名称(仅 mail.cx)。
|
|
171
|
+
- **username**(可选):账号用户名(仅 maildrop)。
|
|
172
|
+
- **timeoutMs**(可选,默认 `120000`):总超时时间(毫秒)。
|
|
173
|
+
|
|
174
|
+
返回 API Key/Token 并在当前会话中自动注册该服务商。要永久生效,请设置对应的环境变量(`MAILDROP_API_KEY` 或 `MAILCX_API_TOKEN`)。
|
|
175
|
+
|
|
176
|
+
## 使用示例
|
|
177
|
+
|
|
178
|
+
### 自动注册获取免费 API Key
|
|
179
|
+
|
|
180
|
+
**MailDrop**(快速,约 2 秒):
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
1. auto_register (provider: "maildrop")
|
|
184
|
+
→ { apiKey: "md_...", email: "tmp_xxx@maildrop.cc", ... }
|
|
185
|
+
|
|
186
|
+
2. [在 MCP 配置中设置 MAILDROP_API_KEY=md_...]
|
|
187
|
+
|
|
188
|
+
3. list_providers
|
|
189
|
+
→ 服务商列表中现在包含 "maildrop"!
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**mail.cx**(约 15-30 秒,需要等待邮件):
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
1. auto_register (provider: "mail.cx")
|
|
196
|
+
→ { apiKey: "tm_live_...", email: "abc@emalupe.com", ... }
|
|
197
|
+
|
|
198
|
+
2. [在 MCP 配置中设置 MAILCX_API_TOKEN=tm_live_...]
|
|
199
|
+
|
|
200
|
+
3. list_providers
|
|
201
|
+
→ 服务商列表中现在包含 "mail.cx"!
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
注册后两个服务商在当前会话中立即可用 — 无需重启。
|
|
205
|
+
|
|
206
|
+
### 典型注册验证流程
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
1. create_mailbox (provider: "mail.tm")
|
|
210
|
+
→ { address: "abc123@somedomain.com", ... }
|
|
211
|
+
|
|
212
|
+
2. [在目标网站上使用临时邮箱地址注册]
|
|
213
|
+
|
|
214
|
+
3. get_verification_code (address: "abc123@somedomain.com", subjectContains: "verification")
|
|
215
|
+
→ { code: "829451", from: "noreply@example.com", subject: "Your verification code", ... }
|
|
216
|
+
|
|
217
|
+
4. [在目标网站上输入验证码完成注册]
|
|
218
|
+
|
|
219
|
+
5. delete_mailbox (address: "abc123@somedomain.com")
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### 手动查看邮件
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
1. create_mailbox (provider: "guerrillamail", username: "mytest")
|
|
226
|
+
→ { address: "mytest@guerrillamailblock.com", ... }
|
|
227
|
+
|
|
228
|
+
2. get_messages (address: "mytest@guerrillamailblock.com")
|
|
229
|
+
→ { count: 2, messages: [{ id: "1", from: "...", subject: "..." }, ...] }
|
|
230
|
+
|
|
231
|
+
3. get_message (address: "mytest@guerrillamailblock.com", messageId: "1")
|
|
232
|
+
→ { id: "1", from: "...", subject: "...", bodyText: "...", bodyHtml: "..." }
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## 开发
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
# 安装依赖
|
|
239
|
+
npm install
|
|
240
|
+
|
|
241
|
+
# 编译
|
|
242
|
+
npm run build
|
|
243
|
+
|
|
244
|
+
# 本地运行
|
|
245
|
+
node dist/index.js
|
|
246
|
+
|
|
247
|
+
# 监听模式
|
|
248
|
+
npm run dev
|
|
249
|
+
|
|
250
|
+
# 测试自动注册
|
|
251
|
+
node test-auto-register-api.mjs maildrop # 仅测试 MailDrop
|
|
252
|
+
node test-auto-register-api.mjs mailcx # 仅测试 mail.cx
|
|
253
|
+
node test-auto-register-api.mjs all # 测试全部
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## 架构
|
|
257
|
+
|
|
258
|
+
```
|
|
259
|
+
┌──────────────────────────────────────────────────────┐
|
|
260
|
+
│ MCP 客户端 (Claude) │
|
|
261
|
+
│ │ │
|
|
262
|
+
│ stdio / Streamable HTTP │
|
|
263
|
+
│ ▼ │
|
|
264
|
+
│ ┌──────────────────────┐ │
|
|
265
|
+
│ │ TempMail MCP 服务器 │ │
|
|
266
|
+
│ │ │ │
|
|
267
|
+
│ │ ┌─── 工具 ────────┐ │ │
|
|
268
|
+
│ │ │ create_mailbox │ │ │
|
|
269
|
+
│ │ │ get_messages │ │ │
|
|
270
|
+
│ │ │ wait_for_email │ │ │
|
|
271
|
+
│ │ │ get_verification │ │ │
|
|
272
|
+
│ │ │ auto_register │ │ │
|
|
273
|
+
│ │ │ ... │ │ │
|
|
274
|
+
│ │ └──────────────────┘ │ │
|
|
275
|
+
│ └──────────┬───────────┘ │
|
|
276
|
+
│ │ │
|
|
277
|
+
│ ┌──────────▼───────────┐ │
|
|
278
|
+
│ │ 服务商管理器 │ │
|
|
279
|
+
│ │ (适配器模式) │ │
|
|
280
|
+
│ └──────────┬───────────┘ │
|
|
281
|
+
│ │ │
|
|
282
|
+
│ ┌────────┬────────┼────────┬──────────┐ │
|
|
283
|
+
│ ▼ ▼ ▼ ▼ ▼ │
|
|
284
|
+
│ Mail.tm Guerrilla 1secmail Catchmail MailDrop │
|
|
285
|
+
│ Mail Mail.cx │
|
|
286
|
+
└──────────────────────────────────────────────────────┘
|
|
287
|
+
|
|
288
|
+
自动注册流程(纯 HTTP,无浏览器):
|
|
289
|
+
┌───────────────┐ ┌───────────────┐
|
|
290
|
+
│ MailDrop │ │ mail.cx │
|
|
291
|
+
│ │ │ │
|
|
292
|
+
│ RSA 密钥生成 │ │ mail.tm 临时 │
|
|
293
|
+
│ ↓ │ │ 邮箱 │
|
|
294
|
+
│ POST 注册 │ │ ↓ │
|
|
295
|
+
│ ↓ │ │ POST magic │
|
|
296
|
+
│ RSA 签名 │ │ link 请求 │
|
|
297
|
+
│ ↓ │ │ ↓ │
|
|
298
|
+
│ POST 登录 │ │ 轮询等待邮件 │
|
|
299
|
+
│ ↓ │ │ ↓ │
|
|
300
|
+
│ POST 创建 │ │ POST verify │
|
|
301
|
+
│ API Key │ │ → API Token │
|
|
302
|
+
│ → md_... │ │ → tm_live_... │
|
|
303
|
+
└───────────────┘ └───────────────┘
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## 许可证
|
|
307
|
+
|
|
308
|
+
MIT
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TempMailProvider, TempMailbox, EmailMessage, CreateMailboxParams, WaitForEmailOptions } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class that implements the common waitForEmail polling logic.
|
|
4
|
+
* Provider adapters extend this and only need to implement the core methods.
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class BaseProvider implements TempMailProvider {
|
|
7
|
+
abstract name: string;
|
|
8
|
+
abstract description: string;
|
|
9
|
+
abstract requiresApiKey: boolean;
|
|
10
|
+
abstract getDomains(): Promise<string[]>;
|
|
11
|
+
abstract createMailbox(params: CreateMailboxParams): Promise<TempMailbox>;
|
|
12
|
+
abstract getMessages(mailbox: TempMailbox): Promise<EmailMessage[]>;
|
|
13
|
+
abstract getMessage(mailbox: TempMailbox, messageId: string): Promise<EmailMessage>;
|
|
14
|
+
deleteMailbox(mailbox: TempMailbox): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Default implementation: poll getMessages until a matching email arrives
|
|
17
|
+
* or the timeout expires.
|
|
18
|
+
*/
|
|
19
|
+
waitForEmail(mailbox: TempMailbox, options?: WaitForEmailOptions): Promise<EmailMessage>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=base-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-provider.d.ts","sourceRoot":"","sources":["../src/base-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAGpB;;;GAGG;AACH,8BAAsB,YAAa,YAAW,gBAAgB;IAC5D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IAEjC,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC;IACzE,QAAQ,CAAC,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IACnE,QAAQ,CAAC,UAAU,CACjB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,YAAY,CAAC;IAElB,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAKxD;;;OAGG;IACG,YAAY,CAChB,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,YAAY,CAAC;CA4BzB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { sleep, mergeWaitOptions, messageMatches } from "./utils.js";
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class that implements the common waitForEmail polling logic.
|
|
4
|
+
* Provider adapters extend this and only need to implement the core methods.
|
|
5
|
+
*/
|
|
6
|
+
export class BaseProvider {
|
|
7
|
+
async deleteMailbox(mailbox) {
|
|
8
|
+
// Default: no-op. Override in subclass if the provider supports deletion.
|
|
9
|
+
void mailbox;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Default implementation: poll getMessages until a matching email arrives
|
|
13
|
+
* or the timeout expires.
|
|
14
|
+
*/
|
|
15
|
+
async waitForEmail(mailbox, options) {
|
|
16
|
+
const opts = mergeWaitOptions(options);
|
|
17
|
+
const deadline = Date.now() + opts.timeoutMs;
|
|
18
|
+
while (Date.now() < deadline) {
|
|
19
|
+
const messages = await this.getMessages(mailbox);
|
|
20
|
+
for (const msg of messages) {
|
|
21
|
+
if (messageMatches(msg, opts.subjectContains, opts.fromContains)) {
|
|
22
|
+
// Fetch the full message body
|
|
23
|
+
const full = await this.getMessage(mailbox, msg.id);
|
|
24
|
+
if (messageMatches(full, opts.subjectContains, opts.fromContains)) {
|
|
25
|
+
return full;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
await sleep(opts.pollIntervalMs);
|
|
30
|
+
}
|
|
31
|
+
throw new Error(`Timed out after ${opts.timeoutMs / 1000}s waiting for email` +
|
|
32
|
+
(opts.subjectContains ? ` matching subject "${opts.subjectContains}"` : "") +
|
|
33
|
+
(opts.fromContains ? ` from "${opts.fromContains}"` : ""));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=base-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-provider.js","sourceRoot":"","sources":["../src/base-provider.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAErE;;;GAGG;AACH,MAAM,OAAgB,YAAY;IAahC,KAAK,CAAC,aAAa,CAAC,OAAoB;QACtC,0EAA0E;QAC1E,KAAK,OAAO,CAAC;IACf,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,YAAY,CAChB,OAAoB,EACpB,OAA6B;QAE7B,MAAM,IAAI,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QAE7C,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;YAC7B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YAEjD,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;gBAC3B,IAAI,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;oBACjE,8BAA8B;oBAC9B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;oBACpD,IACE,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,YAAY,CAAC,EAC7D,CAAC;wBACD,OAAO,IAAI,CAAC;oBACd,CAAC;gBACH,CAAC;YACH,CAAC;YAED,MAAM,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACnC,CAAC;QAED,MAAM,IAAI,KAAK,CACb,mBAAmB,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAqB;YAC3D,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,sBAAsB,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3E,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAC5D,CAAC;IACJ,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|