set_autoresponder
Automate email replies by configuring autoresponders for Migadu mailboxes. Set active status, subject, body, and expiration date for each response.
Instructions
Configure mailbox autoresponders. List of dicts with: target (email/local), active (required), subject (optional), body (optional), expires_on (optional).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| autoresponders | Yes |
Input Schema (JSON Schema)
{
"properties": {
"autoresponders": {
"items": {
"additionalProperties": true,
"type": "object"
},
"title": "Autoresponders",
"type": "array"
}
},
"required": [
"autoresponders"
],
"type": "object"
}
Implementation Reference
- MCP tool handler 'set_autoresponder' that orchestrates bulk autoresponder configuration by calling the processor.@mcp.tool( annotations={ "readOnlyHint": False, "destructiveHint": False, "idempotentHint": True, "openWorldHint": True, }, ) async def set_autoresponder( autoresponders: List[Dict[str, Any]], ctx: Context ) -> Dict[str, Any]: """Configure mailbox autoresponders. List of dicts with: target (email/local), active (required), subject (optional), body (optional), expires_on (optional).""" count = len(list(ensure_iterable(autoresponders))) await log_bulk_operation_start( ctx, "Configuring autoresponders for", count, "mailbox" ) result = await process_set_autoresponder(autoresponders, ctx) await log_bulk_operation_result( ctx, "Autoresponder configuration", result, "mailbox" ) return result
- Helper function that processes individual autoresponder requests with validation, parsing, logging, and service invocation.@bulk_processor_with_schema(AutoresponderRequest) async def process_set_autoresponder( validated_item: AutoresponderRequest, ctx: Context ) -> Dict[str, Any]: """Process a single autoresponder configuration with Pydantic validation""" # Use validated Pydantic model directly - all validation already done target = validated_item.target active = validated_item.active subject = validated_item.subject body = validated_item.body expires_on = ( validated_item.expires_on.isoformat() if validated_item.expires_on else None ) # Parse target parsed = parse_email_target(target) domain, local_part = parsed[0] email_address = format_email_address(domain, local_part) status = "Enabling" if active else "Disabling" await log_operation_start(ctx, f"{status} autoresponder", email_address) service = get_service_factory().mailbox_service() result = await service.set_autoresponder( domain, local_part, active, subject, body, expires_on ) await log_operation_success( ctx, f"{status.lower()} autoresponder", email_address ) return { "autoresponder": result, "email_address": email_address, "success": True, }
- migadu_mcp/utils/schemas.py:132-147 (schema)Pydantic input schema AutoresponderRequest used for validating tool parameters including target, active status, subject, body, and expiration.class AutoresponderRequest(BaseModel): """Request schema for setting autoresponder""" target: str = Field(..., description="Email address or local part") active: bool = Field(..., description="Whether autoresponder is enabled") subject: Optional[str] = Field(None, description="Subject line for replies") body: Optional[str] = Field(None, description="Message content for replies") expires_on: Optional[date] = Field(None, description="Expiration date YYYY-MM-DD") @field_validator("expires_on") @classmethod def validate_expires_on(cls, v: Optional[date]) -> Optional[date]: if v and v <= date.today(): raise ValueError("expires_on must be a future date") return v
- MailboxService method that constructs the API request payload and calls the Migadu API to configure the autoresponder.async def set_autoresponder( self, domain: str, local_part: str, active: bool, subject: Optional[str] = None, body: Optional[str] = None, expires_on: Optional[str] = None, ) -> Dict[str, Any]: """Configure mailbox autoresponder""" data: Dict[str, Any] = {"autorespond_active": active} if subject: data["autorespond_subject"] = subject if body: data["autorespond_body"] = body if expires_on: data["autorespond_expires_on"] = expires_on return await self.client.request( "PUT", f"/domains/{domain}/mailboxes/{local_part}", json=data )
- migadu_mcp/main.py:18-25 (registration)Server initialization that calls register_mailbox_tools(mcp), which in turn registers the set_autoresponder tool via @mcp.tool decorator.def initialize_server(): """Initialize the MCP server with all tools and resources""" # Register all tools register_mailbox_tools(mcp) register_identity_tools(mcp) register_alias_tools(mcp) register_rewrite_tools(mcp) register_resources(mcp)