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;
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden. It successfully discloses the persistence model ('stored persistently') and execution lifecycle ('run on demand'). However, it fails to mention important behavioral traits: that rules perform real (potentially destructive) actions when run, what happens if a duplicate name is provided, or whether validation occurs immediately.

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 consists of two efficient sentences with zero waste. The first sentence front-loads the core purpose, while the second adds essential behavioral context about persistence and execution. Every sentence earns its place.

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

Completeness4/5

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

Given the high complexity (nested filter/action objects) and 100% schema coverage, the description adequately explains the tool's purpose and persistence model. It appropriately omits return value documentation since no output schema exists. Minor gap: lacks warning about destructive actions (delete) that rules can perform when executed.

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%, establishing a baseline of 3. The description text implies the function of the 'filters' and 'action' parameters at a high level ('applies a specific action to emails matching a set of filters'), but does not add syntax details, format examples, or semantics beyond what the schema already provides.

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

Purpose5/5

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

The description clearly states the specific verb (Create), resource (saved rule), and mechanism (applies action to emails matching filters). It effectively distinguishes from sibling bulk_* tools by emphasizing that rules are 'saved' and 'stored persistently' rather than executing immediately.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool (creating reusable automation) by stating rules 'can be run on demand or all at once with run_all_rules.' It explicitly references the sibling execution tool run_all_rules. However, it lacks explicit 'when-not-to-use' guidance contrasting with immediate bulk 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/adamzaidi/icloud-mcp'

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