Metadata-Version: 2.3
Name: emails-mcp-server
Version: 0.1.0.dev2+g8f32098
Summary: Temporary email MCP server built with FastMCP
Author: luofengyuan
Author-email: luofengyuan <3562033221@qq.com>
Requires-Dist: fastmcp>=3.2.0
Requires-Dist: httpx>=0.28.1
Requires-Dist: pydantic>=2.12.0
Requires-Dist: pydantic-settings>=2.10.0
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# emails-mcp-server

临时邮箱 MCP 服务，基于 **uv + FastMCP + src package layout**。

首版范围（v1）：
- Provider（稳定五家）：`guerrilla` / `mailgw` / `mailtm` / `gptmail` / `outlook`
- 统一工具 + provider 原生工具
- 会话句柄（`session_id`）驱动收件流程
- `stdio` 与 `streamable-http` 双传输

## 1. 快速开始

```bash
uv sync --dev
cp .env.example .env
uv run emails-mcp-server --transport stdio
```

HTTP 模式：

```bash
uv run emails-mcp-server --transport streamable-http --host 0.0.0.0 --port 8000 --path /mcp
```

## 2. 统一 MCP 工具

- `email_available_providers`
- `email_get_capabilities`
- `email_create_inbox`
- `email_list_messages`
- `email_read_message`
- `email_wait_for_messages`
- `email_read_latest`
- `email_close_session`

### 关键行为

- 默认通过 `session_id` 追踪 provider 的 token/cookie/session
- `include_raw=false`（默认）不返回原始 HTTP 报文
- `include_raw=true` 才返回排障证据（已对敏感头和敏感 body 字段脱敏）
- 会话默认 TTL 30 分钟（`EMAIL_MCP_SESSION_TTL_MINUTES` 可调）

## 3. Provider 原生工具

每个 provider 都有三类原生工具（create/list/read）：

- Guerrilla: `guerrilla_create_inbox`, `guerrilla_list_messages`, `guerrilla_read_message`
- Mail.gw: `mailgw_create_inbox`, `mailgw_list_messages`, `mailgw_read_message`
- Mail.tm: `mailtm_create_inbox`, `mailtm_list_messages`, `mailtm_read_message`
- GPTMail: `gptmail_create_inbox`, `gptmail_list_messages`, `gptmail_read_message`
- Outlook: `outlook_create_inbox`, `outlook_list_messages`, `outlook_read_message`

Outlook 额外原生工具（业务动作）：

- 分组与池管理：
  - `outlook_create_group`
  - `outlook_delete_group`
  - `outlook_list_group_usage`
  - `outlook_add_mailbox`
  - `outlook_get_available_mailbox`
  - `outlook_get_mailbox_status`
  - `outlook_trigger_mailbox_validations`
- 邮件动作：
  - `outlook_get_latest_mail`
  - `outlook_get_all_mails`
  - `outlook_clear_inbox`
  - `outlook_clear_junk`
  - `outlook_send_mail`

> `provider` 传参支持 `outlook`，并兼容别名 `outllook`。
>
> 删除分组时需传 `business_id`；可先通过 `outlook_list_group_usage` 获取对应 id。

Outlook 环境变量：

- `EMAIL_MCP_OUTLOOK_HELPER_BASE_URL`
- `EMAIL_MCP_OUTLOOK_OAUTH2_BASE_URL`
- `EMAIL_MCP_OUTLOOK_HELPER_API_KEY`
- `EMAIL_MCP_OUTLOOK_PASSWORD`（可选）
- `EMAIL_MCP_OUTLOOK_SEND_PASSWORD`（可选）

## 4. 开发与测试

```bash
uv run ruff check .
uv run mypy src
uv run pytest -q
uv build
```

## 5. GitHub Actions -> Gitea

### CI (`.github/workflows/ci.yml`)
- push / pull_request 触发
- 运行 lint + typecheck + tests + build

### Release (`.github/workflows/release-gitea.yml`)
- `main` 每次 push 自动触发（也支持手动触发）
- 自动将版本改写为 `0.1.0.dev<run_number>` 形式后发布
- 发布 wheel/sdist 到 Gitea PyPI
- 镜像仓库分支 + tags 到 Gitea

### 需要的 GitHub Secrets（沿用既有命名）
- `GITEA_PYPI_PUBLISH_URL`
- `GITEA_PYPI_CHECK_URL`（可选）
- `GITEA_USERNAME`
- `GITEA_PAT`
- `GITEA_MIRROR_REPO_URL`

## 6. 参考文档

- FastMCP:
  - https://gofastmcp.com/getting-started/installation
  - https://gofastmcp.com/getting-started/quickstart
- MCP server:
  - https://modelcontextprotocol.io/docs/develop/build-server
  - https://github.com/modelcontextprotocol/python-sdk
- scaffold 参考：
  - https://pypi.org/project/create-mcp-server/
