Skip to main content
Glama

moveEmail

Transfer emails between folders in Mail MCP Tool by specifying source and target locations with unique identifiers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uidYes
sourceFolderYes
targetFolderYes

Implementation Reference

  • Registration of the 'moveEmail' MCP tool including schema definition and handler function that validates input and delegates to MailService.moveMail, returning success/failure messages.
    this.server.tool( "moveEmail", { uid: z.number(), sourceFolder: z.string(), targetFolder: z.string() }, async ({ uid, sourceFolder, targetFolder }) => { try { const numericUid = Number(uid); const success = await this.mailService.moveMail(numericUid, sourceFolder, targetFolder); if (success) { return { content: [ { type: "text", text: `邮件(UID: ${numericUid})已成功从"${sourceFolder}"移动到"${targetFolder}"文件夹` } ] }; } else { return { content: [ { type: "text", text: `移动邮件(UID: ${numericUid})失败` } ] }; } } catch (error) { return { content: [ { type: "text", text: `移动邮件时发生错误: ${error instanceof Error ? error.message : String(error)}` } ] }; } } );
  • Zod input schema for moveEmail tool: uid (number), sourceFolder (string), targetFolder (string).
    uid: z.number(), sourceFolder: z.string(), targetFolder: z.string()
  • Handler function for moveEmail tool that executes the move operation via mailService and formats the response.
    async ({ uid, sourceFolder, targetFolder }) => { try { const numericUid = Number(uid); const success = await this.mailService.moveMail(numericUid, sourceFolder, targetFolder); if (success) { return { content: [ { type: "text", text: `邮件(UID: ${numericUid})已成功从"${sourceFolder}"移动到"${targetFolder}"文件夹` } ] }; } else { return { content: [ { type: "text", text: `移动邮件(UID: ${numericUid})失败` } ] }; } } catch (error) { return { content: [ { type: "text", text: `移动邮件时发生错误: ${error instanceof Error ? error.message : String(error)}` } ] }; } }
  • Core implementation of email moving logic in MailService using IMAP client: opens source folder and calls imapClient.move(uid, targetFolder).
    async moveMail(uid: number | string, sourceFolder: string, targetFolder: string): Promise<boolean> { await this.connectImap(); // 确保 uid 为数字类型 const numericUid = typeof uid === 'string' ? parseInt(uid, 10) : uid; return new Promise((resolve, reject) => { this.imapClient.openBox(sourceFolder, false, (err) => { if (err) { reject(err); return; } this.imapClient.move(numericUid, targetFolder, (err) => { if (err) { reject(err); return; } resolve(true); }); }); }); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/shuakami/mcp-mail'

If you have feedback or need assistance with the MCP directory API, please join our Discord server