delete_alias
Remove email forwarding aliases from Migadu hosting. Specify targets to permanently delete alias configurations.
Instructions
Delete aliases. DESTRUCTIVE: Cannot be undone. List of dicts with: target (local part), domain (optional).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| targets | Yes |
Implementation Reference
- migadu_mcp/tools/alias_tools.py:242-260 (handler)The main MCP tool handler function 'delete_alias' that orchestrates bulk alias deletion using the process_delete_alias helper.@mcp.tool( annotations={ "readOnlyHint": False, "destructiveHint": True, "idempotentHint": True, "openWorldHint": True, }, ) async def delete_alias( targets: List[Dict[str, Any]], ctx: Context ) -> Dict[str, Any]: """Delete aliases. DESTRUCTIVE: Cannot be undone. List of dicts with: target (local part), domain (optional).""" count = len(list(ensure_iterable(targets))) await log_bulk_operation_start(ctx, "Deleting", count, "alias") await ctx.warning("🗑️ DESTRUCTIVE: This operation cannot be undone!") result = await process_delete_alias(targets, ctx) await log_bulk_operation_result(ctx, "Alias deletion", result, "alias") return result
- Core processing logic for individual alias deletion, including validation, logging, and service call.@bulk_processor_with_schema(AliasDeleteRequest) async def process_delete_alias( validated_item: AliasDeleteRequest, ctx: Context ) -> Dict[str, Any]: """Process a single alias deletion with Pydantic validation""" # Use validated Pydantic model directly - all validation already done target = validated_item.target domain = validated_item.domain # Get domain if not provided if domain is None: from migadu_mcp.config import get_config config = get_config() domain = config.get_default_domain() if not domain: raise ValueError("No domain provided and MIGADU_DOMAIN not configured") email_address = format_email_address(domain, target) await ctx.warning(f"🗑️ DESTRUCTIVE: Deleting alias {email_address}") service = get_service_factory().alias_service() await service.delete_alias(domain, target) await log_operation_success(ctx, "Deleted alias", email_address) return {"deleted": email_address, "success": True}
- migadu_mcp/utils/schemas.py:181-186 (schema)Pydantic schema model 'AliasDeleteRequest' used by the bulk_processor for input validation in delete_alias tool.class AliasDeleteRequest(BaseModel): """Request schema for deleting an alias""" target: str = Field(..., description="Local part of alias") domain: Optional[str] = Field(None, description="Domain name")
- migadu_mcp/main.py:21-25 (registration)Registration of tool modules in the main MCP server initialization, including the alias_tools module containing delete_alias.register_mailbox_tools(mcp) register_identity_tools(mcp) register_alias_tools(mcp) register_rewrite_tools(mcp) register_resources(mcp)
- AliasService method that performs the actual Migadu API DELETE request to remove the alias.async def delete_alias(self, domain: str, local_part: str) -> Dict[str, Any]: """Delete an alias""" return await self.client.request( "DELETE", f"/domains/{domain}/aliases/{local_part}" )