Skip to main content
Glama

create_filter

Destructive

Create a Gmail filter to automatically label incoming messages that match your criteria. Optionally apply the same labels to existing mail to clean up your backlog.

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. 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.

Input Schema

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes
appliedYes
forwardNo
criteriaYes
addLabelIdsYes
removeLabelIdsYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. 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"
      +  }
      +]
  2. 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"
      +  }
      +]
  3. Addedv0.6.0

TDQS

A4.6/5.0
Behavior5/5

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

The description goes far beyond the annotations. It explains that a filter affects only mail arriving after creation, that applyToExisting runs a bulk sweep with a stale-index caveat, that submittedMessages is not the number of changed messages, that verify costs an extra read and failures are non-fatal, that labels can auto-create unknown names, and that the operation requires gmail.settings.basic. This is rich, honest behavioral disclosure consistent with destructiveHint=true.

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 long, but nearly every sentence adds a distinct operational detail: core semantics, common recipes, applyToExisting caveats, verification behavior, use case, and side effects. It is front-loaded with the primary purpose and structured with labeled sections such as 'USE WHEN' and 'SIDE EFFECTS'. It could be tighter, but the density is justified for a tool with 14 parameters and subtle edge cases.

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 complex tool with 14 parameters, no required fields, and an output schema, this description is exceptionally complete. It covers what happens on creation, how existing mail is handled, the semantics of verification, failure behavior, permission requirements, reversibility, and unsupported forwarding. An agent can safely construct a valid call and predict the consequences; the output schema can fill in remaining return-value details.

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?

With 0% schema description coverage, the description carries the semantic burden and does so well for the action parameters: it defines addLabels/removeLabels semantics, gives concrete recipes like removeLabels ['INBOX'] and addLabels ['TRASH'], and explains applyToExisting, maxMessages, and verify. The criteria parameters (from, to, subject, query, etc.) are not individually detailed, but their Gmail meanings are conventional and the overall parameter guidance is well above the minimum viable level.

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 opens with a specific verb-resource pair — 'Create a Gmail filter' — and immediately states what the filter does: matching incoming mail automatically gets label actions. It also distinguishes the tool from siblings by emphasizing persistent auto-triage rules and explicitly noting that forwarding filters are not supported, so there is no confusion with bulk_modify, modify_labels, or other Gmail mutators.

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?

There is a clear 'USE WHEN' statement defining the intended scenario: setting up a persistent auto-triage rule, with the optional applyToExisting use case explained. It also gives an explicit 'not supported' exclusion for forwarding. It stops short of naming a sibling alternative such as bulk_modify for one-time bulk label changes, but the context is strong enough for an agent to choose this tool for filter creation.

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