delete_mailbox
Delete one or more mailboxes from your Migadu hosting account by specifying each mailbox's target identifier.
Instructions
Delete mailbox(es). DESTRUCTIVE. List of dicts with: target.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| items | Yes |
Implementation Reference
- migadu_mcp/tools/mailbox_tools.py:90-99 (handler)Tool handler function for delete_mailbox - parses target, calls service layer, returns deletion result.
@migadu_bulk_tool(mcp, MailboxDeleteRequest, entity="mailbox", destructive=True) async def delete_mailbox( item: MailboxDeleteRequest, ctx: Context ) -> dict[str, Any]: """Delete mailbox(es). DESTRUCTIVE. List of dicts with: target.""" domain, local_part = parse_email_target(item.target)[0] email = format_email_address(domain, local_part) await ctx.warning(f"🗑️ Deleting mailbox {email}") await get_service_factory().mailbox_service().delete_mailbox(domain, local_part) return {"deleted": email, "success": True} - migadu_mcp/utils/schemas.py:89-91 (schema)Pydantic schema for MailboxDeleteRequest with a single 'target' field.
class MailboxDeleteRequest(BaseModel): target: str = Field(..., description="Email address or local part") - Service layer method that sends DELETE request to the Migadu API for the specified mailbox.
async def delete_mailbox(self, domain: str, local_part: str) -> None: await self.client.delete(f"/domains/{domain}/mailboxes/{local_part}") - HTTP DELETE method on the MigaduClient that handles Migadu's known bug (500 on successful delete) and treats 404 as idempotent success.
async def delete(self, path: str) -> None: """DELETE returning None on success. Migadu has a known bug where successful DELETEs return HTTP 500. This method treats 200 and 500 as success. 404 is also treated as success (idempotent delete — already gone). Other errors raise. """ client = self._get_client() response = await client.request("DELETE", path) if response.status_code in (200, 204, 404, 500): return None raise MigaduAPIError(response.status_code, response.text) - migadu_mcp/tools/mailbox_tools.py:19-19 (registration)Registration function called from main.py to register all mailbox tools (including delete_mailbox) with the FastMCP server.
def register_mailbox_tools(mcp: FastMCP) -> None: