@marlinjai/email-mcp 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 marlinjai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,211 @@
1
+ # @marlinjai/email-mcp
2
+
3
+ A unified MCP server for email access across Gmail, Outlook, iCloud, and generic IMAP providers.
4
+
5
+ ## Features
6
+
7
+ - **Multi-provider support** -- Gmail (REST API), Outlook (Microsoft Graph), iCloud (IMAP), and generic IMAP/SMTP
8
+ - **OAuth2 authentication** -- Browser-based OAuth flows for Gmail and Outlook, with automatic token refresh
9
+ - **Full email client** -- Search, read, send, reply, forward, organize, and manage drafts
10
+ - **Batch operations** -- Delete, move, or mark hundreds of emails in a single call
11
+ - **Lightweight search** -- Compact search results by default (~20KB vs ~1.4MB) with optional full body retrieval
12
+ - **Encrypted credential storage** -- AES-256-GCM encryption at rest with machine-derived keys
13
+ - **Provider-native APIs** -- Uses Gmail API and Microsoft Graph where available for richer features, falls back to IMAP for universal compatibility
14
+
15
+ ## Installation
16
+
17
+ Install globally from npm:
18
+
19
+ ```bash
20
+ npm install -g @marlinjai/email-mcp
21
+ ```
22
+
23
+ Or run directly with npx (no install needed):
24
+
25
+ ```bash
26
+ npx @marlinjai/email-mcp
27
+ ```
28
+
29
+ ## Quick Start
30
+
31
+ 1. Run the interactive setup wizard to add your email accounts:
32
+
33
+ ```bash
34
+ npx @marlinjai/email-mcp setup
35
+ ```
36
+
37
+ The wizard will walk you through provider selection and authentication. After each account, it asks if you'd like to add another — so you can set up Gmail, Outlook, and iCloud all in one go.
38
+
39
+ 2. Add the server to your MCP configuration (`.mcp.json`):
40
+
41
+ ```json
42
+ {
43
+ "mcpServers": {
44
+ "email": {
45
+ "command": "npx",
46
+ "args": ["@marlinjai/email-mcp"]
47
+ }
48
+ }
49
+ }
50
+ ```
51
+
52
+ 3. Start using email tools in Claude Code — search your inbox, send emails, organize messages, and more.
53
+
54
+ ## Provider Setup Guides
55
+
56
+ ### Gmail
57
+
58
+ 1. Go to the [Google Cloud Console](https://console.cloud.google.com/).
59
+ 2. Create a new project (or select an existing one).
60
+ 3. Enable the **Gmail API** under APIs & Services.
61
+ 4. Go to **Credentials** and create an **OAuth 2.0 Client ID** (Desktop application type).
62
+ 5. Run the setup wizard:
63
+
64
+ ```bash
65
+ npx @marlinjai/email-mcp setup
66
+ # Select "Gmail" when prompted
67
+ # A browser window will open for authorization
68
+ # Grant the requested permissions and return to the terminal
69
+ ```
70
+
71
+ ### Outlook
72
+
73
+ 1. Go to the [Azure Portal](https://portal.azure.com/) and navigate to **App registrations**.
74
+ 2. Register a new application (select "Personal Microsoft accounts" for consumer Outlook).
75
+ 3. Under **Authentication**, add a redirect URI for `http://localhost`.
76
+ 4. Under **API permissions**, add `Mail.ReadWrite`, `Mail.Send`, and `offline_access`.
77
+ 5. Run the setup wizard:
78
+
79
+ ```bash
80
+ npx @marlinjai/email-mcp setup
81
+ # Select "Outlook" when prompted
82
+ # A browser window will open for authorization
83
+ # Sign in and grant the requested permissions
84
+ ```
85
+
86
+ ### iCloud
87
+
88
+ 1. Go to [appleid.apple.com](https://appleid.apple.com/) and sign in.
89
+ 2. Navigate to **App-Specific Passwords** and generate a new password.
90
+ 3. Run the setup wizard:
91
+
92
+ ```bash
93
+ npx @marlinjai/email-mcp setup
94
+ # Select "iCloud" when prompted
95
+ # Enter your iCloud email address
96
+ # Enter the app-specific password you generated
97
+ ```
98
+
99
+ ### Generic IMAP
100
+
101
+ Run the setup wizard with your IMAP/SMTP server details:
102
+
103
+ ```bash
104
+ npx @marlinjai/email-mcp setup
105
+ # Select "Other IMAP" when prompted
106
+ # Enter your IMAP host, port, and credentials
107
+ # Optionally enter SMTP host and port for sending
108
+ ```
109
+
110
+ ## Available Tools (24)
111
+
112
+ ### Account Management (4)
113
+
114
+ | Tool | Description |
115
+ |------|-------------|
116
+ | `email_list_accounts` | List all configured accounts with connection status |
117
+ | `email_add_account` | Add a new IMAP or iCloud account (Gmail/Outlook require setup wizard) |
118
+ | `email_remove_account` | Remove an account and its stored credentials |
119
+ | `email_test_account` | Test connection to an account |
120
+
121
+ ### Reading & Searching (5)
122
+
123
+ | Tool | Description |
124
+ |------|-------------|
125
+ | `email_list_folders` | List all folders/labels for an account |
126
+ | `email_search` | Search emails with filters. Returns compact results by default (`returnBody=false`). Set `returnBody=true` to include full email bodies |
127
+ | `email_get` | Get full email content by ID (headers, body, attachment metadata) |
128
+ | `email_get_thread` | Get an entire email thread/conversation |
129
+ | `email_get_attachment` | Download a specific attachment by ID (returns base64 data) |
130
+
131
+ ### Sending & Drafts (5)
132
+
133
+ | Tool | Description |
134
+ |------|-------------|
135
+ | `email_send` | Compose and send a new email (to, cc, bcc, subject, body) |
136
+ | `email_reply` | Reply to an email (supports reply-all, preserves threading) |
137
+ | `email_forward` | Forward an email to new recipients |
138
+ | `email_draft_create` | Save a draft without sending |
139
+ | `email_draft_list` | List all drafts |
140
+
141
+ ### Organization (7)
142
+
143
+ | Tool | Description |
144
+ |------|-------------|
145
+ | `email_move` | Move an email to a different folder. Supports `sourceFolder` for IMAP/iCloud |
146
+ | `email_delete` | Delete an email (trash or permanent). Supports `sourceFolder` for IMAP/iCloud |
147
+ | `email_mark` | Mark as read/unread, starred, or flagged. Supports `sourceFolder` for IMAP/iCloud |
148
+ | `email_label` | Add/remove labels (Gmail only) |
149
+ | `email_folder_create` | Create a new folder |
150
+ | `email_get_labels` | List all labels with counts (Gmail only) |
151
+ | `email_get_categories` | List all categories (Outlook only) |
152
+
153
+ ### Batch Operations (3)
154
+
155
+ | Tool | Description |
156
+ |------|-------------|
157
+ | `email_batch_delete` | Delete multiple emails at once (up to 1000 for Gmail, batches of 20 for Outlook, UID ranges for IMAP) |
158
+ | `email_batch_move` | Move multiple emails to a folder in a single call |
159
+ | `email_batch_mark` | Mark multiple emails read/unread, starred, or flagged at once |
160
+
161
+ All batch tools accept a `sourceFolder` parameter for IMAP/iCloud and include a sequential fallback for maximum compatibility.
162
+
163
+ ## Usage with Claude Code
164
+
165
+ Add the following to your `.mcp.json` file (project-level or global `~/.claude/.mcp.json`):
166
+
167
+ ```json
168
+ {
169
+ "mcpServers": {
170
+ "email": {
171
+ "command": "npx",
172
+ "args": ["@marlinjai/email-mcp"]
173
+ }
174
+ }
175
+ }
176
+ ```
177
+
178
+ Once configured, you can ask Claude to interact with your email:
179
+
180
+ - "Check my inbox for unread messages"
181
+ - "Search for emails from alice@example.com in the last week"
182
+ - "Reply to the latest email from Bob and thank him"
183
+ - "Move all newsletters to the Archive folder"
184
+ - "Delete all spam emails" (uses batch operations for speed)
185
+ - "Draft a follow-up email to the team about the meeting"
186
+
187
+ ## Development
188
+
189
+ ```bash
190
+ # Install dependencies
191
+ pnpm install
192
+
193
+ # Build the project
194
+ pnpm build
195
+
196
+ # Run in development mode (watch for changes)
197
+ pnpm dev
198
+
199
+ # Run tests
200
+ pnpm test
201
+
202
+ # Run tests in watch mode
203
+ pnpm test:watch
204
+
205
+ # Run integration tests (requires real email accounts)
206
+ pnpm test:integration
207
+ ```
208
+
209
+ ## License
210
+
211
+ MIT