内容
`@supercorp/gmail-mcp` 是一个 Gmail MCP server。
## 安装和使用
仅使用必需的标志通过 `npx` 运行:
```bash
npx @supercorp/gmail-mcp \
--googleClientId <string> \
--googleClientSecret <string> \
--googleRedirectUri <string>
```
所有其他选项都可以在下表中调整。
## CLI 参数
| Flag | Type | Default | Description |
|---------------------------|--------------------------|--------------------|-----------------------------------------------------------------------------------------------------------------------|
| `--googleClientId` | _string_ _(required)_ | N/A | 你的 Google OAuth 客户端 ID。 |
| `--googleClientSecret` | _string_ _(required)_ | N/A | 你的 Google OAuth 客户端密钥。 |
| `--googleRedirectUri` | _string_ _(required)_ | N/A | 在 Google Cloud Console 中注册的 OAuth 2.0 重定向 URI。 |
| `--port` | _number_ | `8000` | HTTP/SSE 模式的 TCP 端口。 |
| `--transport` | `sse` or `stdio` | `sse` | MCP 传输方式:<br>• `sse`: HTTP server + Server-Sent Events<br>• `stdio`: stdin/stdout 上的 JSON-RPC |
| `--storage` | see below | `memory-single` | OAuth 令牌的持久性后端:<br>• `memory-single`: 单用户内存存储(无 header key)<br>• `memory`: 多用户内存存储<br>• `upstash-redis-rest`: 通过 Upstash Redis REST API 持久存储 |
| `--storageHeaderKey` | _string_ _(conditional)_ | _none_ | 使用 `memory` 或 `upstash-redis-rest` 时,用于标识用户的 HTTP header 名称(或 Redis 密钥前缀)。 |
| `--upstashRedisRestUrl` | _string_ _(conditional)_ | _none_ | Upstash Redis REST URL(如果 `--storage=upstash-redis-rest` 则为必填项)。 |
| `--upstashRedisRestToken` | _string_ _(conditional)_ | _none_ | Upstash Redis REST 令牌(如果 `--storage=upstash-redis-rest` 则为必填项)。 |
| `--sendOnly` | _boolean_ | `false` | 如果设置,则仅公开 `gmail.send` 工具(无读取/草稿功能)。 |
| `--googleState` | _string_ _(optional)_ | _none_ | 转发到 Google 的可选 OAuth 状态参数。 |
### Storage Backends
- **memory-single**: 单用户内存存储(快速演示;重启时数据丢失)
- **memory**: 多用户内存存储(需要 `--storageHeaderKey`)
- **upstash-redis-rest**: 通过 Upstash Redis REST 持久存储(需要 `--storageHeaderKey`、`--upstashRedisRestUrl`、`--upstashRedisRestToken`)
### Transports
- **stdio**
stdin/stdout 上的 JSON-RPC。
- **sse**
HTTP server + Server-Sent Events:
- Subscribe: `GET http://localhost:<port>/`
- Send: `POST http://localhost:<port>/message?sessionId=<session-id>`
## Exposed MCP Methods
| Tool | Description |
|----------------------|---------------------------------------------------------------------------------------------------------------------|
| `auth_url` | 返回 Gmail OAuth 授权 URL。 |
| `exchange_auth_code` | 交换 OAuth 代码以获取刷新令牌并存储它。 |
| `list_emails` | 列出 Gmail 邮件 (`maxResults`, `labelIds`, `query`, `pageToken`, `unreadOnly`)。 |
| `read_email` | 通过 ID 检索完整邮件,将 HTML 正文转换为 Markdown。 |
| `list_drafts` | 列出 Gmail 草稿 (`maxResults`, `query`)。 |
| `read_draft` | 按 ID(完整)读取单个草稿。 |
| `draft_email` | 创建新草稿 (`sender`, `to`, `cc?`, `bcc?`, `subject`, `body`, `isHtml?`)。 |
| `update_draft` | 按 ID 更新现有草稿。 |
| `delete_draft` | 按 ID 删除草稿。 |
| `send_email` | 发送电子邮件(如果提供了 `draftId`,则通过新的或现有的草稿发送)。 在仅发送模式下,这是唯一的工具。 |