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:
ty
2026-06-15 23:52:35 +08:00
parent bf51e843ee
commit b99b872791
31 changed files with 771 additions and 115 deletions

View File

@@ -31,6 +31,7 @@
<a href="#webhook-integration">Webhook Integration</a> •
<a href="#openapi">OpenAPI</a> •
<a href="#cli-tool">CLI Tool</a> •
<a href="#mcp-server">MCP Server</a> •
<a href="#environment-variables">Environment Variables</a> •
<a href="#github-oauth-app-configuration">Github OAuth Config</a> •
<a href="#google-oauth-app-configuration">Google OAuth Config</a> •
@@ -555,13 +556,25 @@ moemail config set api-key YOUR_API_KEY
# Create temporary email
moemail create --domain moemail.app --expiry 1h --json
# List mailboxes
moemail list --json
# List messages in a mailbox
moemail list --email-id <id> --json
# Wait for new messages (polling)
moemail wait --email-id <id> --timeout 120 --json
# Read message content
moemail read --email-id <id> --message-id <id> --json
# Delete email
# Send an email from the temporary address
moemail send --email-id <id> --to user@example.com --subject "Hello" --content "Body text" --json
# Delete a single message
moemail delete --email-id <id> --message-id <id>
# Delete the whole mailbox
moemail delete --email-id <id>
```
@@ -598,6 +611,47 @@ moemail skill install --platform codex
For full documentation, see [packages/cli/README.md](packages/cli/README.md).
## MCP Server
MoeMail also ships an [MCP](https://modelcontextprotocol.io) server, so any
MCP-capable client (Claude Desktop, Cursor, Cline, …) gets native temporary-email
tools without shelling out to the CLI.
### Tools
| Tool | Description |
|------|-------------|
| `create_email` | Create a temporary mailbox (`1h` / `24h` / `3d` / `permanent`) |
| `list_emails` | List mailboxes owned by the API key |
| `list_messages` | List messages in a mailbox |
| `read_message` | Read full text/HTML of a message |
| `wait_for_email` | Poll for a new message (bounded; returns `status: "timeout"` to retry) |
| `send_email` | Send from a temporary address |
| `delete_email` | Delete a mailbox |
| `delete_message` | Delete a single message |
### Setup
Add the server to your MCP client config (e.g. Claude Desktop `claude_desktop_config.json`).
Credentials are passed via environment variables:
```json
{
"mcpServers": {
"moemail": {
"command": "npx",
"args": ["-y", "@moemail/mcp"],
"env": {
"MOEMAIL_API_KEY": "YOUR_API_KEY",
"MOEMAIL_API_URL": "https://moemail.app"
}
}
}
}
```
For full documentation, see [packages/mcp/README.md](packages/mcp/README.md).
## Environment Variables
### Authentication