Skip to main content
Glama
SpasticPalate

Proton MCP Server

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
NameRequiredDescriptionDefault
folderYes
uidYes
destinationYes

Implementation Reference

  • 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)}`,
            },
          ],
        };
      }
    }
  • Input validation schema for 'proton_move_email'.
    export const MoveEmailSchema = z.object({
      folder: z.string(),
      uid: z.number().int().positive(),
      destination: z.string(),
    });
  • 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)}`,
              },
            ],
          };
        }
      }
    );
  • 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();
      }
    }

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/SpasticPalate/proton-mcp-server'

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