Skip to main content
Glama

Search mail messages

mail_search_messages
Read-onlyIdempotent

Search emails by text across subject, body, and participants. Leave dates out for relevance-ranked full-text search, or add before/after to get newest-first results by received time.

Instructions

Finds messages by text, returning the same compact projection as mail_list_messages, 10 per call by default (50 max). Two modes, because Graph will not combine them: with no date range it uses $search, a relevance-ranked KQL search over subject, body and participants (results are NOT in date order, and $search supports no date syntax). Passing after or before switches to $filter on receivedDateTime, which sorts newest-first but can only match query as a substring of the subject — body text is not searched in that mode. The response reports which mode ran. To search body text within a period, search first and filter the dates yourself.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toNoOnly messages addressed to this exact address.
topNoHow many messages to return. Defaults to 10; 50 is the ceiling.
fromNoOnly messages sent by this exact address.
afterNoOnly messages received at or after this ISO-8601 date or datetime, e.g. "2026-01-01" or "2026-01-01T09:00:00Z". A bare date starts at 00:00:00Z. Supplying this switches the tool to $filter mode.
queryYesWords to look for. Without a date range this is a KQL search across subject, body, and participants, so "subject:budget" or "quarterly review" both work. With after/before it degrades to a subject substring match — see the tool description.
beforeNoOnly messages received at or before this ISO-8601 date or datetime. A bare date ends at 23:59:59Z that day. Supplying this switches the tool to $filter mode.
hasAttachmentsNoOnly messages with (or without) attachments.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A5/5.0
Behavior5/5

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

Annotations already cover readOnly, idempotent, and non-destructive behavior, so the burden is on behavior beyond that. The description adds high-value traits: results are not in date order in $search mode, $search supports no date syntax, $filter only matches subject substrings, and the response reports which mode ran. This is substantial behavioral disclosure that structured fields cannot convey.

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 is dense but every clause earns its place: projection, pagination, mode selection, ordering, and a workaround for the body-text-with-date limitation. The most important scoping fact (text search) is front-loaded, and there is no filler or restatement of obvious annotation data.

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 search tool with no output schema, the description tells the agent what projection to expect (via mail_list_messages), the default page size and cap, the mode behavior, and how to compensate for mode limitations. Nothing an agent needs to invoke it correctly or interpret its response is missing.

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

Parameters5/5

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

Although schema coverage is 100%, the description adds meaning the schema alone cannot: after and before are not just date filters but mode switches, and query changes semantics depending on whether a date range is present. This directly affects correct invocation and interpretation of results, going well beyond the schema's property-level descriptions.

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 and resource: "Finds messages by text," and immediately distinguishes it from mail_list_messages via the "same compact projection" reference. The two-mode explanation further separates it from both a plain list operation and a generic search, so an agent can select it confidently.

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?

The description explicitly states when to use each mode: no date range triggers $search, while passing after/before triggers $filter, and it explains the trade-offs of each. It even gives a concrete fallback strategy for searching body text within a period, which is exactly the kind of actionable usage guidance an agent needs.

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