proton-mail-bridge-client 2.7.1 → 2.7.3

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.
Files changed (37) hide show
  1. package/README.md +3 -0
  2. package/dist/index.d.ts +6 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +116 -8
  5. package/dist/index.js.map +1 -1
  6. package/dist/scripts/setup-claude-desktop.d.ts +12 -0
  7. package/dist/scripts/setup-claude-desktop.d.ts.map +1 -1
  8. package/dist/scripts/setup-claude-desktop.js +43 -2
  9. package/dist/scripts/setup-claude-desktop.js.map +1 -1
  10. package/dist/services/delivery-queue-service.d.ts.map +1 -1
  11. package/dist/services/delivery-queue-service.js +7 -6
  12. package/dist/services/delivery-queue-service.js.map +1 -1
  13. package/dist/services/draft-store-service.d.ts.map +1 -1
  14. package/dist/services/draft-store-service.js +10 -9
  15. package/dist/services/draft-store-service.js.map +1 -1
  16. package/dist/services/local-index-service.d.ts.map +1 -1
  17. package/dist/services/local-index-service.js +6 -6
  18. package/dist/services/local-index-service.js.map +1 -1
  19. package/dist/services/simple-imap-service.d.ts +2 -0
  20. package/dist/services/simple-imap-service.d.ts.map +1 -1
  21. package/dist/services/simple-imap-service.js +33 -12
  22. package/dist/services/simple-imap-service.js.map +1 -1
  23. package/dist/services/snooze-service.d.ts.map +1 -1
  24. package/dist/services/snooze-service.js +5 -4
  25. package/dist/services/snooze-service.js.map +1 -1
  26. package/dist/services/template-service.d.ts.map +1 -1
  27. package/dist/services/template-service.js +3 -2
  28. package/dist/services/template-service.js.map +1 -1
  29. package/dist/utils/helpers.d.ts +1 -0
  30. package/dist/utils/helpers.d.ts.map +1 -1
  31. package/dist/utils/helpers.js +59 -13
  32. package/dist/utils/helpers.js.map +1 -1
  33. package/dist/utils/own-record.d.ts +2 -0
  34. package/dist/utils/own-record.d.ts.map +1 -0
  35. package/dist/utils/own-record.js +6 -0
  36. package/dist/utils/own-record.js.map +1 -0
  37. package/package.json +2 -1
package/README.md CHANGED
@@ -681,6 +681,9 @@ To check a real Bridge yourself, run the read-only smoke test: `PROTONMAIL_USERN
681
681
  **"Wrong password" or connection refused**
682
682
  Make sure you're using the **Bridge password**, not your Proton account password. Find it in the Bridge app under Account → Copy password. Bridge must be running before the MCP server or CLI can connect.
683
683
 
684
+ **Every tool answers "not configured"**
685
+ `PROTONMAIL_USERNAME` and `PROTONMAIL_PASSWORD` are not set for the server. Since 2.7.2 it still starts without them, lists its tools and answers each call with that message (it used to exit at once, which clients showed as "Connection closed"). Set both (the password is the Bridge password) and restart; `proton-mail-bridge-client setup-claude-desktop` does it for Claude Desktop. Any other configuration mistake, such as a bad port, still stops the server at start.
686
+
684
687
  **macOS native module crash after update**
685
688
  `better-sqlite3` is a native binary built for your machine. After a major Node.js upgrade or environment change, rebuild it:
686
689
  ```bash
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ import { AccountManager, type AccountBundle } from "./services/account-manager.j
10
10
  export declare const CORE_TOOL_NAMES: Set<string>;
11
11
  export declare function withSources<T>(value: T, _sources: CitationSource[]): T;
12
12
  export declare function withAudit<T>(auditService: AuditService, tool: string, input: Record<string, unknown>, operation: () => Promise<T>): Promise<T>;
13
+ export declare function ignoredArguments(toolName: string, args: unknown): string[];
13
14
  export declare function optionalClearableString(args: Record<string, unknown>, key: string): string | undefined;
14
15
  export declare function headerString(headers: Record<string, unknown> | undefined, name: string): string | undefined;
