@teamnetwork-nz/smtp-mcp-server 1.4.0 → 1.4.2

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/.env.example CHANGED
@@ -13,5 +13,6 @@ SMTP_FROM_NAME=My Agent # optional, defaults to SMTP_FROM_ADDRESS
13
13
  # Recipient restrictions (at least one recommended for production)
14
14
  # An address passes if it matches ANY rule — domain OR explicit address.
15
15
  # If both variables are empty, all addresses are permitted (open mode).
16
- ALLOWED_DOMAINS=example.com,partner.org # comma-separated domains
17
- ALLOWED_ADDRESSES=external@other.com # comma-separated explicit addresses
16
+ SMTP_READWRITE=false # set true to register send_email
17
+ SMTP_ALLOWED_DOMAINS=example.com,partner.org # comma-separated domains
18
+ SMTP_ALLOWED_ADDRESSES=external@other.com # comma-separated explicit addresses
package/README.md CHANGED
@@ -51,10 +51,12 @@ All configuration is via environment variables (loaded from `.env` if present).
51
51
  | `SMTP_PASS` | no | SMTP auth password — omit for unauthenticated relays |
52
52
  | `SMTP_FROM_ADDRESS` | yes | Envelope From address |
53
53
  | `SMTP_FROM_NAME` | no | Display name — defaults to `SMTP_FROM_ADDRESS` |
54
- | `ALLOWED_DOMAINS` | no | Comma-separated domains, e.g. `acme.com,partner.org` |
55
- | `ALLOWED_ADDRESSES` | no | Comma-separated explicit addresses |
54
+ | `SMTP_READWRITE` | no | Set to `true` to register `send_email`; defaults to read-only |
55
+ | `SMTP_ALLOWED_DOMAINS` | for sending | Comma-separated domains, e.g. `acme.com,partner.org` |
56
+ | `SMTP_ALLOWED_ADDRESSES` | for sending | Comma-separated explicit addresses |
57
+ | `SMTP_HTTP_MAX_BODY_BYTES` | no | Positive request-body limit; default 1048576, maximum 16777216 |
56
58
 
57
- **Restriction logic:** a recipient is permitted if its domain matches `ALLOWED_DOMAINS` **or** it appears in `ALLOWED_ADDRESSES`. All addresses across `to`, `cc`, and `bcc` are checked — a single blocked address rejects the whole request. If neither variable is set, all addresses are permitted (not recommended for production).
59
+ **Restriction logic:** `send_email` is absent unless `SMTP_READWRITE=true`. When enabled, at least one recipient allowlist is required. A recipient is permitted if its domain matches `SMTP_ALLOWED_DOMAINS` **or** it appears in `SMTP_ALLOWED_ADDRESSES`. All addresses across `to`, `cc`, and `bcc` are checked — a single blocked address rejects the whole request. `ALLOWED_DOMAINS` and `ALLOWED_ADDRESSES` remain one-release deprecated aliases.
58
60
 
59
61
  ## Claude Code Integration
60
62
 
@@ -73,7 +75,8 @@ Add to your `.claude/mcp_config.json` (or `claude_desktop_config.json`):
73
75
  "SMTP_PASS": "your-password",
74
76
  "SMTP_FROM_ADDRESS": "agent@example.com",
75
77
  "SMTP_FROM_NAME": "My Agent",
76
- "ALLOWED_DOMAINS": "example.com"
78
+ "SMTP_READWRITE": "true",
79
+ "SMTP_ALLOWED_DOMAINS": "example.com"
77
80
  }
78
81
  }
79
82
  }
package/dist/config.js CHANGED
@@ -5,30 +5,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.config = void 0;
7
7
  const dotenv_1 = __importDefault(require("dotenv"));
8
- const zod_1 = require("zod");
8
+ const v3_1 = require("zod/v3");
9
9
  dotenv_1.default.config({ quiet: true });
