Skip to main content
Glama
Soundhannes

IMAP MCP Server

by Soundhannes

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
NameRequiredDescriptionDefault
mailboxNoMailbox name (default: INBOX)

Implementation Reference

  • 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)
  • 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)"},
        },
    ),
  • 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"),
        )

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