Skip to main content
Glama

add_email_account

Configure a new email account in the MCP Email Server by setting up IMAP and SMTP connection details for automated email workflows.

Instructions

Add a new email account configuration to the settings.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailYes

Implementation Reference

  • The core handler function for the 'add_email_account' tool, registered via @mcp.tool decorator. Adds the EmailSettings to config and persists it.
    @mcp.tool(description="Add a new email account configuration to the settings.") async def add_email_account(email: EmailSettings) -> str: settings = get_settings() settings.add_email(email) settings.store() return f"Successfully added email account '{email.account_name}'"
  • Pydantic BaseModel defining the input schema EmailSettings used by the tool handler.
    class EmailSettings(AccountAttributes): full_name: str email_address: str incoming: EmailServer outgoing: EmailServer save_to_sent: bool = True # Save sent emails to IMAP Sent folder sent_folder_name: str | None = None # Override Sent folder name (auto-detect if None)
  • Method on Settings class that appends the new email account to the emails list, triggering validation.
    def add_email(self, email: EmailSettings) -> None: """Use re-assigned for validation to work.""" self.emails = [email, *self.emails]
  • Method on Settings class that serializes and writes the configuration to the TOML file.
    def store(self) -> None: toml_file = self.model_config["toml_file"] toml_file.parent.mkdir(parents=True, exist_ok=True) toml_file.write_text(self._to_toml()) logger.info(f"Settings stored in {toml_file}")
  • Function that provides the singleton instance of Settings, loading from config.toml if needed.
    def get_settings(reload: bool = False) -> Settings: global _settings if not _settings or reload: logger.info(f"Loading settings from {CONFIG_PATH}") _settings = Settings() return _settings

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/ai-zerolab/mcp-email-server'

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