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
| Name | Required | Description | Default |
|---|---|---|---|
| Yes |
Implementation Reference
- mcp_email_server/app.py:35-40 (handler)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}'"
- mcp_email_server/config.py:73-80 (schema)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)
- mcp_email_server/config.py:258-261 (helper)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]
- mcp_email_server/config.py:319-324 (helper)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}")
- mcp_email_server/config.py:329-335 (helper)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