Skip to main content
Glama
SpasticPalate

Proton MCP Server

proton_delete_email

Delete Proton Mail emails by moving them to the Trash folder using folder names and email UIDs.

Instructions

Delete an email by moving it to the Trash folder. Use the folder name and email UID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderNoINBOX
uidYes

Implementation Reference

  • The handler for the proton_delete_email tool which calls the deleteMessage service.
    async (params: z.infer<typeof DeleteEmailSchema>) => {
      try {
        await deleteMessage(params.folder, params.uid);
    
        return {
          content: [
            {
              type: 'text',
              text: `Email UID ${params.uid} deleted successfully (moved to Trash)`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error deleting email: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
        };
      }
    }
  • The underlying service implementation that performs the actual email deletion by moving it to the 'Trash' folder via IMAP.
    export async function deleteMessage(folder: string, uid: number): Promise<void> {
      const client = await getImapClient();
      try {
        const lock = await client.getMailboxLock(folder);
        try {
          await client.mailboxOpen(folder);
          const result = await client.messageMove(String(uid), 'Trash', { uid: true });
          if (!result) {
            throw new Error(`Message UID ${uid} not found in "${folder}"`);
          }
        } finally {
          lock.release();
        }
      } finally {
        await client.logout();
      }
    }
  • Registration of the proton_delete_email tool in the MCP server.
    export function registerDeleteEmailTool(server: McpServer) {
      server.registerTool(
        'proton_delete_email',
        {
          title: 'Delete Email',
          description: 'Delete an email by moving it to the Trash folder. Use the folder name and email UID.',
          inputSchema: DeleteEmailSchema,
          annotations: {
            readOnlyHint: false,
            destructiveHint: true,
            idempotentHint: true,
            openWorldHint: false,
          },
        },
        async (params: z.infer<typeof DeleteEmailSchema>) => {
          try {
            await deleteMessage(params.folder, params.uid);
    
            return {
              content: [
                {
                  type: 'text',
                  text: `Email UID ${params.uid} deleted successfully (moved to Trash)`,
                },
              ],
            };
          } catch (error) {
            return {
              content: [
                {
                  type: 'text',
                  text: `Error deleting email: ${error instanceof Error ? error.message : String(error)}`,
                },
              ],
            };
          }
        }
      );
    }

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