Skip to main content
Glama

delete_email

Remove emails permanently from your mailbox by marking them as deleted and expunging them from the server. Specify the message ID or UID to target specific emails for deletion.

Instructions

Delete email (mark as deleted and expunge)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderNoFolder containing the email (default: INBOX)INBOX
message_idNoMessage ID (sequence number)
uidNoUnique ID of the message

Implementation Reference

  • The core implementation of the delete_email logic within the EmailMove class, which marks emails with the \\Deleted flag in the IMAP folder.
    def delete_email(
        self, folder: str, uids: int | list[int], expunge_immediately: bool = False
    ) -> bool:
        """
        Delete emails from a folder.
    
        This marks emails with \\Deleted flag. If expunge_immediately
        is True, permanently deletes them. Otherwise, they will be
        deleted when the folder is expunged or closed.
    
        Args:
            folder: Folder containing the emails
            uids: Email UID or list of UIDs to delete
            expunge_immediately: If True, permanently delete now
    
        Returns:
            True if successful
    
        Raises:
            EmailMoveError: If operation fails
    
        Example:
            >>> move = EmailMove(conn)
            >>> move.delete_email('INBOX', [1, 2, 3])
            True
        """
        if not folder:
            raise EmailMoveError("Folder name is required")
    
        # Select folder
        self._select_folder(folder)
    
        uid_string = self._validate_uids(uids)
    
        try:
            # Add \\Deleted flag
            response = self._conn.uid("STORE", uid_string, "+FLAGS (\\Deleted)")
    
            if response[0] != b"OK":
                error_msg = (
                    response[1][0].decode("utf-8", errors="replace")
                    if response[1]
                    else "Unknown error"
                )
                raise EmailMoveError(f"Failed to delete email: {error_msg}")
    
            # Expunge if requested
            if expunge_immediately:
                self.expunge(folder)
    
            return True
    
        except EmailMoveError:
            raise
        except Exception as e:
            raise EmailMoveError(f"Failed to delete email: {str(e)}")
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description must carry full behavioral disclosure. It reveals the two-step process (mark deleted + expunge), indicating IMAP-style permanent deletion. However, it omits critical safety context: irreversibility warnings, permission requirements, or error behavior when message_id/uid doesn't exist.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely efficient single sentence with parenthetical detail. Every word serves a purpose: 'Delete' (action), 'email' (resource), 'mark as deleted and expunge' (behavioral specificity). No redundancy or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Adequate for a 3-parameter tool with complete schema documentation, but minimal for a destructive operation lacking both annotations and output schema. The description should explicitly warn about permanent data loss given the absence of structured safety hints (destructiveHint).

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has 100% description coverage (folder default, message_id as sequence number, uid as unique ID). The description adds no parameter-specific guidance, but since the schema fully documents all 3 parameters including the anyOf requirement (message_id OR uid), the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States specific action (Delete) and resource (email). The parenthetical '(mark as deleted and expunge)' clarifies the technical mechanism, distinguishing it from sibling tools like move_email (relocation) and mark_read/unread (flag changes). However, it doesn't explicitly state this is permanent destruction vs. soft deletion.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides no guidance on when to use this tool versus alternatives. Fails to mention that move_email should be used to move messages to a trash folder, while this tool permanently expunges them. No prerequisites or 'when-not' warnings are included despite being a destructive operation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/AdJIa/mail-mcp-server'

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