imap-mcp 1.5.0 → 2.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/README.md CHANGED
@@ -72,6 +72,12 @@ npx tsc
72
72
  node dist/index.js
73
73
  ```
74
74
 
75
+ ## TLS certificates
76
+
77
+ With `IMAP_USE_SSL` set to `true`, imap-mcp checks that the server's certificate is valid for `IMAP_HOST` and refuses to connect, before sending your password, when it is not. This check is on by default.
78
+
79
+ If your server uses a self-signed or otherwise untrusted certificate, set `IMAP_TLS_REJECT_UNAUTHORIZED` to exactly `false` to turn the check off. With the check off, imap-mcp cannot tell your server from another one, so use it only on a network you trust.
80
+
75
81
  ## Access levels
76
82
 
77
83
  `--access` or `MCP_ACCESS` sets what the agent may do through imap-mcp. The flag wins when both are set; changing the level needs a restart of the server.
package/dist/index.js CHANGED
@@ -35,7 +35,11 @@ export async function main() {
35
35
  user: process.env.IMAP_USERNAME || "",
36
36
  pass: process.env.IMAP_PASSWORD || "",
37
37
  },
38
- tls: { rejectUnauthorized: false },
38
+ // Verify the server certificate unless the user explicitly opts out,
39
+ // for a server with a self-signed or otherwise untrusted certificate.
40
+ tls: {
41
+ rejectUnauthorized: process.env.IMAP_TLS_REJECT_UNAUTHORIZED !== "false",
42
+ },
39
43
  // Like the imap package, never upgrade a non-SSL connection with STARTTLS.
40
44
  doSTARTTLS: false,
41
45
  // imapflow logs to stdout by default, which carries the MCP protocol.
@@ -64,10 +64,12 @@ describe("main", () => {
64
64
  process.env.IMAP_HOST = "imap.example.com";
65
65
  process.env.IMAP_PORT = "993";
66
66
  process.env.IMAP_USE_SSL = "true";
67
+ delete process.env.IMAP_TLS_REJECT_UNAUTHORIZED;
67
68
  });
68
69
  afterEach(() => {
69
70
  process.argv = argv;
70
71
  delete process.env.MCP_ACCESS;
72
+ delete process.env.IMAP_TLS_REJECT_UNAUTHORIZED;
71
73
  vi.restoreAllMocks();
72
74
  });
73
75
  function mockServer() {
@@ -105,7 +107,7 @@ describe("main", () => {
105
107
  port: 993,
106
108
  secure: true,
107
109
  auth: { user: "test@example.com", pass: "testpass" },
108
- tls: { rejectUnauthorized: false },
110
+ tls: { rejectUnauthorized: true },
109
111
  doSTARTTLS: false,
110
112
  logger: false,
111
113
  });
@@ -113,6 +115,15 @@ describe("main", () => {
113
115
  expect(StdioServerTransport).toHaveBeenCalled();
114
116
  expect(mockServer.connect).toHaveBeenCalledWith(mockTransport);
115
117
  });
118
+ it("accepts an untrusted certificate only when told to", async () => {
119
+ mockServer();
120
+ process.env.IMAP_TLS_REJECT_UNAUTHORIZED = "false";
121
+ const { main } = await import("./index.js");
122
+ await main();
123
+ const createClient = vi.mocked(registerCreateDraft).mock.calls[0][0];
124
+ createClient();
125
+ expect(ImapFlow).toHaveBeenCalledWith(expect.objectContaining({ tls: { rejectUnauthorized: false } }));
126
+ });
116
127
  it("defaults to everything and logs the level on stderr", async () => {
117
128
  mockServer();
118
129
  const stderr = vi.spyOn(console, "error").mockImplementation(() => { });
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "imap-mcp",
3
3
  "mcpName": "io.github.langmail/imap-mcp",
4
4
  "description": "An MCP server that lets your AI agent search, read and draft email in any IMAP mailbox.",
5
- "version": "1.5.0",
5
+ "version": "2.0.0",
6
6
  "main": "dist/index.js",
7
7
  "type": "module",
8
8
  "bin": {