proton_move_email
Move emails between folders in Proton Mail by specifying source folder, email UID, and destination folder to organize your inbox.
Instructions
Move an email from one folder to another. Specify source folder, email UID, and destination folder.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| folder | Yes | ||
| uid | Yes | ||
| destination | Yes |
Implementation Reference
- src/tools/move.ts:25-47 (handler)Handler for the 'proton_move_email' tool, using moveMessage from imap.ts.
async (params: z.infer<typeof MoveEmailSchema>) => { try { await moveMessage(params.folder, params.uid, params.destination); return { content: [ { type: 'text', text: `Email UID ${params.uid} moved successfully from "${params.folder}" to "${params.destination}"`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error moving email: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } - src/schemas/index.ts:51-55 (schema)Input validation schema for 'proton_move_email'.
export const MoveEmailSchema = z.object({ folder: z.string(), uid: z.number().int().positive(), destination: z.string(), }); - src/tools/move.ts:12-48 (registration)Registration of the 'proton_move_email' tool in the MCP server.
server.registerTool( 'proton_move_email', { title: 'Move Email', description: 'Move an email from one folder to another. Specify source folder, email UID, and destination folder.', inputSchema: MoveEmailSchema, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, }, async (params: z.infer<typeof MoveEmailSchema>) => { try { await moveMessage(params.folder, params.uid, params.destination); return { content: [ { type: 'text', text: `Email UID ${params.uid} moved successfully from "${params.folder}" to "${params.destination}"`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error moving email: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } ); - src/services/imap.ts:312-332 (helper)Actual IMAP implementation for moving an email.
export async function moveMessage( sourceFolder: string, uid: number, destinationFolder: string ): Promise<void> { const client = await getImapClient(); try { const lock = await client.getMailboxLock(sourceFolder); try { await client.mailboxOpen(sourceFolder); const result = await client.messageMove(String(uid), destinationFolder, { uid: true }); if (!result) { throw new Error(`Message UID ${uid} not found in "${sourceFolder}"`); } } finally { lock.release(); } } finally { await client.logout(); } }