15
16
  export declare function parseAuthenticationResults(value?: string): {
@@ -108,6 +109,9 @@ export declare function groupEmailIdsByAccount(accountManager: AccountManager, e
108
109
  export declare function prefixBulkResult(result: BulkOperationResult, slug: string | undefined): BulkOperationResult;
109
110
  export declare function prefixNotFound(excluded: BulkExcludedEmailId[], slug: string | undefined): BulkExcludedEmailId[];
110
111
  export declare function mergeBulkResults(results: BulkOperationResult[]): BulkOperationResult;
112
+ export declare class MissingCredentialsError extends Error {
113
+ constructor();
114
+ }
111
115
  export declare function buildConfigFromEnv(): ProtonMailConfig;
112
116
  export declare function createServer(config: ProtonMailConfig, options?: {
113
117
  startBackgroundSync?: boolean;
@@ -157,6 +161,8 @@ export declare function createServer(config: ProtonMailConfig, options?: {
157
161
  accountManager: AccountManager;
158
162
  };
159
163
  export declare function stopAllAccounts(bundles: Array<Pick<AccountBundle, "backgroundSyncService" | "deliveryQueueService" | "snoozeService" | "imapService" | "smtpService" | "localIndexService">>, timeoutMs?: number): Promise<void>;
164
+ export declare const NOT_CONFIGURED_MESSAGE: string;
165
+ export declare function createUnconfiguredServer(): Server;
160
166
  export declare function main(): Promise<void>;
161
167
  export {};
162
168
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AASA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAYnE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAuD,MAAM,mCAAmC,CAAC;AAC3H,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAA2H,iBAAiB,EAA+B,MAAM,mCAAmC,CAAC;AAC5N,OAAO,EAAmC,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,KAAK,EAMV,mBAAmB,EACnB,cAAc,EACd,WAAW,EAIX,WAAW,EAIX,gBAAgB,EAChB,cAAc,EAGf,MAAM,kBAAkB,CAAC;AA2B1B,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAsuDnF,eAAO,MAAM,eAAe,aA2C1B,CAAC;AAqCH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,CAAC,CAEtE;AAmGD,wBAAsB,SAAS,CAAC,CAAC,EAC/B,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,MAAM,EACZ,KA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mB,CAAC,EAAE,OAAO,CAAC;CAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmpJP;AAOD,wBAAsB,eAAe,CACnC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,uBAAuB,GAAG,sBAAsB,GAAG,eAAe,GAAG,aAAa,GAAG,aAAa,GAAG,mBAAmB,CAAC,CAAC,EAC7J,SAAS,SAAQ,GAChB,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,eAAO,MAAM,sBAAsB,QAGiG,CAAC;AAIrI,wBAAgB,wBAAwB,IAAI,MAAM,CAQjD;AAaD,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAyE1C"}
package/dist/index.js CHANGED
@@ -1743,6 +1743,10 @@ const TOOLS = [
1743
1743
  },
1744
1744
  ];
1745
1745
  // Core tier: the 20 tools that cover ~80% of daily email use.
1746
+ function listedTools() {
1747
+ const tier = (process.env.PROTONMAIL_TOOL_TIER ?? "full").trim().toLowerCase();
1748
+ return tier === "core" ? [...TOOLS].filter((t) => CORE_TOOL_NAMES.has(t.name)) : [...TOOLS];
1749
+ }
1746
1750
  // Set PROTONMAIL_TOOL_TIER=core to expose only these — reduces context-window burn
1747
1751
  // significantly on every session. Default is "full" (all tools).
1748
1752
  export const CORE_TOOL_NAMES = new Set([
@@ -1849,6 +1853,8 @@ const AUDIT_MAX_DEPTH = 8;
1849
1853
  const AUDIT_REDACTED_KEYS = new Set([
1850
1854
  "body", "html", "text", "htmlBody", "textBody", "markdownBody", "customMessage", "notes", "bodyEdits",
1851
1855
  "raw", "rawBase64", "base64", "content", "find", "replace", "signature",
1856
+ // Parts of a received message that a tool result could carry: a preview or attachment text can hold a code or a secret.
1857
+ "preview", "snippet", "attachmentText", "latestPreview",
1852
1858
  ]);
1853
1859
  const AUDIT_SECRET_KEY = /pass(word|wd|phrase)?$|secret|token|api[-_]?key|authoriz|credential|cookie|private[-_]?key/i;
1854
1860
  function sanitizeAuditValue(value, depth = 0, seen = new WeakSet()) {
@@ -1959,6 +1965,58 @@ function parseBodyEdits(value) {
1959
1965
  return { find: edit.find, replace: edit.replace, ...(edit.all === true ? { all: true } : {}) };
1960
1966
  });
1961
1967
  }
1968
+ // Moving a message into the Trash folder is trashing it: trash_email is literally a move there. The move tools
1969
+ // therefore need the "trash" permission as well as "move" when the destination is the Trash folder, or an
1970
+ // ALLOWED_ACTIONS list that leaves out "trash" could be sidestepped by moving to Trash instead.
1971
+ async function ensureMoveTargetAllowed(runtime, imap, targetFolder) {
1972
+ if (!targetFolder)
1973
+ return;
1974
+ // A call that can span accounts is checked against every account's own Trash folder: their names may differ.
1975
+ let unknown = false;
1976
+ for (const candidate of Array.isArray(imap) ? imap : [imap]) {
1977
+ const isTrash = await candidate.isTrashFolder(targetFolder);
1978
+ if (isTrash) {
1979
+ ensureEmailActionAllowed(runtime, "trash");
1980
+ return;
1981
+ }
1982
+ if (isTrash === undefined)
1983
+ unknown = true;
1984
+ }
1985
+ // Not being able to tell must not open a way round the permission: with "trash" not allowed, refuse.
1986
+ if (unknown && !runtime.allowedActions.includes("trash")) {
1987
+ throw new McpError(ErrorCode.InternalError, `Cannot tell whether ${targetFolder} is the Trash folder (the folder list could not be read), and the trash action is not allowed. Try again when Bridge answers.`);
1988
+ }
1989
+ }
1990
+ // Arguments a tool does not declare are ignored (clients send extra fields, and refusing them would break
1991
+ // those clients), but silently: `folder` on get_threads did nothing for a long time and nobody was told. The
1992
+ // result now carries a note naming them, so the caller (usually a model) learns the argument had no effect.
1993
+ export function ignoredArguments(toolName, args) {
1994
+ const tool = TOOLS.find((candidate) => candidate.name === toolName);
1995
+ if (!tool || !args || typeof args !== "object" || Array.isArray(args)) {
1996
+ return [];
1997
+ }
1998
+ const declared = new Set(Object.keys(tool.inputSchema.properties ?? {}));
1999
+ return Object.keys(args).filter((key) => !declared.has(key));
2000
+ }
2001
+ function withIgnoredArgumentsNote(handler) {
2002
+ return async (request) => {
2003
+ const result = await handler(request);
2004
+ const ignored = ignoredArguments(request.params.name, request.params.arguments);
2005
+ if (ignored.length === 0) {
2006
+ return result;
2007
+ }
2008
+ // The names come from the caller; keep the note short however many or however long they are.
2009
+ const shown = ignored.slice(0, 10).map((key) => `"${key.length > 64 ? `${key.slice(0, 64)}...` : key}"`);
2010
+ if (ignored.length > shown.length)
2011
+ shown.push(`and ${ignored.length - shown.length} more`);
2012
+ logger.warn("Tool call had arguments the tool does not accept", "MCPServer", { name: request.params.name, ignored: shown });
2013
+ const tool = TOOLS.find((candidate) => candidate.name === request.params.name);
2014
+ const accepted = Object.keys(tool?.inputSchema?.properties ?? {});
2015
+ const note = `Note: ${request.params.name} does not accept ${shown.join(", ")}; ignored. ` +
2016
+ (accepted.length > 0 ? `It accepts: ${accepted.join(", ")}.` : "It takes no arguments.");
2017
+ return { ...result, content: [...result.content, { type: "text", text: note }] };
2018
+ };
2019
+ }
1962
2020
  function asObject(value) {
1963
2021
  if (!value || typeof value !== "object" || Array.isArray(value)) {
1964
2022
  return {};
@@ -3586,11 +3644,20 @@ function parseAdditionalAccountsEnv(primary) {
3586
3644
  };
3587
3645
  });
3588
3646
  }
3647
+ // The one configuration error the server can still answer: without a login it cannot reach Bridge, but it can
3648
+ // list its tools and say what is missing (registries and MCP clients start servers without credentials to
3649
+ // inspect them, and "Connection closed" tells nobody anything).
3650
+ export class MissingCredentialsError extends Error {
3651
+ constructor() {
3652
+ super("Missing required environment variables or secret sources: PROTONMAIL_USERNAME and PROTONMAIL_PASSWORD.");
3653
+ this.name = "MissingCredentialsError";
3654
+ }
3655
+ }
3589
3656
  export function buildConfigFromEnv() {
3590
3657
  const username = readEnvValue("PROTONMAIL_USERNAME");
3591
3658
  const password = readEnvValue("PROTONMAIL_PASSWORD");
3592
3659
  if (!username || !password) {
3593
- throw new Error("Missing required environment variables or secret sources: PROTONMAIL_USERNAME and PROTONMAIL_PASSWORD.");
3660
+ throw new MissingCredentialsError();
3594
3661
  }
3595
3662
  validatePortEnv("PROTONMAIL_SMTP_PORT");
3596
3663
  const smtpPort = parseIntegerEnv("PROTONMAIL_SMTP_PORT", 1025, 1, 65_535);
@@ -3831,10 +3898,7 @@ export function createServer(config, options = {}) {
3831
3898
  resources: {},
3832
3899
  },
3833
3900
  });
3834
- server.setRequestHandler(ListToolsRequestSchema, async () => {
3835
- const tier = (process.env.PROTONMAIL_TOOL_TIER ?? "full").trim().toLowerCase();
3836
- return { tools: tier === "core" ? [...TOOLS].filter((t) => CORE_TOOL_NAMES.has(t.name)) : [...TOOLS] };
3837
- });
3901
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: listedTools() }));
3838
3902
  server.setRequestHandler(ListResourcesRequestSchema, async (request) => {
3839
3903
  const cursor = request.params?.cursor ? Number.parseInt(request.params.cursor, 10) : 0;
3840
3904
  // Fan out across every configured account and prefix non-primary ids exactly as the
@@ -3970,7 +4034,7 @@ export function createServer(config, options = {}) {
3970
4034
  }
3971
4035
  }
3972
4036
  });
