shipmail-mcp 0.6.4 → 0.6.6

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/dist/index.js CHANGED
@@ -4,6 +4,106 @@
4
4
  import { serveStdio } from "@modelcontextprotocol/server/stdio";
5
5
  import { ShipMailClient as ShipMailClient2 } from "shipmail";
6
6
 
7
+ // src/config.ts
8
+ import { readFileSync } from "fs";
9
+ import { env } from "process";
10
+ var DEFAULT_BASE_URL = "https://shipmail.to/api/v1";
11
+ var HELP_TEXT = `shipmail-mcp
12
+
13
+ Usage:
14
+ shipmail-mcp
15
+
16
+ Environment:
17
+ SHIPMAIL_API_KEY Required ShipMail API key (or use SHIPMAIL_API_KEY_FILE).
18
+ SHIPMAIL_API_KEY_FILE Optional path to a file containing the API key. Takes precedence over
19
+ SHIPMAIL_API_KEY when set; reduces env-trace leak surface for hosts that
20
+ log environment variables.
21
+ SHIPMAIL_BASE_URL Optional API base URL. Must be https. Defaults to ${DEFAULT_BASE_URL}.
22
+ SHIPMAIL_ORGANIZATION_ID
23
+ Optional delegated child organization ID for infrastructure tools.
24
+ SHIPMAIL_ALLOW_INSECURE_BASE_URL=1
25
+ Permit non-https or non-shipmail.to base URL (development only).
26
+
27
+ ShipMail discovers tools from the API key's live permissions at startup. Change scopes, resources,
28
+ recipient rules, and send budgets in ShipMail Settings.`;
29
+ var API_KEY_HELP = "SHIPMAIL_API_KEY (or SHIPMAIL_API_KEY_FILE) is required. Create an API key in ShipMail, then run `SHIPMAIL_API_KEY=sm_live_... shipmail-mcp`.";
30
+ function readApiKey() {
31
+ const filePath = env["SHIPMAIL_API_KEY_FILE"];
32
+ if (filePath !== void 0 && filePath.length > 0) {
33
+ let raw;
34
+ try {
35
+ raw = readFileSync(filePath, "utf8");
36
+ } catch (error) {
37
+ throw new Error(
38
+ `Failed to read SHIPMAIL_API_KEY_FILE at ${filePath}: ${error instanceof Error ? error.message : String(error)}`,
39
+ { cause: error }
40
+ );
41
+ }
42
+ const trimmed = raw.trim();
43
+ if (trimmed.length === 0) {
44
+ throw new Error(`SHIPMAIL_API_KEY_FILE at ${filePath} is empty.`);
45
+ }
46
+ return trimmed;
47
+ }
48
+ const direct = env["SHIPMAIL_API_KEY"];
49
+ if (!direct) throw new Error(API_KEY_HELP);
50
+ return direct;
51
+ }
52
+ var ALLOWED_BASE_URL_HOSTS = ["shipmail.to", "api.shipmail.to"];
53
+ function validateBaseUrl(rawValue, allowInsecure) {
54
+ let parsed;
55
+ try {
56
+ parsed = new URL(rawValue);
57
+ } catch {
58
+ throw new Error(`SHIPMAIL_BASE_URL is not a valid URL: ${rawValue}`);
59
+ }
60
+ if (allowInsecure) return parsed.toString().replace(/\/+$/, "");
61
+ if (parsed.protocol !== "https:") {
62
+ throw new Error(
63
+ "SHIPMAIL_BASE_URL must use https. Set SHIPMAIL_ALLOW_INSECURE_BASE_URL=1 for development."
64
+ );
65
+ }
66
+ const host = parsed.hostname.toLowerCase();
67
+ const isAllowedHost = ALLOWED_BASE_URL_HOSTS.some(
68
+ (allowed) => host === allowed || host.endsWith(`.${allowed}`)
69
+ );
70
+ if (!isAllowedHost) {
71
+ throw new Error(
72
+ `SHIPMAIL_BASE_URL host "${host}" is not allowed. Set SHIPMAIL_ALLOW_INSECURE_BASE_URL=1 for development.`
73
+ );
74
+ }
75
+ return parsed.toString().replace(/\/+$/, "");
76
+ }
77
+ function readConfig(argv = process.argv.slice(2)) {
78
+ if (argv.includes("--tools")) {
79
+ throw new Error(
80
+ "--tools was removed. ShipMail MCP tools now follow the API key permissions configured in ShipMail Settings."
81
+ );
82
+ }
83
+ const unknownArgs = argv.filter((arg) => arg !== "--help" && arg !== "-h");
84
+ if (unknownArgs.length > 0) {
85
+ throw new Error(`Unknown argument: ${unknownArgs[0]}`);
86
+ }
87
+ const rawBaseUrl = env["SHIPMAIL_BASE_URL"];
88
+ const allowInsecure = env["SHIPMAIL_ALLOW_INSECURE_BASE_URL"] === "1";
89
+ const baseUrl = rawBaseUrl !== void 0 && rawBaseUrl.length > 0 ? validateBaseUrl(rawBaseUrl, allowInsecure) : void 0;
90
+ return {
91
+ apiKey: readApiKey(),
92
+ baseUrl,
93
+ organizationId: env["SHIPMAIL_ORGANIZATION_ID"] || void 0
94
+ };
95
+ }
96
+
97
+ // src/server.ts
98
+ import { McpServer as McpServer5 } from "@modelcontextprotocol/server";
99
+ import { ShipMailClient } from "shipmail";
100
+
101
+ // src/cross-organization-tools.ts
102
+ import { performance } from "perf_hooks";
103
+ import "@modelcontextprotocol/server";
104
+ import { ShipMailError as ShipMailError2 } from "shipmail";
105
+ import { z as z2 } from "zod/v4";
106
+
7
107
  // src/capabilities.ts
