Skip to main content
Glama
Michaelzag
by Michaelzag

delete_mailbox

Remove email mailboxes from Migadu hosting services. This destructive action permanently deletes specified mailboxes and cannot be reversed.

Instructions

Delete mailboxes. DESTRUCTIVE: Cannot be undone. List of dicts with: target (email/local).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetsYes

Implementation Reference

  • Main handler for the 'delete_mailbox' tool. Registers the tool with FastMCP and orchestrates bulk deletion by calling the process_delete_mailbox helper.
    @mcp.tool( annotations={ "readOnlyHint": False, "destructiveHint": True, "idempotentHint": True, "openWorldHint": True, }, ) async def delete_mailbox( targets: List[Dict[str, Any]], ctx: Context ) -> Dict[str, Any]: """Delete mailboxes. DESTRUCTIVE: Cannot be undone. List of dicts with: target (email/local).""" count = len(list(ensure_iterable(targets))) await log_bulk_operation_start(ctx, "Deleting", count, "mailbox") await ctx.warning("🗑️ DESTRUCTIVE: This operation cannot be undone!") result = await process_delete_mailbox(targets, ctx) await log_bulk_operation_result(ctx, "Mailbox deletion", result, "mailbox") return result
  • Helper function that processes individual mailbox deletion: validates input, parses email target, calls MailboxService.delete_mailbox, and logs the operation.
    @bulk_processor_with_schema(MailboxDeleteRequest) async def process_delete_mailbox( validated_item: MailboxDeleteRequest, ctx: Context ) -> Dict[str, Any]: """Process a single mailbox deletion with Pydantic validation""" # Use validated Pydantic model directly - all validation already done target = validated_item.target # Parse target parsed = parse_email_target(target) domain, local_part = parsed[0] email_address = format_email_address(domain, local_part) await ctx.warning(f"🗑️ DESTRUCTIVE: Deleting mailbox {email_address}") service = get_service_factory().mailbox_service() await service.delete_mailbox(domain, local_part) await log_operation_success(ctx, "Deleted mailbox", email_address) return {"deleted": email_address, "success": True}
  • Pydantic model used for input validation of delete_mailbox requests, requiring a 'target' field (email or local part).
    class MailboxDeleteRequest(BaseModel): """Request schema for deleting a mailbox""" target: str = Field(..., description="Email address or local part")
  • Service layer method that executes the actual Migadu API DELETE request to remove the mailbox.
    async def delete_mailbox(self, domain: str, local_part: str) -> Dict[str, Any]: """Permanently delete a mailbox and all stored messages with API bug handling. Note: Due to Migadu API bug, successful deletions may return HTTP 500 errors. The operation actually succeeds despite the error response. """ return await self.client.request( "DELETE", f"/domains/{domain}/mailboxes/{local_part}" )
  • Registration of mailbox tools (including delete_mailbox) by calling register_mailbox_tools on the FastMCP instance in the main server initialization.
    from migadu_mcp.tools.mailbox_tools import register_mailbox_tools from migadu_mcp.tools.identity_tools import register_identity_tools from migadu_mcp.tools.alias_tools import register_alias_tools from migadu_mcp.tools.rewrite_tools import register_rewrite_tools from migadu_mcp.tools.resource_tools import register_resources # Initialize FastMCP server mcp: FastMCP = FastMCP("Migadu Mailbox Manager") def initialize_server(): """Initialize the MCP server with all tools and resources""" # Register all tools register_mailbox_tools(mcp)

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/Michaelzag/migadu-mcp'

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