unflag_email
Remove flags from specific emails in IMAP mailboxes to organize and declutter your inbox by clearing markers like read, important, or custom labels.
Instructions
Remove flag from emails
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uids | Yes | Email UIDs | |
| flag | Yes | Flag name to remove | |
| mailbox | No | Mailbox name (default: current) |
Implementation Reference
- src/imap_mcp/imap_client.py:645-653 (handler)The core logic for removing a flag from an email in the IMAP client.
def unflag_email( self, uids: list[int], flag: str, mailbox: Optional[str] = None ) -> bool: """Remove flag from emails.""" self._ensure_connected() if mailbox: self.select_mailbox(mailbox) self.client.remove_flags(uids, [flag.encode() if isinstance(flag, str) else flag]) return True - src/imap_mcp/server.py:271-284 (schema)The definition and schema for the unflag_email MCP tool.
make_tool( "unflag_email", "Remove flag from emails", { "uids": { "type": "array", "items": {"type": "number"}, "description": "Email UIDs", }, "flag": {"type": "string", "description": "Flag name to remove"}, "mailbox": {"type": "string", "description": "Mailbox name (default: current)"}, }, ["uids", "flag"], ), - src/imap_mcp/server.py:602-607 (registration)The registration/dispatch logic that maps the unflag_email MCP tool name to the imap_client handler.
elif name == "unflag_email": return imap_client.unflag_email( uids=args["uids"], flag=args["flag"], mailbox=args.get("mailbox"), )