8
108
  import { API_KEY_SCOPES, apiKeyScopesGrant } from "shipmail/api-key-scopes";
9
109
  var MCP_CAPABILITY_VERSION = "1.0.0";
@@ -499,106 +599,6 @@ function getMcpCapability(toolName) {
499
599
  return MCP_CAPABILITIES.find((capability) => capability.toolName === toolName);
500
600
  }
501
601
 
502
- // src/config.ts
503
- import { readFileSync } from "fs";
504
- import { env } from "process";
505
- var DEFAULT_BASE_URL = "https://shipmail.to/api/v1";
506
- var HELP_TEXT = `shipmail-mcp
507
-
508
- Usage:
509
- shipmail-mcp
510
-
511
- Environment:
512
- SHIPMAIL_API_KEY Required ShipMail API key (or use SHIPMAIL_API_KEY_FILE).
513
- SHIPMAIL_API_KEY_FILE Optional path to a file containing the API key. Takes precedence over
514
- SHIPMAIL_API_KEY when set; reduces env-trace leak surface for hosts that
515
- log environment variables.
516
- SHIPMAIL_BASE_URL Optional API base URL. Must be https. Defaults to ${DEFAULT_BASE_URL}.
517
- SHIPMAIL_ORGANIZATION_ID
518
- Optional delegated child organization ID for infrastructure tools.
519
- SHIPMAIL_ALLOW_INSECURE_BASE_URL=1
520
- Permit non-https or non-shipmail.to base URL (development only).
521
-
522
- ShipMail discovers tools from the API key's live permissions at startup. Change scopes, resources,
523
- recipient rules, and send budgets in ShipMail Settings.`;
524
- var API_KEY_HELP = "SHIPMAIL_API_KEY (or SHIPMAIL_API_KEY_FILE) is required. Create an API key in ShipMail, then run `SHIPMAIL_API_KEY=sm_live_... shipmail-mcp`.";
525
- function readApiKey() {
526
- const filePath = env["SHIPMAIL_API_KEY_FILE"];
527
- if (filePath !== void 0 && filePath.length > 0) {
528
- let raw;
529
- try {
530
- raw = readFileSync(filePath, "utf8");
531
- } catch (error) {
532
- throw new Error(
533
- `Failed to read SHIPMAIL_API_KEY_FILE at ${filePath}: ${error instanceof Error ? error.message : String(error)}`,
534
- { cause: error }
535
- );
536
- }
537
- const trimmed = raw.trim();
538
- if (trimmed.length === 0) {
539
- throw new Error(`SHIPMAIL_API_KEY_FILE at ${filePath} is empty.`);
540
- }
541
- return trimmed;
542
- }
543
- const direct = env["SHIPMAIL_API_KEY"];
544
- if (!direct) throw new Error(API_KEY_HELP);
545
- return direct;
546
- }
547
- var ALLOWED_BASE_URL_HOSTS = ["shipmail.to", "api.shipmail.to"];
548
- function validateBaseUrl(rawValue, allowInsecure) {
549
- let parsed;
550
- try {
551
- parsed = new URL(rawValue);
552
- } catch {
553
- throw new Error(`SHIPMAIL_BASE_URL is not a valid URL: ${rawValue}`);
554
- }
555
- if (allowInsecure) return parsed.toString().replace(/\/+$/, "");
556
- if (parsed.protocol !== "https:") {
557
- throw new Error(
558
- "SHIPMAIL_BASE_URL must use https. Set SHIPMAIL_ALLOW_INSECURE_BASE_URL=1 for development."
559
- );
560
- }
561
- const host = parsed.hostname.toLowerCase();
562
- const isAllowedHost = ALLOWED_BASE_URL_HOSTS.some(
563
- (allowed) => host === allowed || host.endsWith(`.${allowed}`)
564
- );
565
- if (!isAllowedHost) {
566
- throw new Error(
567
- `SHIPMAIL_BASE_URL host "${host}" is not allowed. Set SHIPMAIL_ALLOW_INSECURE_BASE_URL=1 for development.`
568
- );
569
- }
570
- return parsed.toString().replace(/\/+$/, "");
571
- }
572
- function readConfig(argv = process.argv.slice(2)) {
573
- if (argv.includes("--tools")) {
574
- throw new Error(
575
- "--tools was removed. ShipMail MCP tools now follow the API key permissions configured in ShipMail Settings."
576
- );
577
- }
578
- const unknownArgs = argv.filter((arg) => arg !== "--help" && arg !== "-h");
579
- if (unknownArgs.length > 0) {
580
- throw new Error(`Unknown argument: ${unknownArgs[0]}`);
581
- }
582
- const rawBaseUrl = env["SHIPMAIL_BASE_URL"];
583
- const allowInsecure = env["SHIPMAIL_ALLOW_INSECURE_BASE_URL"] === "1";
584
- const baseUrl = rawBaseUrl !== void 0 && rawBaseUrl.length > 0 ? validateBaseUrl(rawBaseUrl, allowInsecure) : void 0;
585
- return {
586
- apiKey: readApiKey(),
587
- baseUrl,
588
- organizationId: env["SHIPMAIL_ORGANIZATION_ID"] || void 0
589
- };
590
- }
591
-
592
- // src/server.ts
593
- import { McpServer as McpServer5 } from "@modelcontextprotocol/server";
594
- import { ShipMailClient } from "shipmail";
595
-
596
- // src/cross-organization-tools.ts
597
- import { performance } from "perf_hooks";
598
- import "@modelcontextprotocol/server";
599
- import { ShipMailError as ShipMailError2 } from "shipmail";
600
- import { z as z2 } from "zod/v4";
601
-
602
602
  // src/result.ts