10
- const configSchema = zod_1.z.object({
11
- smtp: zod_1.z.object({
12
- host: zod_1.z.string().min(1, "SMTP_HOST is required"),
13
- port: zod_1.z.coerce.number().int().min(1).max(65535).default(587),
14
- secure: zod_1.z
15
- .string()
16
- .transform((v) => v.toLowerCase() === "true")
17
- .default(false),
18
- ignoreTls: zod_1.z
19
- .string()
20
- .transform((v) => v.toLowerCase() === "true")
21
- .default(false),
22
- user: zod_1.z.string().min(1).optional(),
23
- pass: zod_1.z.string().min(1).optional(),
10
+ const configSchema = v3_1.z.object({
11
+ readWrite: v3_1.z.boolean().default(false),
12
+ smtp: v3_1.z.object({
13
+ host: v3_1.z.string().min(1, "SMTP_HOST is required"),
14
+ port: v3_1.z.coerce.number().int().min(1).max(65535).default(587),
15
+ secure: v3_1.z.boolean().default(false),
16
+ ignoreTls: v3_1.z.boolean().default(false),
17
+ user: v3_1.z.string().min(1).optional(),
18
+ pass: v3_1.z.string().min(1).optional(),
24
19
  }),
25
- from: zod_1.z.object({
26
- address: zod_1.z.string().email("SMTP_FROM_ADDRESS must be a valid email"),
27
- name: zod_1.z.string().optional(),
20
+ from: v3_1.z.object({
21
+ address: v3_1.z.string().email("SMTP_FROM_ADDRESS must be a valid email"),
22
+ name: v3_1.z.string().optional(),
28
23
  }),
29
- restrictions: zod_1.z.object({
30
- allowedDomains: zod_1.z.array(zod_1.z.string()).default([]),
31
- allowedAddresses: zod_1.z.array(zod_1.z.string().email()).default([]),
24
+ restrictions: v3_1.z.object({
25
+ allowedDomains: v3_1.z.array(v3_1.z.string()).default([]),
26
+ allowedAddresses: v3_1.z.array(v3_1.z.string().email()).default([]),
32
27
  }),
33
28
  });
34
29
  function parseList(value) {
@@ -39,13 +34,23 @@ function parseList(value) {
39
34
  .map((s) => s.trim())
40
35
  .filter(Boolean);
41
36
  }
37
+ function parseListEnv(canonicalName, legacyName) {
38
+ if (process.env[canonicalName] !== undefined)
39
+ return parseList(process.env[canonicalName]);
40
+ if (process.env[legacyName] !== undefined) {
41
+ process.stderr.write(`[deprecated] ${legacyName} is deprecated; use ${canonicalName}.\n`);
42
+ return parseList(process.env[legacyName]);
43
+ }
44
+ return [];
45
+ }
42
46
  function loadConfig() {
43
47
  const raw = {
48
+ readWrite: (process.env.SMTP_READWRITE ?? "").toLowerCase() === "true",
44
49
  smtp: {
45
50
  host: process.env.SMTP_HOST,
46
51
  port: process.env.SMTP_PORT,
47
- secure: process.env.SMTP_SECURE,
48
- ignoreTls: process.env.SMTP_IGNORE_TLS,
52
+ secure: (process.env.SMTP_SECURE ?? "").toLowerCase() === "true",
53
+ ignoreTls: (process.env.SMTP_IGNORE_TLS ?? "").toLowerCase() === "true",
49
54
  user: process.env.SMTP_USER,
50
55
  pass: process.env.SMTP_PASS,
51
56
  },
@@ -54,8 +59,8 @@ function loadConfig() {
54
59
  name: process.env.SMTP_FROM_NAME,
55
60
  },
56
61
  restrictions: {
57
- allowedDomains: parseList(process.env.ALLOWED_DOMAINS),
58
- allowedAddresses: parseList(process.env.ALLOWED_ADDRESSES),
62
+ allowedDomains: parseListEnv("SMTP_ALLOWED_DOMAINS", "ALLOWED_DOMAINS"),
63
+ allowedAddresses: parseListEnv("SMTP_ALLOWED_ADDRESSES", "ALLOWED_ADDRESSES"),
59
64
  },
60
65
  };
61
66
  const result = configSchema.safeParse(raw);
@@ -63,13 +68,17 @@ function loadConfig() {
63
68
  const messages = result.error.issues
64
69
  .map((i) => ` ${i.path.join(".")}: ${i.message}`)
65
70
  .join("\n");
66
- console.error(`Configuration error:\n${messages}`);
71
+ process.stderr.write(`Configuration error:\n${messages}\n`);
67
72
  process.exit(1);
68
73
  }
69
74
  const config = result.data;
70
75
  if (!config.from.name) {
71
76
  config.from.name = config.from.address;
72
77
  }
78
+ if (config.readWrite && config.restrictions.allowedDomains.length === 0 && config.restrictions.allowedAddresses.length === 0) {
79
+ process.stderr.write("Configuration error:\n restrictions: SMTP_READWRITE=true requires SMTP_ALLOWED_DOMAINS or SMTP_ALLOWED_ADDRESSES\n");
80
+ process.exit(1);
81
+ }
73
82
  return config;
74
83
  }
75
84
  exports.config = loadConfig();
package/dist/email.js CHANGED
@@ -71,7 +71,10 @@ function resolveAttachment(a) {
71
71
  contentType: validateContentType(content_type, filename),
72
72
  };
73
73
  }
74
- async function sendEmail(transport, from, options) {
74
+ async function sendEmail(transport, from, options, readWrite) {
75
+ if (!readWrite) {
76
+ throw new Error("Write operations are disabled. Set SMTP_READWRITE=true and configure a recipient allowlist to enable sending.");
77
+ }
75
78
  const message = {
76
79
  from: `"${from.name}" <${from.address}>`,
77
80
  to: options.to,
package/dist/env.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parsePositiveInt = parsePositiveInt;
4
+ function parsePositiveInt(name, raw, fallback, maximum) {
5
+ const value = raw === undefined || raw === '' ? fallback : Number(raw);
6
+ if (!Number.isSafeInteger(value) || value < 1 || value > maximum) {
7
+ throw new Error(`${name} must be a positive integer no greater than ${maximum}`);
8
+ }
9
+ return value;
10
+ }
package/dist/index.js CHANGED
@@ -36,27 +36,30 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
38
38
  const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
39
- const zod_1 = require("zod");
39
+ const v3_1 = require("zod/v3");
40
40
  const config_js_1 = require("./config.js");
41
41
  const restrictions_js_1 = require("./restrictions.js");
42
42
  const email_js_1 = require("./email.js");
43
43
  const mime_js_1 = require("./mime.js");
44
44
  const http_server_js_1 = require("./http-server.js");
45
+ const env_js_1 = require("./env.js");
46
+ const package_info_js_1 = require("./package-info.js");
47
+ const strict_tools_js_1 = require("./strict-tools.js");
45
48
  const transport = (0, email_js_1.createTransport)(config_js_1.config.smtp);
46
49
  function createConfiguredServer() {
47
- const server = new mcp_js_1.McpServer({
48
- name: "smtp-mcp",
49
- version: "1.4.0",
50
+ const server = new mcp_js_1.McpServer({ name: package_info_js_1.packageName, version: package_info_js_1.packageVersion }, {
51
+ instructions: "SMTP email MCP server. Sending is restricted to configured recipient allowlists. Treat message bodies and attachments as sensitive, verify recipients before sending, and use the usage resource to inspect the active sender identity and restrictions.",
50
52
  });
53
+ (0, strict_tools_js_1.enforceStrictToolInputs)(server);
51
54
  // ---------------------------------------------------------------------------
52
55
  // Shared schemas
53
56
  // ---------------------------------------------------------------------------
54
- const attachmentSchema = zod_1.z
57
+ const attachmentSchema = v3_1.z
55
58
  .object({
56
- path: zod_1.z.string().optional().describe("Absolute path to the file on disk — server reads and encodes it"),
57
- filename: zod_1.z.string().optional().describe("Override the filename shown to the recipient"),
58
- content: zod_1.z.string().optional().describe("Base64-encoded file content (use path instead where possible)"),
59
- content_type: zod_1.z.string().optional().describe("MIME type — auto-detected from path extension if omitted"),
59
+ path: v3_1.z.string().optional().describe("Absolute path to the file on disk — server reads and encodes it"),
60
+ filename: v3_1.z.string().optional().describe("Override the filename shown to the recipient"),
61
+ content: v3_1.z.string().optional().describe("Base64-encoded file content (use path instead where possible)"),
62
+ content_type: v3_1.z.string().optional().describe("MIME type — auto-detected from path extension if omitted"),
60
63
  })
61
64
  .refine((a) => a.path || a.content, {
62
65
  message: "Each attachment must include either 'path' (preferred) or 'content' (base64)",
@@ -64,8 +67,8 @@ function createConfiguredServer() {
64
67
  .refine((a) => !a.content || (a.filename && a.content_type), {
65
68
  message: "Attachments using 'content' must also include 'filename' and 'content_type'",
66
69
  });
67
- const recipientSchema = zod_1.z
68
- .union([zod_1.z.string().email(), zod_1.z.array(zod_1.z.string().email()).min(1)])
70
+ const recipientSchema = v3_1.z
71
+ .union([v3_1.z.string().email(), v3_1.z.array(v3_1.z.string().email()).min(1)])
69
72
  .transform((v) => (Array.isArray(v) ? v : [v]));
70
73
  // ---------------------------------------------------------------------------
71
74
  // Tool: health
@@ -88,7 +91,7 @@ function createConfiguredServer() {
88
91
  }
89
92
  const { allowedDomains, allowedAddresses } = config_js_1.config.restrictions;
90
93
  const restrictionSummary = allowedDomains.length === 0 && allowedAddresses.length === 0
91
- ? "none (all addresses permitted)"
94
+ ? "none (sending disabled)"
92
95
  : [
93
96
  allowedDomains.length
94
97
  ? `domains: ${allowedDomains.join(", ")}`
@@ -105,6 +108,7 @@ function createConfiguredServer() {
105
108
  `tls: ${config_js_1.config.smtp.secure ? "implicit TLS" : config_js_1.config.smtp.ignoreTls ? "none (plain SMTP)" : "STARTTLS"}`,
106
109
  `auth: ${config_js_1.config.smtp.user ? `authenticated as ${config_js_1.config.smtp.user}` : "unauthenticated"}`,
107
110
  `from: "${config_js_1.config.from.name}" <${config_js_1.config.from.address}>`,
111
+ `mode: ${config_js_1.config.readWrite ? "read-write" : "read-only"}`,
108
112
  `restrictions: ${restrictionSummary}`,
109
113
  ];
110
114
  return {
@@ -121,8 +125,8 @@ function createConfiguredServer() {
121
125
  "the server will encode the file itself without passing binary data through the agent. " +
122
126
  "Use encode_file only when you need to inspect or transform the content before sending.",
123
127
  inputSchema: {
124
- path: zod_1.z.string().min(1).describe("Absolute or relative path to the file"),
125
- content_type: zod_1.z
128
+ path: v3_1.z.string().min(1).describe("Absolute or relative path to the file"),
129
+ content_type: v3_1.z
126
130
  .string()
127
131
  .optional()
128
132
  .describe("MIME type override. If omitted the type is detected from the file extension."),
@@ -161,72 +165,73 @@ function createConfiguredServer() {
161
165
  // ---------------------------------------------------------------------------
162
166
  // Tool: send_email
163
167
  // ---------------------------------------------------------------------------
164
- server.registerTool("send_email", {
165
- description: "Send an email via SMTP. Recipient addresses are validated against the server's allowed domains/addresses policy.",
166
- inputSchema: {
167
- to: recipientSchema.describe("Recipient address or list of addresses"),
168
- subject: zod_1.z.string().min(1).describe("Email subject line"),
169
- body: zod_1.z.string().min(1).describe("Email body content"),
170
- body_type: zod_1.z
171
- .enum(["text", "html"])
172
- .default("text")
173
- .describe("Body format — plain text (default) or HTML"),
174
- cc: recipientSchema
175
- .optional()
176
- .describe("CC address or list of addresses"),
177
- bcc: recipientSchema
178
- .optional()
179
- .describe("BCC address or list of addresses"),
180
- attachments: zod_1.z
181
- .array(attachmentSchema)
182
- .optional()
183
- .describe("Files to attach"),
184
- },
185
- }, async (args) => {
186
- const allRecipients = [
187
- ...args.to,
188
- ...(args.cc ?? []),
189
- ...(args.bcc ?? []),
190
- ];
191
- const check = (0, restrictions_js_1.checkRecipients)(allRecipients, config_js_1.config.restrictions);
192
- if (!check.allowed) {
193
- return {
194
- isError: true,
195
- content: [
196
- {
197
- type: "text",
198
- text: `Recipient(s) not permitted by server policy: ${check.blocked.join(", ")}`,
199
- },
200
- ],
201
- };
202
- }
203
- try {
204
- const result = await (0, email_js_1.sendEmail)(transport, config_js_1.config.from, {
205
- to: args.to,
206
- subject: args.subject,
207
- body: args.body,
208
- body_type: args.body_type,
209
- cc: args.cc,
210
- bcc: args.bcc,
211
- attachments: args.attachments,
212
- });
213
- return {
214
- content: [
215
- {
216
- type: "text",
217
- text: `Email sent successfully. Message ID: ${result.messageId}`,
218
- },
219
- ],
220
- };
221
- }
222
- catch (err) {
223
- const message = err instanceof Error ? err.message : String(err);
224
- return {
225
- isError: true,
226
- content: [{ type: "text", text: `Failed to send email: ${message}` }],
227
- };
228
- }
229
- });
168
+ if (config_js_1.config.readWrite)
169
+ server.registerTool("send_email", {
170
+ description: "Send an email via SMTP. Recipient addresses are validated against the server's allowed domains/addresses policy.",
171
+ inputSchema: {
172
+ to: recipientSchema.describe("Recipient address or list of addresses"),
173
+ subject: v3_1.z.string().min(1).describe("Email subject line"),
174
+ body: v3_1.z.string().min(1).describe("Email body content"),
175
+ body_type: v3_1.z
176
+ .enum(["text", "html"])
177
+ .default("text")
178
+ .describe("Body format — plain text (default) or HTML"),
179
+ cc: recipientSchema
180
+ .optional()
181
+ .describe("CC address or list of addresses"),
182
+ bcc: recipientSchema
183
+ .optional()
184
+ .describe("BCC address or list of addresses"),
185
+ attachments: v3_1.z
186
+ .array(attachmentSchema)
187
+ .optional()
188
+ .describe("Files to attach"),
189
+ },
190
+ }, async (args) => {
191
+ const allRecipients = [
192
+ ...args.to,
193
+ ...(args.cc ?? []),
194
+ ...(args.bcc ?? []),
195
+ ];
196
+ const check = (0, restrictions_js_1.checkRecipients)(allRecipients, config_js_1.config.restrictions);
197
+ if (!check.allowed) {
198
+ return {
199
+ isError: true,
200
+ content: [
201
+ {
202
+ type: "text",
203
+ text: `Recipient(s) not permitted by server policy: ${check.blocked.join(", ")}`,
204
+ },
205
+ ],
206
+ };
207
+ }
208
+ try {
209
+ const result = await (0, email_js_1.sendEmail)(transport, config_js_1.config.from, {
210
+ to: args.to,
211
+ subject: args.subject,
212
+ body: args.body,
213
+ body_type: args.body_type,
214
+ cc: args.cc,
215
+ bcc: args.bcc,
216
+ attachments: args.attachments,
217
+ }, config_js_1.config.readWrite);
218
+ return {
219
+ content: [
220
+ {
221
+ type: "text",
222
+ text: `Email sent successfully. Message ID: ${result.messageId}`,
223
+ },
224
+ ],
225
+ };
226
+ }
227
+ catch (err) {
228
+ const message = err instanceof Error ? err.message : String(err);
229
+ return {
230
+ isError: true,
231
+ content: [{ type: "text", text: `Failed to send email: ${message}` }],
232
+ };
233
+ }
234
+ });
230
235
  // ---------------------------------------------------------------------------
231
236
  // Resource: usage guide for agents
232
237
  // ---------------------------------------------------------------------------
@@ -247,7 +252,7 @@ function createConfiguredServer() {
247
252
  ]
248
253
  .filter((l) => l !== null)
249
254
  .join("\n")
250
- : "RECIPIENT RESTRICTIONS\nNone configured — all addresses are permitted.";
255
+ : "RECIPIENT RESTRICTIONS\nNone configured — sending cannot be enabled.";
251
256
  return `
252
257
  SMTP MCP SERVER — USAGE GUIDE
253
258
  ==============================
@@ -256,6 +261,9 @@ This server sends email on behalf of agents via an SMTP relay.
256
261
  All configuration (credentials, sender identity, restrictions) is fixed at
257
262
  startup and cannot be changed by tool calls.
258
263
 
264
+ MODE
265
+ ${config_js_1.config.readWrite ? "read-write — send_email is available" : "read-only — send_email is not registered"}
266
+
259
267
  SENDER IDENTITY
260
268
  From name: ${config_js_1.config.from.name}
261
269
  From address: ${config_js_1.config.from.address}
@@ -359,8 +367,8 @@ TIPS
359
367
  async function main() {
360
368
  if ((process.env.SMTP_TRANSPORT ?? "stdio") === "http") {
361
369
  const host = process.env.SMTP_HTTP_HOST ?? "127.0.0.1";
362
- const port = Number.parseInt(process.env.SMTP_HTTP_PORT ?? "3000", 10);
363
- (0, http_server_js_1.createHttpServer)(createConfiguredServer, { host, port, serverName: "@teamnetwork-nz/smtp-mcp-server", bearerToken: process.env.SMTP_HTTP_BEARER_TOKEN, allowedHosts: process.env.SMTP_HTTP_ALLOWED_HOSTS?.split(",").map(v => v.trim()).filter(Boolean), allowedOrigins: process.env.SMTP_HTTP_ALLOWED_ORIGINS?.split(",").map(v => v.trim()).filter(Boolean) }).listen(port, host, () => console.error(`SMTP MCP server listening on ${host}:${port}/mcp`));
370
+ const port = (0, env_js_1.parsePositiveInt)("SMTP_HTTP_PORT", process.env.SMTP_HTTP_PORT, 3000, 65535);
371
+ (0, http_server_js_1.createHttpServer)(createConfiguredServer, { host, port, serverName: "@teamnetwork-nz/smtp-mcp-server", bearerToken: process.env.SMTP_HTTP_BEARER_TOKEN, allowedHosts: process.env.SMTP_HTTP_ALLOWED_HOSTS?.split(",").map(v => v.trim()).filter(Boolean), allowedOrigins: process.env.SMTP_HTTP_ALLOWED_ORIGINS?.split(",").map(v => v.trim()).filter(Boolean), maxBodyBytes: (0, env_js_1.parsePositiveInt)("SMTP_HTTP_MAX_BODY_BYTES", process.env.SMTP_HTTP_MAX_BODY_BYTES, 1_048_576, 16_777_216) }).listen(port, host, () => console.error(`SMTP MCP server listening on ${host}:${port}/mcp`));
364
372
  }
365
373
  else {
366
374
  await createConfiguredServer().connect(new stdio_js_1.StdioServerTransport());
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.packageVersion = exports.packageName = void 0;
4
+ const node_fs_1 = require("node:fs");
5
+ const node_path_1 = require("node:path");
6
+ const packageJson = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, '..', 'package.json'), 'utf8'));
7
+ exports.packageName = packageJson.name ?? 'smtp-mcp-server';
8
+ exports.packageVersion = packageJson.version ?? '0.0.0';
@@ -6,9 +6,9 @@ function domainOf(address) {
6
6
  }
7
7
  function checkRecipients(addresses, restrictions) {
8
8
  const { allowedDomains, allowedAddresses } = restrictions;
9
- // No restrictions configured — permit everything.
9
+ // A write-enabled server must always have an explicit recipient allowlist.
10
10
  if (allowedDomains.length === 0 && allowedAddresses.length === 0) {
11
- return { allowed: true };
11
+ return { allowed: false, blocked: addresses };
12
12
  }
13
13
  const normalizedAllowedAddresses = allowedAddresses.map((a) => a.toLowerCase());
14
14
  const normalizedAllowedDomains = allowedDomains.map((d) => d.toLowerCase());
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enforceStrictToolInputs = enforceStrictToolInputs;
4
+ const v3_1 = require("zod/v3");
5
+ function isSchema(value) {
6
+ return typeof value === "object" && value !== null && "_def" in value;
7
+ }
8
+ function isRawShape(value) {
9
+ if (typeof value !== "object" || value === null || isSchema(value))
10
+ return false;
11
+ const values = Object.values(value);
12
+ return values.length === 0 || values.some(isSchema);
13
+ }
14
+ function strictSchema(schema) {
15
+ if (schema === undefined)
16
+ return v3_1.z.object({}).strict();
17
+ if (isRawShape(schema))
18
+ return v3_1.z.object(schema).strict();
19
+ if (isSchema(schema) && typeof schema.strict === "function")
20
+ return schema.strict();
21
+ return schema;
22
+ }
23
+ /** Make every tool object reject undeclared arguments, including no-argument tools. */
24
+ function enforceStrictToolInputs(server) {
25
+ const mutable = server;
26
+ const createRegisteredTool = mutable._createRegisteredTool.bind(server);
27
+ mutable._createRegisteredTool = (...args) => {
28
+ // SDK 1.29 funnels both tool() and registerTool() through this method.
29
+ args[3] = strictSchema(args[3]);
30
+ return createRegisteredTool(...args);
31
+ };
32
+ }
package/package.json CHANGED
@@ -1,48 +1,48 @@
1
- {
2
- "name": "@teamnetwork-nz/smtp-mcp-server",
3
- "version": "1.4.0",
4
- "description": "MCP server for sending email via SMTP relay",
5
- "main": "dist/index.js",
6
- "bin": {
7
- "smtp-mcp-server": "dist/index.js"
8
- },
9
- "files": [
10
- "dist",
11
- "README.md",
12
- ".env.example"
13
- ],
14
- "scripts": {
15
- "build": "tsc",
16
- "test": "npm run build && node --test tests/*.test.mjs",
17
- "start": "node dist/index.js",
18
- "dev": "tsc --watch",
19
- "prepublishOnly": "npm run build"
20
- },
21
- "keywords": [
22
- "mcp",
23
- "smtp",
24
- "email",
25
- "model-context-protocol",
26
- "claude"
27
- ],
28
- "author": "",
29
- "license": "ISC",
30
- "type": "commonjs",
31
- "engines": {
32
- "node": ">=18.0.0"
33
- },
34
- "publishConfig": {
35
- "access": "public"
36
- },
37
- "dependencies": {
38
- "@modelcontextprotocol/sdk": "^1.29.0",
39
- "dotenv": "^17.4.2",
40
- "nodemailer": "^8.0.7",
41
- "zod": "^4.4.3"
42
- },
43
- "devDependencies": {
44
- "@types/node": "^25.7.0",
45
- "@types/nodemailer": "^8.0.0",
46
- "typescript": "^6.0.3"
47
- }
48
- }
1
+ {
2
+ "name": "@teamnetwork-nz/smtp-mcp-server",
3
+ "version": "1.4.2",
4
+ "description": "MCP server for sending email via SMTP relay",
5
+ "main": "dist/index.js",
6
+ "bin": {
7
+ "smtp-mcp-server": "dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "README.md",
12
+ ".env.example"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "test": "npm run build && node --test tests/*.test.mjs",
17
+ "start": "node dist/index.js",
18
+ "dev": "tsc --watch",
19
+ "prepublishOnly": "npm run build"
20
+ },
21
+ "keywords": [
22
+ "mcp",
23
+ "smtp",
24
+ "email",
25
+ "model-context-protocol",
26
+ "claude"
27
+ ],
28
+ "author": "",
29
+ "license": "ISC",
30
+ "type": "commonjs",
31
+ "engines": {
32
+ "node": ">=18.0.0"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "dependencies": {
38
+ "@modelcontextprotocol/sdk": "^1.32.2",
39
+ "dotenv": "^17.4.2",
40
+ "nodemailer": "^8.0.7",
41
+ "zod": "^4.6.7"
42
+ },
43
+ "devDependencies": {
44
+ "@types/node": "^25.7.0",
45
+ "@types/nodemailer": "^8.0.0",
46
+ "typescript": "^6.0.3"
47
+ }
48
+ }