Skip to main content
Glama

create_filter

Destructive

Create a Gmail filter that automatically labels, archives, marks read, stars, or trashes matching incoming mail by criteria; optionally apply the same actions to existing mail.

Instructions

Create a Gmail filter: matching incoming mail automatically gets the given label actions. Give at least one criterion and at least one action. Actions are label add/remove only (labels by name or id; an unknown name in addLabels is auto-created). Common recipes: skip the inbox → removeLabels ['INBOX']; auto-mark-read → removeLabels ['UNREAD']; auto-trash → addLabels ['TRASH']; star → addLabels ['STARRED']; file under a label → addLabels ['Receipts']. A filter only affects mail arriving AFTER it's created; set applyToExisting:true to ALSO apply the same actions once to mail already in the mailbox (builds a Gmail search from the criteria and runs a bulk modify — same unverified-index caveat as bulk_modify — the sweep acts on what the index returns, which can be badly stale on read state; up to maxMessages, default 1000). The sweep's applied.submittedMessages is how many ids were handed to the API, NOT how many messages changed; set verify:true alongside applyToExisting to read the labels back afterwards and get applied.verified {applied, notApplied[], unverifiable[]}. It costs one extra read per affected thread, so it is off by default; a read-back that fails lands in unverifiable and never fails the call — the filter stands either way. USE WHEN: setting up a persistent auto-triage rule (e.g. 'always archive + label newsletters from x'), optionally cleaning up the existing backlog too — preview_filter first to see how much mail it would catch today and whether an existing filter already covers it. NOTE: forwarding filters are intentionally not supported — mailwarden creates no send/exfiltration path. SIDE EFFECTS: adds a server-side rule affecting future mail (reversible via delete_filter); with applyToExisting also modifies existing messages. Requires gmail.settings.basic.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "create_filter"
  }
}

Input Schema

NameRequiredDescriptionDefault
toNo
fromNo
sizeNo
queryNo
verifyNo
subjectNo
addLabelsNo
maxMessagesNo
excludeChatsNo
negatedQueryNo
removeLabelsNo
hasAttachmentNo
sizeComparisonNo
applyToExistingNo

Output Schema

