mailosaur_messages_get
Retrieves the first matching email or SMS message from a Mailosaur server, waiting briefly if needed. Ideal for automated testing to confirm receipt of expected messages.
Instructions
Wait for and return the first full message matching criteria. Best for test flows where an email/SMS may arrive shortly.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| server | Yes | Mailosaur server ID. | |
| criteria | Yes | ||
| options | No |
Implementation Reference
- src/index.ts:120-134 (registration)Registration of the 'mailosaur_messages_get' tool via server.tool(), defining its name, description, schema, and handler.
server.tool( "mailosaur_messages_get", "Wait for and return the first full message matching criteria. Best for test flows where an email/SMS may arrive shortly.", { server: z.string().describe("Mailosaur server ID."), criteria: SearchCriteriaSchema, options: MessageWaitOptionsSchema.optional() }, async ({ server, criteria, options }) => { const searchOptions = toSearchOptions(options); const { errorOnTimeout: _errorOnTimeout, ...getOptions } = searchOptions ?? {}; const message = await mailosaur.messages.get(server, criteria, getOptions); return response(message); } ); - src/index.ts:128-133 (handler)Handler function that receives server, criteria, and options, calls mailosaur.messages.get(), and returns the response.
async ({ server, criteria, options }) => { const searchOptions = toSearchOptions(options); const { errorOnTimeout: _errorOnTimeout, ...getOptions } = searchOptions ?? {}; const message = await mailosaur.messages.get(server, criteria, getOptions); return response(message); } - src/index.ts:123-127 (schema)Input schema for the tool: server (string), criteria (SearchCriteriaSchema), and optional options (MessageWaitOptionsSchema).
{ server: z.string().describe("Mailosaur server ID."), criteria: SearchCriteriaSchema, options: MessageWaitOptionsSchema.optional() }, - src/index.ts:38-41 (schema)Definition of MessageWaitOptionsSchema used by the tool's options parameter.
const MessageWaitOptionsSchema = MessageListOptionsSchema.extend({ timeout: z.number().int().min(1).optional(), errorOnTimeout: z.boolean().optional() }); - src/index.ts:23-29 (schema)Definition of SearchCriteriaSchema used by the tool's criteria parameter.
const SearchCriteriaSchema = z.object({ sentFrom: z.string().optional(), sentTo: z.string().optional(), subject: z.string().optional(), body: z.string().optional(), match: z.enum(["ALL", "ANY"]).optional() });