3973
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
4037
+ server.setRequestHandler(CallToolRequestSchema, withIgnoredArgumentsNote(async (request) => {
3974
4038
  const name = request.params.name;
3975
4039
  const args = asObject(request.params.arguments);
3976
4040
  logger.debug("Handling tool call", "MCPServer", { name, argKeys: Object.keys(args || {}) });
@@ -5600,6 +5664,7 @@ export function createServer(config, options = {}) {
5600
5664
  throw new McpError(ErrorCode.InvalidParams, "Provide emailIds OR match, not both.");
5601
5665
  const folder = optionalString(args, "folder") ?? "INBOX";
5602
5666
  const targetFolder = requireString(args, "targetFolder");
5667
+ await ensureMoveTargetAllowed(config.runtime, accountManager.all().map((entry) => entry.imapService), targetFolder);
5603
5668
  const max = getBulkMaxBatchSize(args);
5604
5669
  const dryRun = normalizeBoolean(args.dryRun, false);
5605
5670
  // emailIds can span multiple configured accounts (a "<slug>::"
@@ -5917,6 +5982,7 @@ export function createServer(config, options = {}) {
5917
5982
  // (e.g. a match/threading key that could resolve differently per
5918
5983
  // account) is out of scope for this pass.
5919
5984
  const { bundle, rest: messageId } = resolveAccountForEmailId(requireString(args, "messageId"));
5985
+ await ensureMoveTargetAllowed(config.runtime, bundle.imapService, requireString(args, "destination"));
5920
5986
  const result = await withAudit(bundle.auditService, name, args, () => bundle.imapService.moveThread({
5921
5987
  messageId,
5922
5988
  destination: requireString(args, "destination"),
@@ -6045,6 +6111,7 @@ export function createServer(config, options = {}) {
6045
6111
  const rawEmailId = requireString(args, "emailId");
6046
6112
  const { bundle, rest: emailId } = resolveAccountForEmailId(rawEmailId);
6047
6113
  const targetFolder = requireString(args, "targetFolder");
6114
+ await ensureMoveTargetAllowed(config.runtime, bundle.imapService, targetFolder);
6048
6115
  const uidValidity = parseEmailId(emailId).uidValidity;
6049
6116
  const result = await withAudit(auditService, name, args, async () => {
6050
6117
  try {
@@ -6118,6 +6185,7 @@ export function createServer(config, options = {}) {
6118
6185
  ensureEmailActionAllowed(config.runtime, "restore");
6119
6186
  const rawEmailId = requireString(args, "emailId");
6120
6187
  const { bundle, rest: emailId } = resolveAccountForEmailId(rawEmailId);
6188
+ await ensureMoveTargetAllowed(config.runtime, bundle.imapService, optionalString(args, "targetFolder"));
6121
6189
  const uidValidity = parseEmailId(emailId).uidValidity;
6122
6190
  const result = await withAudit(auditService, name, args, async () => bundle.imapService.restoreEmail(emailId, optionalString(args, "targetFolder"), uidValidity));
6123
6191
  const targetEmailId = result.targetEmailId ? prefixedIdFor(bundle, result.targetEmailId) : undefined;
@@ -6266,6 +6334,9 @@ export function createServer(config, options = {}) {
6266
6334
  const continueOnError = normalizeBoolean(args.continueOnError, true);
6267
6335
  const dryRun = normalizeBoolean(args.dryRun, false);
6268
6336
  const targetFolder = optionalString(args, "targetFolder");
6337
+ if (action === "move" || action === "restore") {
6338
+ await ensureMoveTargetAllowed(config.runtime, accountManager.all().map((entry) => entry.imapService), targetFolder);
6339
+ }
6269
6340
  const groups = groupEmailIdsByAccount(accountManager, emailIds);
6270
6341
  const groupResults = [];
6271
6342
  for (const [slug, group] of groups) {
@@ -7423,6 +7494,9 @@ export function createServer(config, options = {}) {
7423
7494
  const thread = await bundle.localIndexService.getThreadById(threadId);
7424
7495
  const action = requireEmailAction(args);
7425
7496
  ensureEmailActionAllowed(config.runtime, action);
7497
+ if (action === "move" || action === "restore") {
7498
+ await ensureMoveTargetAllowed(config.runtime, bundle.imapService, optionalString(args, "targetFolder"));
7499
+ }
7426
7500
  const unreadOnly = normalizeBoolean(args.unreadOnly, false);
7427
7501
  const emailIds = [...new Set(thread.messages
7428
7502
  .filter((message) => !unreadOnly || !message.isRead)
@@ -7664,7 +7738,7 @@ export function createServer(config, options = {}) {
7664
7738
  ?? "An internal error occurred. Check get_logs for details, or run run_doctor for a full connectivity check.";
7665
7739
  throw new McpError(ErrorCode.InternalError, message);
7666
7740
  }
7667
- });
7741
+ }));
7668
7742
  return {
7669
7743
  server,
7670
7744
  smtpService,
@@ -7698,8 +7772,42 @@ export async function stopAllAccounts(bundles, timeoutMs = 3_000) {
7698
7772
  if (timer)
7699
7773
  clearTimeout(timer);
7700
7774
  }
7775
+ export const NOT_CONFIGURED_MESSAGE = "Proton Mail Bridge Client is not configured: PROTONMAIL_USERNAME and PROTONMAIL_PASSWORD are not set. " +
7776
+ "Set them to your Bridge login (the password is the one the Proton Mail Bridge app shows under your account, " +
7777
+ "not your Proton password) and restart the server. `proton-mail-bridge-client setup-claude-desktop` does this for Claude Desktop.";
7778
+ // Starts a server that lists its tools and answers every call with NOT_CONFIGURED_MESSAGE. It touches nothing:
7779
+ // no data directory, no Bridge connection, no background work.
7780
+ export function createUnconfiguredServer() {
7781
+ const server = new Server({ name: "proton-mail-bridge-client", version: PACKAGE_VERSION }, { capabilities: { tools: {} } });
7782
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: listedTools() }));
7783
+ server.setRequestHandler(CallToolRequestSchema, async () => ({
7784
+ isError: true,
7785
+ content: [{ type: "text", text: NOT_CONFIGURED_MESSAGE }],
7786
+ }));
7787
+ return server;
7788
+ }
7789
+ async function runUnconfigured() {
7790
+ logger.warn(NOT_CONFIGURED_MESSAGE, "MCPServer");
7791
+ const server = createUnconfiguredServer();
7792
+ const transport = new StdioServerTransport();
7793
+ await server.connect(transport);
7794
+ const leave = () => process.exit(0);
7795
+ process.on("SIGINT", leave);
7796
+ process.on("SIGTERM", leave);
7797
+ transport.onclose = leave;
7798
+ }
7701
7799
  export async function main() {
7702
- const config = buildConfigFromEnv();
7800
+ let config;
7801
+ try {
7802
+ config = buildConfigFromEnv();
7803
+ }
7804
+ catch (error) {
7805
+ if (error instanceof MissingCredentialsError) {
7806
+ await runUnconfigured();
7807
+ return;
7808
+ }
7809
+ throw error;
7810
+ }
7703
7811
  // Create the data directory explicitly with a restrictive mode as its very
7704
7812
  // first creation, before any service (draft store, template store, audit
7705
7813
  // log, local index, ...) does its own mkdir(dirname(...)) as a side effect