delete_identity
Permanently remove identities from Migadu email hosting. Requires mailbox details (target, mailbox, optional domain). Irreversible action—use with caution.
Instructions
Delete identities. DESTRUCTIVE: Cannot be undone. List of dicts with: target, mailbox (required), domain (optional).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| targets | Yes |
Input Schema (JSON Schema)
{
"properties": {
"targets": {
"items": {
"additionalProperties": true,
"type": "object"
},
"title": "Targets",
"type": "array"
}
},
"required": [
"targets"
],
"type": "object"
}
Implementation Reference
- The main MCP tool handler for 'delete_identity'. It handles bulk deletion requests by delegating to process_delete_identity after logging and warnings.@mcp.tool( annotations={ "readOnlyHint": False, "destructiveHint": True, "idempotentHint": True, "openWorldHint": True, }, ) async def delete_identity( targets: List[Dict[str, Any]], ctx: Context ) -> Dict[str, Any]: """Delete identities. DESTRUCTIVE: Cannot be undone. List of dicts with: target, mailbox (required), domain (optional).""" count = len(list(ensure_iterable(targets))) await log_bulk_operation_start(ctx, "Deleting", count, "identity") await ctx.warning("🗑️ DESTRUCTIVE: This operation cannot be undone!") result = await process_delete_identity(targets, ctx) await log_bulk_operation_result(ctx, "Identity deletion", result, "identity") return result
- migadu_mcp/utils/schemas.py:224-230 (schema)Pydantic schema defining the input structure for delete_identity requests: target, mailbox, optional domain.class IdentityDeleteRequest(BaseModel): """Request schema for deleting an identity""" target: str = Field(..., description="Local part of identity address") mailbox: str = Field(..., description="Username of mailbox that owns this identity") domain: Optional[str] = Field(None, description="Domain name")
- migadu_mcp/main.py:22-22 (registration)Registration point where register_identity_tools is called on the MCP instance, which defines and registers the delete_identity tool among others.register_identity_tools(mcp)
- Bulk processor helper that validates individual delete requests using IdentityDeleteRequest schema and calls the service layer to perform deletion.@bulk_processor_with_schema(IdentityDeleteRequest) async def process_delete_identity( validated_item: IdentityDeleteRequest, ctx: Context ) -> Dict[str, Any]: """Process a single identity deletion""" # Get domain if not provided domain = validated_item.domain 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, validated_item.target) await ctx.warning(f"🗑️ DESTRUCTIVE: Deleting identity {email_address}") service = get_service_factory().identity_service() await service.delete_identity( domain, validated_item.mailbox, validated_item.target ) await log_operation_success(ctx, "Deleted identity", email_address) return {"deleted": email_address, "success": True}
- Service layer method that performs the actual HTTP DELETE request to Migadu API to delete the identity.async def delete_identity( self, domain: str, mailbox: str, identity: str ) -> Dict[str, Any]: """Delete an identity""" return await self.client.request( "DELETE", f"/domains/{domain}/mailboxes/{mailbox}/identities/{identity}" )