NameRequiredDescriptionDefault
idYes
appliedYes
forwardNo
criteriaYes
addLabelIdsYes
removeLabelIdsYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.32.0
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • changedOutput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
  2. Changed2 schema fields changedv0.25.0
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / properties / size / maximum
      Added value: +9007199254740991
  3. Changed2 schema fields changedv0.21.0
    • addedInput schema / properties / verify
      Added value: +{
      +  "default": false,
      +  "type": "boolean"
      +}
    • changedOutput schema / properties / applied / anyOf
      Previous value: -[
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "capped": {
      -        "type": "boolean"
      -      },
      -      "error": {
      -        "type": "string"
      -      },
      -      "failed": {
      -        "items": {
      -          "additionalProperties": false,
      -          "properties": {
      -            "error": {
      -              "type": "string"
      -            },
      -            "messageIds": {
      -              "items": {
      -                "type": "string"
      -              },
      -              "type": "array"
      -            }
      -          },
      -          "required": [
      -            "messageIds",
      -            "error"
      -          ],
      -          "type": "object"
      -        },
      -        "type": "array"
      -      },
      -      "matchedMessages": {
      -        "type": "number"
      -      },
      -      "query": {
      -        "type": "string"
      -      },
      -      "submittedMessages": {
      -        "type": "number"
      -      },
      -      "submittedThreadCount": {
      -        "type": "number"
      -      }
      -    },
      -    "required": [
      -      "query",
      -      "matchedMessages",
      -      "submittedMessages",
      -      "submittedThreadCount",
      -      "capped",
      -      "failed"
      -    ],
      -    "type": "object"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "capped": {
      +        "type": "boolean"
      +      },
      +      "error": {
      +        "type": "string"
      +      },
      +      "failed": {
      +        "items": {
      +          "additionalProperties": false,
      +          "properties": {
      +            "error": {
      +              "type": "string"
      +            },
      +            "messageIds": {
      +              "items": {
      +                "type": "string"
      +              },
      +              "type": "array"
      +            }
      +          },
      +          "required": [
      +            "messageIds",
      +            "error"
      +          ],
      +          "type": "object"
      +        },
      +        "type": "array"
      +      },
      +      "matchedMessages": {
      +        "type": "number"
      +      },
      +      "query": {
      +        "type": "string"
      +      },
      +      "submittedMessages": {
      +        "type": "number"
      +      },
      +      "submittedThreadCount": {
      +        "type": "number"
      +      },
      +      "verified": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "applied": {
      +            "type": "number"
      +          },
      +          "notApplied": {
      +            "items": {
      +              "type": "string"
      +            },
      +            "type": "array"
      +          },
      +          "unverifiable": {
      +            "items": {
      +              "type": "string"
      +            },
      +            "type": "array"
      +          }
      +        },
      +        "required": [
      +          "applied",
      +          "notApplied",
      +          "unverifiable"
      +        ],
      +        "type": "object"
      +      }
      +    },
      +    "required": [
      +      "query",
      +      "matchedMessages",
      +      "submittedMessages",
      +      "submittedThreadCount",
      +      "capped",
      +      "failed"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
  4. Changed1 schema field changedv0.15.1
    • changedOutput schema / properties / applied / anyOf
      Previous value: -[
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "capped": {
      -        "type": "boolean"
      -      },
      -      "error": {
      -        "type": "string"
      -      },
      -      "failed": {
      -        "items": {
      -          "additionalProperties": false,
      -          "properties": {
      -            "error": {
      -              "type": "string"
      -            },
      -            "messageIds": {
      -              "items": {
      -                "type": "string"
      -              },
      -              "type": "array"
      -            }
      -          },
      -          "required": [
      -            "messageIds",
      -            "error"
      -          ],
      -          "type": "object"
      -        },
      -        "type": "array"
      -      },
      -      "matchedMessages": {
      -        "type": "number"
      -      },
      -      "modifiedMessages": {
      -        "type": "number"
      -      },
      -      "modifiedThreadCount": {
      -        "type": "number"
      -      },
      -      "query": {
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "query",
      -      "matchedMessages",
      -      "modifiedMessages",
      -      "modifiedThreadCount",
      -      "capped",
      -      "failed"
      -    ],
      -    "type": "object"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "capped": {
      +        "type": "boolean"
      +      },
      +      "error": {
      +        "type": "string"
      +      },
      +      "failed": {
      +        "items": {
      +          "additionalProperties": false,
      +          "properties": {
      +            "error": {
      +              "type": "string"
      +            },
      +            "messageIds": {
      +              "items": {
      +                "type": "string"
      +              },
      +              "type": "array"
      +            }
      +          },
      +          "required": [
      +            "messageIds",
      +            "error"
      +          ],
      +          "type": "object"
      +        },
      +        "type": "array"
      +      },
      +      "matchedMessages": {
      +        "type": "number"
      +      },
      +      "query": {
      +        "type": "string"
      +      },
      +      "submittedMessages": {
      +        "type": "number"
      +      },
      +      "submittedThreadCount": {
      +        "type": "number"
      +      }
      +    },
      +    "required": [
      +      "query",
      +      "matchedMessages",
      +      "submittedMessages",
      +      "submittedThreadCount",
      +      "capped",
      +      "failed"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
  5. Addedv0.6.0

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already declare destructiveHint=true and idempotentHint=false, and the description adds material context beyond them: the filter only affects mail arriving after creation, applyToExisting triggers a bulk modify against a possibly stale index, the sweep's submittedMessages count is not a change count, verify adds one read per thread and failures land in `unverifiable` without failing the call, and gmail.settings.basic is required. Reversibility via delete_filter is also disclosed.

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?

Front-loaded with purpose, then recipes, then the applyToExisting/verify caveats, then USE WHEN and SIDE EFFECTS — a sensible ordering. It is dense but most sentences earn their place; the 'same unverified-index caveat as bulk_modify' cross-reference assumes sibling knowledge and the sweep paragraph is a touch tangled.

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

Completeness5/5

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

For a destructive 14-parameter mutation with an output schema, the description covers the critical gaps: the minimum-one-criterion/one-action rule (required params are 0 in the schema), scope requirements, reversibility, and even the shape of the applied/verified output. Nothing an agent needs to invoke this safely is missing.

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

Parameters4/5

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

Schema description coverage is 0% across 14 parameters, so the description must carry the load. It does well on the non-obvious ones — label name-or-id resolution, auto-creation of unknown addLabels, the INBOX/UNREAD/TRASH/STARRED recipes, applyToExisting, verify, and maxMessages — but leaves query, negatedQuery, excludeChats, hasAttachment, and sizeComparison largely to Gmail-search convention.

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?

Opens with a specific verb+resource ('Create a Gmail filter') and immediately states the effect: matching incoming mail gets the given label actions. An agent can distinguish it from delete_filter, preview_filter, and bulk_modify from the text alone.

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

Usage Guidelines5/5

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

An explicit 'USE WHEN:' section names the scenario (persistent auto-triage rule), points to preview_filter first to gauge the backlog and check for an existing filter, and states a hard exclusion ('forwarding filters are intentionally not supported'). Alternatives are named rather than inferred.

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