603
603
  import { ShipMailError, ValidationError } from "shipmail";
604
604
 
@@ -1211,6 +1211,31 @@ var inboxBodyValueSchema = z.object({
1211
1211
  value: z.string(),
1212
1212
  is_encoding_problem: z.boolean()
1213
1213
  });
1214
+ var emailAuthVerdictSchema = z.enum([
1215
+ "pass",
1216
+ "fail",
1217
+ "softfail",
1218
+ "neutral",
1219
+ "none",
1220
+ "temperror",
1221
+ "permerror",
1222
+ "policy",
1223
+ "unknown"
1224
+ ]);
1225
+ var emailAuthenticationResultsSchema = z.object({
1226
+ spf: emailAuthVerdictSchema,
1227
+ dkim: emailAuthVerdictSchema,
1228
+ dmarc: emailAuthVerdictSchema,
1229
+ spam: z.object({
1230
+ isSpam: z.boolean().nullable(),
1231
+ scoreMilli: z.number().int().nullable()
1232
+ }),
1233
+ raw: z.object({
1234
+ authenticationResults: z.string().nullable(),
1235
+ receivedSpf: z.string().nullable(),
1236
+ spamStatus: z.string().nullable()
1237
+ })
1238
+ });
1214
1239
  var inboxMessageSchema = z.object({
1215
1240
  object: z.literal("inbox_message"),
1216
1241
  id: z.string(),
@@ -1225,7 +1250,8 @@ var inboxMessageSchema = z.object({
1225
1250
  received_at: z.string(),
1226
1251
  preview: z.string(),
1227
1252
  has_attachment: z.boolean(),
1228
- size: z.number()
1253
+ size: z.number(),
1254
+ authentication_results: emailAuthenticationResultsSchema.nullable()
1229
1255
  });
1230
1256
  var inboxFullMessageSchema = inboxMessageSchema.omit({ object: true }).extend({
1231
1257
  object: z.literal("inbox_message_full"),
@@ -3829,7 +3855,8 @@ function toInboxMessageSummary(message) {
3829
3855
  received_at: message.received_at,
3830
3856
  preview: message.preview,
3831
3857
  has_attachment: message.has_attachment,
3832
- size: message.size
3858
+ size: message.size,
3859
+ authentication_results: message.authentication_results
3833
3860
  };
3834
3861
  }
3835
3862
  function toInboxMessageSummaries(messages) {
@@ -7141,7 +7168,7 @@ function registerTools(rawServer, client, allowedTools, grantedOrganizations = [
7141
7168
  }
7142
7169
 
7143
7170
  // src/version.ts
7144
- var VERSION = "0.6.4";
7171
+ var VERSION = "0.6.6";
7145
7172
 
7146
7173
  // src/server.ts
7147
7174
  var INSTRUCTIONS = `ShipMail MCP exposes the business email and calendar tools authorized by the connection's current ShipMail permissions.
@@ -7208,6 +7235,47 @@ function createShipMailMcpServer(config, allowedTools, organizationGrants = [])
7208
7235
  return server;
7209
7236
  }
7210
7237
 
7238
+ // src/startup.ts
7239
+ function writeStderrWarning(message) {
7240
+ process.stderr.write(`${message}
7241
+ `);
7242
+ }
7243
+ function errorMessage(error) {
7244
+ const message = error instanceof Error ? error.message : String(error);
7245
+ return message.replace(/\s+/g, " ").trim() || "Unknown error";
7246
+ }
7247
+ async function resolveAllowedTools(client, writeWarning = writeStderrWarning) {
7248
+ let capabilities;
7249
+ try {
7250
+ capabilities = await client.capabilities.get();
7251
+ } catch (error) {
7252
+ writeWarning(
7253
+ `Could not fetch ShipMail capabilities (${errorMessage(error)}). The tool list is unverified and calls may fail.`
7254
+ );
7255
+ return new Set(MCP_TOOL_NAMES);
7256
+ }
7257
+ const serverMajor = capabilities.capability_version.split(".")[0];
7258
+ const supportedMajor = MCP_CAPABILITY_VERSION.split(".")[0];
7259
+ if (!serverMajor || serverMajor !== supportedMajor) {
7260
+ throw new Error(
7261
+ `ShipMail capability version ${capabilities.capability_version} is incompatible with this shipmail-mcp version. Upgrade shipmail-mcp before reconnecting.`
7262
+ );
7263
+ }
7264
+ const localTools = new Set(MCP_TOOL_NAMES);
7265
+ const allowedTools = new Set(
7266
+ capabilities.allowed_mcp_tools.filter((toolName) => localTools.has(toolName))
7267
+ );
7268
+ const missingTools = capabilities.allowed_mcp_tools.filter(
7269
+ (toolName) => !localTools.has(toolName)
7270
+ );
7271
+ if (missingTools.length > 0) {
7272
+ writeWarning(
7273
+ `ShipMail allows tools not implemented by this shipmail-mcp version: ${missingTools.join(", ")}. Upgrade to use them.`
7274
+ );
7275
+ }
7276
+ return allowedTools;
7277
+ }
7278
+
7211
7279
  // src/index.ts
7212
7280
  function installShutdownHandlers(server) {
7213
7281
  let shuttingDown = false;
@@ -7239,27 +7307,7 @@ async function main() {
7239
7307
  "X-ShipMail-Client-Version": VERSION
7240
7308
  }
7241
7309
  });
7242
- const capabilities = await client.capabilities.get();
7243
- const serverMajor = capabilities.capability_version.split(".")[0];
7244
- const supportedMajor = MCP_CAPABILITY_VERSION.split(".")[0];
7245
- if (!serverMajor || serverMajor !== supportedMajor) {
7246
- throw new Error(
7247
- `ShipMail capability version ${capabilities.capability_version} is incompatible with this shipmail-mcp version. Upgrade shipmail-mcp before reconnecting.`
7248
- );
7249
- }
7250
- const localTools = new Set(MCP_TOOL_NAMES);
7251
- const allowedTools = new Set(
7252
- capabilities.allowed_mcp_tools.filter((toolName) => localTools.has(toolName))
7253
- );
7254
- const missingTools = capabilities.allowed_mcp_tools.filter(
7255
- (toolName) => !localTools.has(toolName)
7256
- );
7257
- if (missingTools.length > 0) {
7258
- process.stderr.write(
7259
- `ShipMail allows tools not implemented by this shipmail-mcp version: ${missingTools.join(", ")}. Upgrade to use them.
7260
- `
7261
- );
7262
- }
7310
+ const allowedTools = await resolveAllowedTools(client);
7263
7311
  const server = serveStdio(() => createShipMailMcpServer(config, allowedTools), {
7264
7312
  legacy: "reject"
7265
7313
  });
package/dist/server.js CHANGED
@@ -1114,6 +1114,31 @@ var inboxBodyValueSchema = z.object({
1114
1114
  value: z.string(),
1115
1115
  is_encoding_problem: z.boolean()
1116
1116
  });
1117
+ var emailAuthVerdictSchema = z.enum([
1118
+ "pass",
1119
+ "fail",
1120
+ "softfail",
1121
+ "neutral",
1122
+ "none",
1123
+ "temperror",
1124
+ "permerror",
1125
+ "policy",
1126
+ "unknown"
1127
+ ]);
1128
+ var emailAuthenticationResultsSchema = z.object({
1129
+ spf: emailAuthVerdictSchema,
1130
+ dkim: emailAuthVerdictSchema,
1131
+ dmarc: emailAuthVerdictSchema,
1132
+ spam: z.object({
1133
+ isSpam: z.boolean().nullable(),
1134
+ scoreMilli: z.number().int().nullable()
1135
+ }),
1136
+ raw: z.object({
1137
+ authenticationResults: z.string().nullable(),
1138
+ receivedSpf: z.string().nullable(),
1139
+ spamStatus: z.string().nullable()
1140
+ })
1141
+ });
1117
1142
  var inboxMessageSchema = z.object({
1118
1143
  object: z.literal("inbox_message"),
1119
1144
  id: z.string(),
@@ -1128,7 +1153,8 @@ var inboxMessageSchema = z.object({
1128
1153
  received_at: z.string(),
1129
1154
  preview: z.string(),
1130
1155
  has_attachment: z.boolean(),
1131
- size: z.number()
1156
+ size: z.number(),
1157
+ authentication_results: emailAuthenticationResultsSchema.nullable()
1132
1158
  });
1133
1159
  var inboxFullMessageSchema = inboxMessageSchema.omit({ object: true }).extend({
1134
1160
  object: z.literal("inbox_message_full"),
@@ -3732,7 +3758,8 @@ function toInboxMessageSummary(message) {
3732
3758
  received_at: message.received_at,
3733
3759
  preview: message.preview,
3734
3760
  has_attachment: message.has_attachment,
3735
- size: message.size
3761
+ size: message.size,
3762
+ authentication_results: message.authentication_results
3736
3763
  };
3737
3764
  }
3738
3765
  function toInboxMessageSummaries(messages) {
@@ -7044,7 +7071,7 @@ function registerTools(rawServer, client, allowedTools, grantedOrganizations = [
7044
7071
  }
7045
7072
 
7046
7073
  // src/version.ts
7047
- var VERSION = "0.6.4";
7074
+ var VERSION = "0.6.6";
7048
7075
 
7049
7076
  // src/server.ts
7050
7077
  var INSTRUCTIONS = `ShipMail MCP exposes the business email and calendar tools authorized by the connection's current ShipMail permissions.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shipmail-mcp",
3
- "version": "0.6.4",
3
+ "version": "0.6.6",
4
4
  "mcpName": "io.github.shipmail-to/shipmail-mcp",
5
5
  "description": "Official Model Context Protocol (MCP) server for Shipmail, a business email provider with REST API, webhooks, and custom-domain inboxes for AI agents.",
6
6
  "type": "module",
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "@modelcontextprotocol/server": "2.0.0",
62
- "shipmail": "0.4.10",
62
+ "shipmail": "0.4.12",
63
63
  "zod": "4.4.3"
64
64
  },
65
65
  "devDependencies": {
package/server.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "url": "https://github.com/shipmail-to/shipmail-mcp",
7
7
  "source": "github"
8
8
  },
9
- "version": "0.6.4",
9
+ "version": "0.6.6",
10
10
  "websiteUrl": "https://shipmail.to/docs/mcp",
11
11
  "remotes": [
12
12
  {
@@ -27,7 +27,7 @@
27
27
  "registryType": "npm",
28
28
  "registryBaseUrl": "https://registry.npmjs.org",
29
29
  "identifier": "shipmail-mcp",
30
- "version": "0.6.4",
30
+ "version": "0.6.6",
31
31
  "transport": {
32
32
  "type": "stdio"
33
33
  },
package/smithery.yaml CHANGED
@@ -1,6 +1,6 @@
1
1
  # Smithery configuration file: https://smithery.ai/docs/build/project-config/smithery-yaml
2
2
  name: shipmail-mcp
3
- version: 0.6.4
3
+ version: 0.6.6
4
4
  description: Official Shipmail MCP server for AI-agent custom-domain business email inboxes with REST API and webhooks.
5
5
  author: ShipMail
6
6
  repository: https://github.com/shipmail-to/shipmail-mcp