Skip to main content
Glama
adamzaidi

icloud-mcp

by adamzaidi

create_rule

Create automated email rules to organize iCloud Mail by applying actions like move, delete, or mark to messages matching specific filters such as sender, subject, or date.

Instructions

Create a saved rule that applies a specific action to emails matching a set of filters. Rules are stored persistently and can be run on demand or all at once with run_all_rules.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesUnique rule name (used to run or delete the rule)
descriptionNoOptional human-readable description of what the rule does
filtersYesEmail filters (same as bulk_move/bulk_delete filters: sender, domain, subject, before, since, unread, flagged, larger, smaller)
actionYesAction to apply to matching emails

Implementation Reference

  • Implementation of the create_rule tool handler.
    export function createRule(name, filters, action, description = '') {
      const data = readRules();
      if (data.rules.find(r => r.name === name)) {
        throw new Error(`Rule '${name}' already exists. Delete it first to update it.`);
      }
      const validActions = ['move', 'delete', 'mark_read', 'mark_unread', 'flag', 'unflag'];
      if (!validActions.includes(action.type)) {
        throw new Error(`Invalid action type '${action.type}'. Must be one of: ${validActions.join(', ')}`);
      }
      if (action.type === 'move' && !action.targetMailbox) {
        throw new Error(`Action type 'move' requires targetMailbox`);
      }
      const rule = {
        name,
        description,
        filters,
        action,
        createdAt: new Date().toISOString(),
        lastRun: null,
        runCount: 0,
      };
      data.rules.push(rule);
      writeRules(data);
      return rule;
    }

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/adamzaidi/icloud-mcp'

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