Skip to main content
Glama
Soundhannes

IMAP MCP Server

by Soundhannes

search_by_date

Find emails within specific date ranges using ISO format dates to filter messages by when they were sent or received.

Instructions

Search emails by date range

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sinceNoEmails since date (ISO format)
beforeNoEmails before date (ISO format)
mailboxNoMailbox name (default: current)
limitNoMax results (default: 50)

Implementation Reference

  • The search_by_date method implementation, which builds IMAP search criteria based on since/before parameters and fetches the corresponding emails.
    def search_by_date(
        self,
        mailbox: Optional[str] = None,
        since: Optional[str] = None,
        before: Optional[str] = None,
        limit: int = 50,
    ) -> list[EmailHeader]:
        """Search emails by date range."""
        self._ensure_connected()
        if mailbox:
            self.select_mailbox(mailbox)
        elif not self.current_mailbox:
            self.select_mailbox("INBOX")
    
        criteria = []
        if since:
            criteria.extend(["SINCE", since])
        if before:
            criteria.extend(["BEFORE", before])
        if not criteria:
            criteria = ["ALL"]
    
        uids = self.client.search(criteria)
        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()]
  • Registration and dispatch logic for the search_by_date tool in the MCP server.
    elif name == "search_by_date":
        return imap_client.search_by_date(

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/Soundhannes/IMAP-MCP'

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