Skip to main content
Glama
Michaelzag
by Michaelzag

delete_mailbox

Remove email accounts permanently from Migadu email hosting. Specify targets as email addresses or local accounts. Action is irreversible; use with caution.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetsYes

Implementation Reference

  • Main tool handler for delete_mailbox, decorated with @mcp.tool. Processes list of targets via bulk processor, logs warnings, and delegates to process_delete_mailbox.
    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
  • Pydantic schema MailboxDeleteRequest used for input validation in bulk delete_mailbox operations.
    class MailboxDeleteRequest(BaseModel): """Request schema for deleting a mailbox""" target: str = Field(..., description="Email address or local part")
  • Top-level registration call in main.py that invokes register_mailbox_tools to add all mailbox tools including delete_mailbox to the MCP server.
    register_mailbox_tools(mcp)
  • Helper function process_delete_mailbox that handles single mailbox deletion after schema validation, parses target, warns user, and calls the service layer.
    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}
  • Service layer implementation delete_mailbox that makes the actual DELETE API request to Migadu, handling known API quirks.
    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}" )

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