Skip to main content
Glama
Soundhannes

IMAP MCP Server

by Soundhannes

select_mailbox

Open a specific mailbox folder like INBOX or Sent to access and manage its email messages within an IMAP email account.

Instructions

Select/open a mailbox folder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mailboxYesMailbox name (e.g., INBOX, Sent)

Implementation Reference

  • The `select_mailbox` method in `ImapClient` handles the actual IMAP `select_folder` logic and returns `MailboxStatus`.
    def select_mailbox(self, mailbox: str) -> MailboxStatus:
        """Select/open a mailbox folder."""
        self._ensure_connected()
        result = self.client.select_folder(mailbox)
        self.current_mailbox = mailbox
        return MailboxStatus(
            name=mailbox,
            exists=result.get(b"EXISTS", 0),
            recent=result.get(b"RECENT", 0),
            unseen=result.get(b"UNSEEN", 0) if b"UNSEEN" in result else 0,
            uidnext=result.get(b"UIDNEXT", 0),
            uidvalidity=result.get(b"UIDVALIDITY", 0),
        )
  • The tool `select_mailbox` is registered with the MCP server with a description and input schema.
    make_tool(
        "select_mailbox",
        "Select/open a mailbox folder",
        {
            "mailbox": {"type": "string", "description": "Mailbox name (e.g., INBOX, Sent)"},
        },
        ["mailbox"],
    ),
  • The `handle_tool_call` function in `server.py` routes the `select_mailbox` tool call to the corresponding `imap_client.select_mailbox` implementation.
    elif name == "select_mailbox":
        return imap_client.select_mailbox(args["mailbox"])

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