Skip to main content
Glama
Racimy

iMail-mcp

delete_messages

Remove specific emails from your iCloud mailbox by providing message IDs to clean up your inbox and manage email storage.

Instructions

Delete messages from a mailbox

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mailboxNoMailbox name (default: INBOX)INBOX
messageIdsYesArray of message IDs to delete

Implementation Reference

  • MCP tool handler for 'delete_messages' that extracts arguments, calls the iCloudMailClient.deleteMessages method, and returns the result as text content.
    case 'delete_messages': {
      if (!mailClient) {
        throw new McpError(
          ErrorCode.InvalidRequest,
          'iCloud Mail not configured. Please set ICLOUD_EMAIL and ICLOUD_APP_PASSWORD environment variables.'
        );
      }
    
      const messageIds = args?.messageIds as string[];
      const mailbox = (args?.mailbox as string) || 'INBOX';
    
      const result = await mailClient.deleteMessages(messageIds, mailbox);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Input schema definition for the 'delete_messages' tool, specifying required messageIds array and optional mailbox.
    {
      name: 'delete_messages',
      description: 'Delete messages from a mailbox',
      inputSchema: {
        type: 'object',
        properties: {
          messageIds: {
            type: 'array',
            items: { type: 'string' },
            description: 'Array of message IDs to delete',
          },
          mailbox: {
            type: 'string',
            description: 'Mailbox name (default: INBOX)',
            default: 'INBOX',
          },
        },
        required: ['messageIds'],
      },
    },
  • Helper method in iCloudMailClient that deletes all messages in the specified mailbox by adding the \\Deleted flag and expunging (ignores provided messageIds).
    async deleteMessages(
      _messageIds: string[],
      mailbox: string = 'INBOX'
    ): Promise<{ status: string; message: string }> {
      return new Promise((resolve) => {
        this.imap.openBox(mailbox, false, (err: Error) => {
          if (err) {
            resolve({
              status: 'error',
              message: `Failed to open mailbox '${mailbox}': ${err.message}`,
            });
            return;
          }
    
          this.imap.search(['ALL'], (err: Error, results: number[]) => {
            if (err) {
              resolve({
                status: 'error',
                message: `Failed to search messages: ${err.message}`,
              });
              return;
            }
    
            if (!results || results.length === 0) {
              resolve({
                status: 'error',
                message: 'No messages found in mailbox',
              });
              return;
            }
    
            this.imap.addFlags(results, ['\\Deleted'], (err: Error) => {
              if (err) {
                resolve({
                  status: 'error',
                  message: `Failed to mark messages for deletion: ${err.message}`,
                });
                return;
              }
    
              this.imap.expunge((err: Error) => {
                if (err) {
                  resolve({
                    status: 'error',
                    message: `Failed to expunge deleted messages: ${err.message}`,
                  });
                  return;
                }
    
                resolve({
                  status: 'success',
                  message: `Successfully deleted ${results.length} messages from '${mailbox}'`,
                });
              });
            });
          });
        });
      });
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action without disclosing critical behavioral traits. It doesn't mention whether deletion is permanent or reversible, permission requirements, error handling, or side effects on the mailbox, which are essential 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.

Conciseness5/5

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

The description is a single, clear sentence with zero wasted words, making it highly efficient and front-loaded. It directly communicates the core function without unnecessary elaboration, earning its place succinctly.

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 tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral outcomes, error cases, or return values, leaving significant gaps in understanding how the tool operates and what to expect after invocation.

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?

The input schema has 100% description coverage, fully documenting both parameters, so the description adds no additional parameter information beyond what the schema provides. This meets the baseline for high schema coverage, but doesn't compensate with extra context like format examples or constraints.

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 ('messages from a mailbox'), making the purpose immediately understandable. It doesn't differentiate from sibling tools like 'move_messages' or 'delete_mailbox', which would require more specificity about scope or alternatives.

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 'move_messages' or 'delete_mailbox', nor does it mention prerequisites or exclusions. It lacks context about appropriate scenarios, leaving the agent to infer usage from the name alone.

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