MCP reply_to_thread quotes an empty message (or "undefined") under the attribution line

Description

Replies created through the MCP server’s reply_to_thread tool never quote the message they answer. Under the attribution line (“On Oct 6 2026, at 7:59 am, X wrote:”), the quote block is empty when the original message is HTML, and contains the literal word undefined when it is plaintext. It happens on every reply made with the tool, whatever the account.

The cause is in app/internal_packages/mcp-server/lib/mcp-tools.ts: reply_to_thread loads the thread’s messages with DatabaseStore.findAll(Message, { threadId }) without .include(Message.attributes.body), so the message passed to DraftFactory.createDraftForReply has no body. prepareBodyForQuoting then quotes undefined. get_thread already includes the body in the same file.

To Reproduce…

  1. Enable the MCP server with the read-write access level.
  2. From an MCP client, call reply_to_thread on a thread whose latest message is plaintext.
  3. Open the draft, or send it.
  4. See undefined in the quote block under the attribution line (an empty quote block if the latest message is HTML).

Expected Behavior

The reply quotes the latest message of the thread, as a reply written in the composer does.

Setup

  • OS and Version: macOS 15.7.7
  • Mailspring Version: 1.26.0 (still present on master at 68cbd67)

Additional Context

The fix is one line: add .include(Message.attributes.body) to that query. I have it ready on a branch with a regression spec (mcp-reply-tools-spec.ts), which fails without the fix and passes with it. I’m happy to open a pull request if you’d accept it.