Delete folder
delete_folderDelete a mailbox folder or label container while protecting system mailboxes. Move its messages to another folder first, or preview affected nested folders and message counts with a dry run.
Instructions
Delete a mailbox folder or label container. Restricted to the "Folders/" and "Labels/" namespaces to protect system mailboxes (INBOX, Sent, Trash, etc.).
Deleting a folder does not delete its messages, but it takes them out of every folder: they stay findable only in "All Mail", which is easy to lose track of. Pass moveContentsTo (e.g. "Archive" or "INBOX") to move the folder's mail, nested folders included, there first, and dryRun: true to see the nested folders and message counts beforehand. Nested folders are deleted with it. Deleting a label only removes the label; its messages stay in their folders.
Accepts . and .. path segments by design — IMAP treats paths as opaque literal names with no parent-directory semantics, so this is the cleanup path for adversarial folder names left behind by other IMAP clients (or older versions of this server). create_folder and rename_folder reject those segments so confusable paths cannot be introduced through this tool.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"path": "<path>"
},
"name": "delete_folder"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to delete (e.g. "Folders/Old", "Labels/Archived"). Must start with "Folders/" or "Labels/". | |
| dryRun | No | Show the nested folders and message counts that would be affected, without deleting. | |
| moveContentsTo | No | Folders only: move all of the folder's mail (nested folders included) to this folder before deleting, e.g. "Archive" or "INBOX". If a move fails, nothing is deleted. |