Skip to main content
Glama
Racimy

iMail-mcp

delete_mailbox

Remove an existing mailbox (folder) from your iCloud email account by specifying the mailbox name to delete unwanted folders and organize your email storage.

Instructions

Delete an existing mailbox (folder)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the mailbox to delete

Implementation Reference

  • Handler for delete_mailbox tool: validates configuration and input, calls mailClient.deleteMailbox, and formats response.
    case 'delete_mailbox': {
      if (!mailClient) {
        throw new McpError(
          ErrorCode.InvalidRequest,
          'iCloud Mail not configured. Please set ICLOUD_EMAIL and ICLOUD_APP_PASSWORD environment variables.'
        );
      }
    
      const mailboxName = args?.name as string;
    
      if (!mailboxName) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Mailbox name is required'
        );
      }
    
      const result = await mailClient.deleteMailbox(mailboxName);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Core implementation of mailbox deletion using IMAP delBox command, with input validation, system mailbox protection, and enhanced error messages.
    async deleteMailbox(
      name: string
    ): Promise<{ status: string; message: string }> {
      if (!name || name.trim() === '') {
        return {
          status: 'error',
          message: 'Mailbox name cannot be empty',
        };
      }
    
      const trimmedName = name.trim();
    
      // Prevent deletion of important system mailboxes
      const systemMailboxes = ['INBOX', 'Sent', 'Trash', 'Drafts', 'Junk'];
      if (systemMailboxes.includes(trimmedName)) {
        return {
          status: 'error',
          message: `Cannot delete system mailbox '${trimmedName}'`,
        };
      }
    
      return new Promise((resolve) => {
        this.imap.delBox(trimmedName, (err: Error) => {
          if (err) {
            let errorMessage = err.message;
    
            // Provide more helpful error messages for common issues
            if (err.message.includes('does not exist')) {
              errorMessage = `Mailbox '${trimmedName}' does not exist`;
            } else if (err.message.includes('not empty')) {
              errorMessage = `Cannot delete mailbox '${trimmedName}' because it contains messages. Please move or delete all messages first.`;
            } else if (err.message.includes('permission')) {
              errorMessage = `Permission denied: Cannot delete mailbox '${trimmedName}'`;
            }
    
            resolve({
              status: 'error',
              message: errorMessage,
            });
            return;
          }
    
          resolve({
            status: 'success',
            message: `Mailbox '${trimmedName}' deleted successfully`,
          });
        });
      });
    }
  • src/index.ts:160-173 (registration)
    Registration of the delete_mailbox tool with MCP server, including description and input schema.
    {
      name: 'delete_mailbox',
      description: 'Delete an existing mailbox (folder)',
      inputSchema: {
        type: 'object',
        properties: {
          name: {
            type: 'string',
            description: 'Name of the mailbox to delete',
          },
        },
        required: ['name'],
      },
    },
  • Input schema definition for delete_mailbox tool.
    inputSchema: {
      type: 'object',
      properties: {
        name: {
          type: 'string',
          description: 'Name of the mailbox to delete',
        },
      },
      required: ['name'],
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Delete' implies a destructive mutation, it doesn't specify whether deletion is permanent or reversible, what happens to contained messages, required permissions, or error conditions. This leaves significant gaps for a destructive operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that states the core functionality without unnecessary words. However, it could be more front-loaded with critical behavioral information given the destructive nature of the operation.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive mutation tool with no annotations and no output schema, the description is insufficient. It doesn't address what happens after deletion, whether confirmation is needed, error handling, or how this interacts with sibling tools. The context demands more completeness for safe agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the single 'name' parameter. The description doesn't add any parameter-specific context beyond what's in the schema (e.g., format constraints, examples, or relationship to other tools). Baseline 3 is appropriate when schema does the documentation work.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Delete') and resource ('an existing mailbox (folder)'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'delete_messages' or 'create_mailbox', which would require explicit comparison to earn a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'delete_messages' or 'move_messages'. There's no mention of prerequisites (e.g., mailbox must exist), consequences, or typical scenarios for deletion versus other operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Racimy/iMail-mcp'

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