Skip to main content
Glama

preview_filter

Read-only

Preview a Gmail filter before creating it: count today's matching mail, detect duplicate or overlapping filters, and flag missing labels—without changing anything.

Instructions

Check a filter BEFORE create_filter makes it: how much mail its criteria match today, which existing filters have exactly the same criteria, which share a from/to/subject/query value with it, and which label names in addLabels do not exist yet. Creates nothing and changes nothing. Takes the same criteria as create_filter and checks them the same way, so a preview cannot accept what the create would refuse. currentMatches counts what Gmail's search returns for the derived query — the same unverified index create_filter's applyToExisting sweep would act on; it is a size, not a promise that the filter engine agrees on every message. A rule with no positive criterion (only negatedQuery or hasAttachment:false) is not counted at all: it would match nearly the whole mailbox. overlapping is literal: two filters overlap here when they carry the same value in the same field. Whether two different searches intersect is the search engine's question, and is not guessed at. USE WHEN: before create_filter, to show the user what the rule would catch and avoid a duplicate. SIDE EFFECTS: none. Requires gmail.settings.basic (it lists the existing filters).

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": "preview_filter"
  }
}

Input Schema

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

Output Schema

NameRequiredDescriptionDefault
queryYes
cappedYes
overlappingYes
sameCriteriaYes
currentMatchesYes
labelsToCreateYes
trashesMatchesYes
currentThreadCountYes

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

TDQS

A4.5/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and openWorldHint=false; the description goes further by naming the required scope (gmail.settings.basic), restating that nothing is created or changed, and disclosing two non-obvious semantic caveats — currentMatches reflects the unverified search index rather than filter-engine agreement, and rules with no positive criterion are reported as zero matches. The only shortfall is that it does not mention the maxMessages cap, which does bound the count behavior an agent will report.

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 the purpose, then structured as caveats then USE WHEN / SIDE EFFECTS, with zero filler sentences. It is dense but repetitive on one point: 'Creates nothing and changes nothing', the readOnlyHint annotation, and 'SIDE EFFECTS: none' say the same thing three times.

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?

Very strong for a 12-parameter, 0%-coverage tool: the output keys currentMatches and overlapping are explained in the description (beyond what an output schema would convey), and the trust caveats are the ones an agent actually needs to relay to a user. Completeness is only dinged by the unexplained maxMessages bound and the unmentioned removeLabels/excludeChats/sizeComparison parameters.

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 coverage is 0% across 12 parameters, so the description carries the burden and does explain the meaningful ones: the from/to/subject/query field grouping, the label-existence check on addLabels, and the negatedQuery/hasAttachment:false edge case. It leaves maxMessages (default 1000, max 10000), excludeChats, size, sizeComparison and removeLabels entirely unaddressed, which is a real gap at this parameter count.

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?

States a specific verb and object — preview/check a filter's criteria before creation — and enumerates exactly what the check returns (match count, exact-duplicate filters, field-value overlaps, nonexistent addLabels names). It explicitly positions itself against create_filter, so an agent can distinguish the two without opening either schema.

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?

Gives an explicit trigger ('USE WHEN: before create_filter, to show the user what the rule would catch and avoid a duplicate'), naming the sibling and the goal state that selects it. It also states the parity guarantee (a preview cannot accept what the create would refuse), which tells the agent this is a safe pre-check rather than an alternative path.

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