get_unread_count
Count unread emails in an IMAP mailbox to monitor incoming messages and track email backlog without opening each message.
Instructions
Get count of unread emails
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mailbox | No | Mailbox name (default: INBOX) |
Implementation Reference
- src/imap_mcp/imap_client.py:760-764 (handler)The core implementation of the get_unread_count tool that queries the IMAP client for the UNSEEN status.
def get_unread_count(self, mailbox: str = "INBOX") -> int: """Get count of unread emails.""" self._ensure_connected() status = self.client.folder_status(mailbox, ["UNSEEN"]) return status.get(b"UNSEEN", 0) - src/imap_mcp/server.py:355-361 (registration)The registration of the get_unread_count tool, defining its metadata and parameters.
make_tool( "get_unread_count", "Get count of unread emails", { "mailbox": {"type": "string", "description": "Mailbox name (default: INBOX)"}, }, ), - src/imap_mcp/server.py:639-642 (handler)The tool handler in the server that calls the imap_client.get_unread_count method.
elif name == "get_unread_count": return imap_client.get_unread_count( mailbox=args.get("mailbox", "INBOX"), )