mcp-mail-server 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) 2025 Euan Zhu
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,261 @@
1
+ # MCP Mail Server
2
+
3
+ **Language:** English | [δΈ­ζ–‡](README-zh.md)
4
+
5
+ A Model Context Protocol (MCP) server that enables email operations through POP3 and SMTP protocols in Cursor AI. Features secure environment-based configuration for seamless email management.
6
+
7
+ ### ✨ Features
8
+
9
+ #### πŸ“₯ POP3 Features (Receive Emails)
10
+ - Connect to POP3 email servers
11
+ - User authentication with TLS support
12
+ - List all messages in mailbox
13
+ - Retrieve specific email content
14
+ - Delete messages from server
15
+ - Get total message count
16
+ - Secure connection management
17
+
18
+ #### πŸ“€ SMTP Features (Send Emails)
19
+ - Connect to SMTP email servers
20
+ - Send emails (text and HTML formats)
21
+ - Support for CC and BCC recipients
22
+ - SSL/TLS encryption support
23
+ - Comprehensive error handling
24
+
25
+ ### πŸ“¦ Installation
26
+
27
+ #### Method 1: Install via npm
28
+ ```bash
29
+ npm install -g mcp-mail-server
30
+ ```
31
+
32
+ #### Method 2: Use with npx (Recommended)
33
+ No installation required:
34
+ ```bash
35
+ npx mcp-mail-server
36
+ ```
37
+
38
+ ### βš™οΈ Cursor Configuration
39
+
40
+ Add the following configuration to your Cursor MCP settings:
41
+
42
+ #### Using npx (Recommended):
43
+ ```json
44
+ {
45
+ "mcpServers": {
46
+ "mcp-mail-server": {
47
+ "command": "npx",
48
+ "args": ["mcp-mail-server"],
49
+ "env": {
50
+ "POP3_HOST": "your-pop3-server.com",
51
+ "POP3_PORT": "995",
52
+ "POP3_SECURE": "true",
53
+ "SMTP_HOST": "your-smtp-server.com",
54
+ "SMTP_PORT": "465",
55
+ "SMTP_SECURE": "true",
56
+ "EMAIL_USER": "your-email@domain.com",
57
+ "EMAIL_PASS": "your-password"
58
+ }
59
+ }
60
+ }
61
+ }
62
+ ```
63
+
64
+ #### Using global installation:
65
+ ```json
66
+ {
67
+ "mcpServers": {
68
+ "mcp-mail-server": {
69
+ "command": "mcp-mail-server",
70
+ "env": {
71
+ "POP3_HOST": "your-pop3-server.com",
72
+ "POP3_PORT": "995",
73
+ "POP3_SECURE": "true",
74
+ "SMTP_HOST": "your-smtp-server.com",
75
+ "SMTP_PORT": "465",
76
+ "SMTP_SECURE": "true",
77
+ "EMAIL_USER": "your-email@domain.com",
78
+ "EMAIL_PASS": "your-password"
79
+ }
80
+ }
81
+ }
82
+ }
83
+ ```
84
+
85
+ ### πŸ› οΈ Available Tools
86
+
87
+ #### `connect_pop3`
88
+ Connect to POP3 email server using preconfigured settings.
89
+
90
+ #### `list_messages`
91
+ List all messages in the mailbox with metadata.
92
+
93
+ #### `get_message`
94
+ Retrieve complete content of a specific email.
95
+
96
+ **Parameters:**
97
+ - `messageId` (number): Message ID to retrieve
98
+
99
+ #### `delete_message`
100
+ Delete a specific email message.
101
+
102
+ **Parameters:**
103
+ - `messageId` (number): Message ID to delete
104
+
105
+ #### `get_message_count`
106
+ Get the total number of messages in the mailbox.
107
+
108
+ #### `disconnect`
109
+ Disconnect from the POP3 server.
110
+
111
+ #### `connect_smtp`
112
+ Connect to SMTP email server using preconfigured settings.
113
+
114
+ #### `send_email`
115
+ Send an email via SMTP.
116
+
117
+ **Parameters:**
118
+ - `to` (string): Recipient email address(es), comma-separated
119
+ - `subject` (string): Email subject
120
+ - `text` (string, optional): Plain text email body
121
+ - `html` (string, optional): HTML email body
122
+ - `cc` (string, optional): CC recipients, comma-separated
123
+ - `bcc` (string, optional): BCC recipients, comma-separated
124
+
125
+ #### `disconnect_smtp`
126
+ Disconnect from the SMTP server.
127
+
128
+ #### `quick_connect`
129
+ Connect to both POP3 and SMTP servers simultaneously using preconfigured settings.
130
+
131
+ ### πŸ’‘ Usage Examples
132
+
133
+ **Note: This project uses preconfigured email server settings via environment variables.**
134
+
135
+ In Cursor, you can use natural language commands:
136
+
137
+ #### πŸš€ Quick Start
138
+
139
+ 1. Connect to all email servers at once:
140
+ ```
141
+ Connect to email servers
142
+ ```
143
+ or
144
+ ```
145
+ Quick connect to mail
146
+ ```
147
+
148
+ #### πŸ“₯ Receiving Emails
149
+
150
+ 1. Connect to POP3 server (if not using quick connect):
151
+ ```
152
+ Connect to POP3 server
153
+ ```
154
+
155
+ 2. List emails:
156
+ ```
157
+ Show me my email list
158
+ ```
159
+
160
+ 3. Get specific email:
161
+ ```
162
+ Show me the content of email ID 1
163
+ ```
164
+
165
+ 4. Delete email:
166
+ ```
167
+ Delete email with ID 1
168
+ ```
169
+
170
+ #### πŸ“€ Sending Emails
171
+
172
+ 1. Connect to SMTP server (if not using quick connect):
173
+ ```
174
+ Connect to SMTP server
175
+ ```
176
+
177
+ 2. Send simple email:
178
+ ```
179
+ Send email to recipient@example.com with subject "Test Email" and message "Hello, this is a test email"
180
+ ```
181
+
182
+ 3. Send HTML email:
183
+ ```
184
+ Send HTML email to recipient@example.com with subject "Welcome" and HTML content "<h1>Welcome!</h1><p>This is an HTML email</p>"
185
+ ```
186
+
187
+ ### πŸ”§ Environment Configuration
188
+
189
+ #### Required Environment Variables
190
+
191
+ **⚠️ All environment variables are required - no defaults provided!**
192
+
193
+ | Variable | Description | Example Value |
194
+ |----------|-------------|---------------|
195
+ | `POP3_HOST` | POP3 server address | your-pop3-server.com |
196
+ | `POP3_PORT` | POP3 port number | 995 |
197
+ | `POP3_SECURE` | Enable TLS (true/false) | true |
198
+ | `SMTP_HOST` | SMTP server address | your-smtp-server.com |
199
+ | `SMTP_PORT` | SMTP port number | 465 |
200
+ | `SMTP_SECURE` | Enable SSL (true/false) | true |
201
+ | `EMAIL_USER` | Email username | your-email@domain.com |
202
+ | `EMAIL_PASS` | Email password | your-password |
203
+
204
+ #### Configuration Validation
205
+
206
+ - Server will fail to start if any required environment variable is missing
207
+ - Boolean values must be `true` or `false` (case-insensitive)
208
+ - Port numbers must be valid integers
209
+ - Configuration summary is displayed on startup (passwords are hidden)
210
+
211
+ ### ⚠️ Security Considerations
212
+
213
+ - Use app-specific passwords when available (Gmail, Outlook, etc.)
214
+ - Ensure secure network connections in production
215
+ - Environment variables are the recommended configuration method
216
+ - TLS/SSL encryption is strongly recommended for both protocols
217
+
218
+ ### πŸ”¨ Development
219
+
220
+ To modify or develop this project:
221
+
222
+ 1. Clone the repository:
223
+ ```bash
224
+ git clone https://github.com/yunfeizhu/mcp-mail-server.git
225
+ cd mcp-mail-server
226
+ ```
227
+
228
+ 2. Install dependencies:
229
+ ```bash
230
+ npm install
231
+ ```
232
+
233
+ 3. Build the project:
234
+ ```bash
235
+ npm run build
236
+ ```
237
+
238
+ 4. Local testing:
239
+ ```bash
240
+ # Set environment variables
241
+ export POP3_HOST=your-pop3-server.com
242
+ export POP3_PORT=995
243
+ export POP3_SECURE=true
244
+ export SMTP_HOST=your-smtp-server.com
245
+ export SMTP_PORT=465
246
+ export SMTP_SECURE=true
247
+ export EMAIL_USER=your-email@domain.com
248
+ export EMAIL_PASS=your-password
249
+
250
+ # Run the server
251
+ npm start
252
+ ```
253
+
254
+ ### πŸ“Š Package Information
255
+
256
+ - **Package Name**: `mcp-mail-server`
257
+ - **Executable**: `mcp-mail-server`
258
+ - **Node.js Version**: >=18.0.0
259
+ - **License**: MIT
260
+ - **Repository**: [GitHub](https://github.com/yunfeizhu/mcp-mail-server)
261
+
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{Server as e}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as t}from"@modelcontextprotocol/sdk/server/stdio.js";import{ListToolsRequestSchema as n,CallToolRequestSchema as r}from"@modelcontextprotocol/sdk/types.js";import s from"net";import o from"tls";import{EventEmitter as i}from"events";import c from"nodemailer";class POP3Client extends i{socket=null;config;connected=!1;authenticated=!1;buffer="";constructor(e){super(),this.config=e}async connect(){return new Promise((e,t)=>{console.error(`[POP3] Connecting to ${this.config.host}:${this.config.port} (TLS: ${this.config.tls})`);const n=setTimeout(()=>{this.socket&&this.socket.destroy(),t(new Error(`Connection timeout to ${this.config.host}:${this.config.port}`))},1e4);this.config.tls?this.socket=o.connect({host:this.config.host,port:this.config.port,rejectUnauthorized:!1}):this.socket=s.createConnection(this.config.port,this.config.host),this.socket.on("connect",()=>{console.error("[POP3] Socket connected, waiting for server greeting..."),this.connected=!0}),this.socket.on("secureConnect",()=>{console.error("[POP3] TLS connection established, waiting for server greeting..."),this.connected=!0}),this.socket.on("data",r=>{console.error("[POP3] Received data:",r.toString().trim()),this.buffer+=r.toString(),this.processBuffer(e,t,n)}),this.socket.on("error",e=>{console.error("[POP3] Connection error:",e.message),clearTimeout(n),t(new Error(`POP3 connection failed: ${e.message}`))}),this.socket.on("close",()=>{console.error("[POP3] Connection closed"),clearTimeout(n),this.connected=!1,this.authenticated=!1})})}processBuffer(e,t,n){const r=this.buffer.split("\r\n");if(r.length>1){const s=r[0];this.buffer=r.slice(1).join("\r\n"),console.error("[POP3] Server response:",s),s.startsWith("+OK")?(n&&clearTimeout(n),e&&(console.error("[POP3] Connection successful!"),e())):s.startsWith("-ERR")&&(n&&clearTimeout(n),t&&(console.error("[POP3] Server error:",s),t(new Error(`POP3 server error: ${s}`))))}}async sendCommand(e){return new Promise((t,n)=>{if(!this.socket||!this.connected)return void n(new Error("Not connected"));this.socket.write(e+"\r\n");const r=e=>{const s=e.toString();this.socket?.removeListener("data",r),s.startsWith("+OK")?t(s):n(new Error(s))};this.socket.on("data",r)})}async authenticate(){if(!this.connected)throw new Error("Not connected to server");try{console.error("[POP3] Authenticating user:",this.config.username),await this.sendCommand(`USER ${this.config.username}`),console.error("[POP3] Sending password..."),await this.sendCommand(`PASS ${this.config.password}`),this.authenticated=!0,console.error("[POP3] Authentication successful!")}catch(e){throw console.error("[POP3] Authentication failed:",e),new Error(`Authentication failed: ${e instanceof Error?e.message:String(e)}`)}}async getMessageCount(){if(!this.authenticated)throw new Error("Not authenticated");const e=(await this.sendCommand("STAT")).match(/\+OK (\d+)/);return e?parseInt(e[1]):0}async listMessages(){if(!this.authenticated)throw new Error("Not authenticated");return new Promise((e,t)=>{if(!this.socket)return void t(new Error("Not connected"));this.socket.write("LIST\r\n");let n="";const r=t=>{if(n+=t.toString(),n.includes("\r\n.\r\n")){this.socket?.removeListener("data",r);const t=n.split("\r\n"),s=[];for(let e=1;e<t.length-2;e++){const n=t[e].split(" ");n.length>=2&&s.push({id:parseInt(n[0]),size:parseInt(n[1])})}e(s)}};this.socket.on("data",r)})}async retrieveMessage(e){if(!this.authenticated)throw new Error("Not authenticated");return new Promise((t,n)=>{if(!this.socket)return void n(new Error("Not connected"));this.socket.write(`RETR ${e}\r\n`);let r="";const s=n=>{if(r+=n.toString(),r.includes("\r\n.\r\n")){this.socket?.removeListener("data",s);const n=r.substring(r.indexOf("\r\n")+2,r.lastIndexOf("\r\n.\r\n")),o=this.parseMessage(e,n);t(o)}};this.socket.on("data",s)})}parseMessage(e,t){const n=t.indexOf("\r\n\r\n"),r=n>-1?t.substring(0,n):"",s=n>-1?t.substring(n+4):t,o={},i=r.split("\r\n");for(const e of i){const t=e.indexOf(":");if(t>-1){const n=e.substring(0,t).trim().toLowerCase(),r=e.substring(t+1).trim();o[n]=r}}return{id:e,size:t.length,headers:o,body:s.trim(),raw:t}}async deleteMessage(e){if(!this.authenticated)throw new Error("Not authenticated");await this.sendCommand(`DELE ${e}`)}async quit(){this.socket&&this.connected&&(await this.sendCommand("QUIT"),this.socket.end())}disconnect(){this.socket&&(this.socket.destroy(),this.connected=!1,this.authenticated=!1)}}class SMTPClient{transporter=null;config;constructor(e){this.config=e}async connect(){this.transporter=c.createTransport({host:this.config.host,port:this.config.port,secure:this.config.secure||!1,auth:{user:this.config.username,pass:this.config.password}});try{this.transporter&&await this.transporter.verify()}catch(e){throw new Error(`SMTP connection failed: ${e instanceof Error?e.message:String(e)}`)}}async sendMail(e){if(!this.transporter)throw new Error("SMTP client not connected");const t={from:e.from||this.config.username,to:Array.isArray(e.to)?e.to.join(", "):e.to,cc:e.cc?Array.isArray(e.cc)?e.cc.join(", "):e.cc:void 0,bcc:e.bcc?Array.isArray(e.bcc)?e.bcc.join(", "):e.bcc:void 0,subject:e.subject,text:e.text,html:e.html,attachments:e.attachments};try{const e=await this.transporter.sendMail(t);return{messageId:e.messageId,response:e.response,accepted:e.accepted||[],rejected:e.rejected||[]}}catch(e){throw new Error(`Failed to send email: ${e instanceof Error?e.message:String(e)}`)}}async disconnect(){this.transporter&&(this.transporter.close(),this.transporter=null)}}function a(e){const t=process.env[e];if(!t)throw new Error(`Missing required environment variable: ${e}. Please set this variable in your MCP server configuration.`);return t}function h(e){const t=process.env[e];if(!t)throw new Error(`Missing required environment variable: ${e}. Please set this variable to 'true' or 'false' in your MCP server configuration.`);if("true"!==t.toLowerCase()&&"false"!==t.toLowerCase())throw new Error(`Invalid boolean value for environment variable ${e}: ${t}. Must be 'true' or 'false'.`);return"true"===t.toLowerCase()}function l(e){const t=process.env[e];if(!t)throw new Error(`Missing required environment variable: ${e}. Please set this variable to a valid number in your MCP server configuration.`);const n=parseInt(t,10);if(isNaN(n))throw new Error(`Invalid number value for environment variable ${e}: ${t}. Must be a valid number.`);return n}const p={POP3:{host:a("POP3_HOST"),port:l("POP3_PORT"),username:a("EMAIL_USER"),password:a("EMAIL_PASS"),tls:h("POP3_SECURE")},SMTP:{host:a("SMTP_HOST"),port:l("SMTP_PORT"),username:a("EMAIL_USER"),password:a("EMAIL_PASS"),secure:h("SMTP_SECURE")}};(new class{server;pop3Client=null;smtpClient=null;constructor(){this.validateConfig(),this.server=new e({name:"mcp-mail",version:"1.0.0"},{capabilities:{tools:{}}}),this.setupToolHandlers(),this.setupErrorHandling()}setupErrorHandling(){this.server.onerror=e=>console.error("[MCP Error]",e),process.on("SIGINT",async()=>{this.pop3Client&&this.pop3Client.disconnect(),this.smtpClient&&await this.smtpClient.disconnect(),await this.server.close(),process.exit(0)})}setupToolHandlers(){this.server.setRequestHandler(n,async()=>({tools:[{name:"connect_pop3",description:"Connect to POP3 email server (using preconfigured settings)",inputSchema:{type:"object",properties:{}}},{name:"list_messages",description:"List all messages in the mailbox",inputSchema:{type:"object",properties:{}}},{name:"get_message",description:"Retrieve a specific email message",inputSchema:{type:"object",properties:{messageId:{type:"number",description:"Message ID to retrieve"}},required:["messageId"]}},{name:"delete_message",description:"Delete a specific email message",inputSchema:{type:"object",properties:{messageId:{type:"number",description:"Message ID to delete"}},required:["messageId"]}},{name:"get_message_count",description:"Get the total number of messages in the mailbox",inputSchema:{type:"object",properties:{}}},{name:"disconnect",description:"Disconnect from the POP3 server",inputSchema:{type:"object",properties:{}}},{name:"connect_smtp",description:"Connect to SMTP email server for sending emails (using preconfigured settings)",inputSchema:{type:"object",properties:{}}},{name:"send_email",description:"Send an email via SMTP",inputSchema:{type:"object",properties:{to:{type:"string",description:"Recipient email address(es), comma-separated"},subject:{type:"string",description:"Email subject"},text:{type:"string",description:"Plain text email body"},html:{type:"string",description:"HTML email body (optional)"},cc:{type:"string",description:"CC recipients, comma-separated (optional)"},bcc:{type:"string",description:"BCC recipients, comma-separated (optional)"}},required:["to","subject"]}},{name:"disconnect_smtp",description:"Disconnect from the SMTP server",inputSchema:{type:"object",properties:{}}},{name:"quick_connect",description:"Connect to both POP3 and SMTP servers at once (using preconfigured settings)",inputSchema:{type:"object",properties:{}}}]})),this.server.setRequestHandler(r,async e=>{const{name:t,arguments:n}=e.params;try{switch(t){case"connect_pop3":return await this.handleConnect();case"list_messages":return await this.handleListMessages();case"get_message":return await this.handleGetMessage(n);case"delete_message":return await this.handleDeleteMessage(n);case"get_message_count":return await this.handleGetMessageCount();case"disconnect":return await this.handleDisconnect();case"connect_smtp":return await this.handleConnectSMTP();case"send_email":return await this.handleSendEmail(n);case"disconnect_smtp":return await this.handleDisconnectSMTP();case"quick_connect":return await this.handleQuickConnect();default:throw new Error(`Unknown tool: ${t}`)}}catch(e){return{content:[{type:"text",text:`Error: ${e instanceof Error?e.message:String(e)}`}]}}})}async handleConnect(){const e=p.POP3;try{return this.pop3Client=new POP3Client(e),await this.pop3Client.connect(),await this.pop3Client.authenticate(),{content:[{type:"text",text:`Successfully connected to POP3 server ${e.host}:${e.port}`}]}}catch(e){throw new Error(`Failed to connect: ${e instanceof Error?e.message:String(e)}`)}}async handleListMessages(){if(!this.pop3Client)throw new Error("Not connected to POP3 server");const e=await this.pop3Client.listMessages();return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}async handleGetMessage(e){if(!this.pop3Client)throw new Error("Not connected to POP3 server");const t=e.messageId;if("number"!=typeof t)throw new Error("messageId must be a number");const n=await this.pop3Client.retrieveMessage(t);return{content:[{type:"text",text:JSON.stringify(n,null,2)}]}}async handleDeleteMessage(e){if(!this.pop3Client)throw new Error("Not connected to POP3 server");const t=e.messageId;if("number"!=typeof t)throw new Error("messageId must be a number");return await this.pop3Client.deleteMessage(t),{content:[{type:"text",text:`Message ${t} marked for deletion`}]}}async handleGetMessageCount(){if(!this.pop3Client)throw new Error("Not connected to POP3 server");return{content:[{type:"text",text:`Total messages: ${await this.pop3Client.getMessageCount()}`}]}}async handleDisconnect(){if(!this.pop3Client)throw new Error("Not connected to POP3 server");return await this.pop3Client.quit(),this.pop3Client=null,{content:[{type:"text",text:"Disconnected from POP3 server"}]}}async handleConnectSMTP(){const e=p.SMTP;try{return this.smtpClient=new SMTPClient(e),await this.smtpClient.connect(),{content:[{type:"text",text:`Successfully connected to SMTP server ${e.host}:${e.port}`}]}}catch(e){throw new Error(`Failed to connect to SMTP server: ${e instanceof Error?e.message:String(e)}`)}}async handleSendEmail(e){if(!this.smtpClient)throw new Error("Not connected to SMTP server");const t={to:e.to.split(",").map(e=>e.trim()),subject:e.subject,text:e.text,html:e.html,cc:e.cc?e.cc.split(",").map(e=>e.trim()):void 0,bcc:e.bcc?e.bcc.split(",").map(e=>e.trim()):void 0};if(!t.text&&!t.html)throw new Error("Either text or html content is required");try{const e=await this.smtpClient.sendMail(t);return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}catch(e){throw new Error(`Failed to send email: ${e instanceof Error?e.message:String(e)}`)}}async handleDisconnectSMTP(){if(!this.smtpClient)throw new Error("Not connected to SMTP server");return await this.smtpClient.disconnect(),this.smtpClient=null,{content:[{type:"text",text:"Disconnected from SMTP server"}]}}async handleQuickConnect(){const e=[];let t=!1,n=!1;try{const n=p.POP3;this.pop3Client=new POP3Client(n),await this.pop3Client.connect(),await this.pop3Client.authenticate(),e.push(`βœ… POP3: Successfully connected to ${n.host}:${n.port}`),t=!0}catch(t){e.push(`❌ POP3: Failed to connect - ${t instanceof Error?t.message:String(t)}`)}try{const t=p.SMTP;this.smtpClient=new SMTPClient(t),await this.smtpClient.connect(),e.push(`βœ… SMTP: Successfully connected to ${t.host}:${t.port}`),n=!0}catch(t){e.push(`❌ SMTP: Failed to connect - ${t instanceof Error?t.message:String(t)}`)}const r=`Connection Summary: POP3 ${t?"βœ…":"❌"} | SMTP ${n?"βœ…":"❌"}`;return e.push("",r),{content:[{type:"text",text:e.join("\n")}]}}validateConfig(){try{console.error("=== MCP Mail Server Configuration ==="),console.error(`POP3: ${p.POP3.host}:${p.POP3.port} (TLS: ${p.POP3.tls})`),console.error(`SMTP: ${p.SMTP.host}:${p.SMTP.port} (Secure: ${p.SMTP.secure})`),console.error(`User: ${p.POP3.username}`),console.error("Password: [CONFIGURED]"),console.error("Configuration loaded successfully")}catch(e){throw console.error("Configuration error:",e instanceof Error?e.message:String(e)),console.error("Please ensure all required environment variables are set in your MCP server configuration."),e}}async run(){const e=new t;await this.server.connect(e),console.error("MCP Mail server running on stdio")}}).run().catch(console.error);
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "mcp-mail-server",
3
+ "version": "1.0.0",
4
+ "description": "MCP server for POP3/SMTP email access with environment-based configuration",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "mcp-mail-server": "dist/index.js"
9
+ },
10
+ "scripts": {
11
+ "build": "rollup -c",
12
+ "build:dev": "rollup -c --watch",
13
+ "build:tsc": "tsc",
14
+ "dev": "tsc --watch",
15
+ "start": "node dist/index.js",
16
+ "prepublishOnly": "npm run build",
17
+ "clean": "rimraf dist"
18
+ },
19
+ "files": [
20
+ "dist/index.js",
21
+ "README.md",
22
+ "LICENSE"
23
+ ],
24
+ "keywords": [
25
+ "mcp",
26
+ "pop3",
27
+ "smtp",
28
+ "email",
29
+ "mail",
30
+ "server",
31
+ "cursor",
32
+ "claude",
33
+ "model-context-protocol"
34
+ ],
35
+ "author": "zhuyunfei",
36
+ "license": "MIT",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/yunfeizhu/mcp-mail-server.git"
40
+ },
41
+ "homepage": "https://github.com/yunfeizhu/mcp-mail-server#readme",
42
+ "bugs": {
43
+ "url": "https://github.com/yunfeizhu/mcp-mail-server/issues"
44
+ },
45
+ "engines": {
46
+ "node": ">=18.0.0"
47
+ },
48
+ "dependencies": {
49
+ "@modelcontextprotocol/sdk": "^0.5.0",
50
+ "nodemailer": "^6.9.0"
51
+ },
52
+ "devDependencies": {
53
+ "@rollup/plugin-commonjs": "^25.0.0",
54
+ "@rollup/plugin-node-resolve": "^15.0.0",
55
+ "@rollup/plugin-terser": "^0.4.0",
56
+ "@rollup/plugin-typescript": "^11.0.0",
57
+ "@types/node": "^20.0.0",
58
+ "@types/nodemailer": "^6.4.0",
59
+ "rollup": "^4.0.0",
60
+ "tslib": "^2.6.0",
61
+ "typescript": "^5.0.0"
62
+ }
63
+ }