search_unread
Retrieve unread emails from an IMAP account to manage inbox priorities and track pending messages. Specify mailbox and limit parameters to filter results.
Instructions
Get all unread emails
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mailbox | No | Mailbox name (default: current) | |
| limit | No | Max results (default: 50) |
Implementation Reference
- src/imap_mcp/imap_client.py:581-597 (handler)The `search_unread` method in the `IMAPClient` class implements the logic to search for unread emails by selecting the mailbox and searching for the 'UNSEEN' flag.
def search_unread( self, mailbox: Optional[str] = None, limit: int = 50 ) -> list[EmailHeader]: """Get all unread emails.""" self._ensure_connected() if mailbox: self.select_mailbox(mailbox) elif not self.current_mailbox: self.select_mailbox("INBOX") uids = self.client.search(["UNSEEN"]) uids = sorted(uids, reverse=True)[:limit] if not uids: return [] messages = self.client.fetch(uids, ["ENVELOPE", "FLAGS", "RFC822.SIZE"]) return [self._parse_email_header(uid, data) for uid, data in messages.items()] - src/imap_mcp/server.py:574-575 (registration)The `search_unread` tool is registered and called in `src/imap_mcp/server.py` within the tool handler dispatch logic.
elif name == "search_unread": return imap_client.search_unread(