Foundry376/Mailspring · error

Message '${messageId}' not found

Error message

Message '${messageId}' not found

What it means

Resource handler guard in the MCP server's registerResources: the message id decoded from a mailspring://message/{messageId}/attachment/{fileId} resource URI either does not exist in the local database or belongs to a message the MCP client is not allowed to read. Used to reject unauthorized or stale resource reads.

Source

Thrown at app/internal_packages/mcp-server/lib/mcp-tools.ts:355

      const start = Date.now();
      const audit = (resultSummary: string) =>
        addAuditEntry({
          timestamp: Date.now(),
          toolName: 'resources/read',
          params: uri.href.slice(0, 200),
          resultSummary,
          durationMs: Date.now() - start,
        });

      try {
        // Variables come from the SDK's template match on the raw URI, so
        // they preserve the ids' case (unlike uri.host, which URL lowercases).
        const messageId = decodeURIComponent(String(variables.messageId));
        const fileId = decodeURIComponent(String(variables.fileId));

        const message = await DatabaseStore.find<Message>(Message, messageId);
        if (!message || !isMessageAllowed(message)) {
          throw new Error(`Message '${messageId}' not found`);
        }
        const file = (message.files || []).find((f) => f.id === fileId);
        if (!file) {
          throw new Error(`Message '${messageId}' has no attachment with id '${fileId}'`);
        }
        const filePath = await attachmentPathOnDisk(file);
        if (!filePath) {
          throw new Error(
            `Attachment '${file.displayName()}' has not been downloaded — call the get_attachment tool first.`
          );
        }

        const buffer = await fs.promises.readFile(filePath);
        audit('ok');
        return {
          contents: [
            { uri: uri.href, mimeType: mimeTypeForFile(file), blob: buffer.toString('base64') },
          ],

View on GitHub (pinned to 648c685d60)

Solutions

  1. Have the client re-list resources to obtain fresh ids after the database syncs
  2. Verify the message id is URL-encoded correctly when constructing the resource URI
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at app/internal_packages/mcp-server/lib/mcp-tools.ts:355 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Foundry376/Mailspring@648c685d60 (2026-09-03). Data as JSON: /api/errors/2451bf25b2dfaa4a. Report an issue: GitHub.