Skip to main content
Glama
Soundhannes

IMAP MCP Server

by Soundhannes

flag_email

Add custom flags to specific emails in IMAP mailboxes for better organization and categorization.

Instructions

Add flag to emails

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uidsYesEmail UIDs
flagYesFlag name (e.g., \Flagged, \Important)
mailboxNoMailbox name (default: current)

Implementation Reference

  • The core implementation of flag_email, which handles the IMAP flag addition.
    def flag_email(
        self, uids: list[int], flag: str, mailbox: Optional[str] = None
    ) -> bool:
        """Add flag to emails."""
        self._ensure_connected()
        if mailbox:
            self.select_mailbox(mailbox)
        self.client.add_flags(uids, [flag.encode() if isinstance(flag, str) else flag])
        return True
  • Registration of the flag_email tool in the MCP server.
    make_tool(
        "flag_email",
        "Add flag to emails",
        {
            "uids": {
                "type": "array",
                "items": {"type": "number"},
                "description": "Email UIDs",
            },
            "flag": {"type": "string", "description": "Flag name (e.g., \\Flagged, \\Important)"},
            "mailbox": {"type": "string", "description": "Mailbox name (default: current)"},
        },
        ["uids", "flag"],
    ),
    make_tool(
  • The tool execution handler in the MCP server that calls the IMAP client method.
    elif name == "flag_email":
        return imap_client.flag_email(
            uids=args["uids"],
            flag=args["flag"],
            mailbox=args.get("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