Skip to main content
Glama

wait_for_email

Monitor an inbox for incoming emails and return them upon arrival. Set a timeout to control how long to wait for email delivery.

Instructions

Poll an inbox until an email arrives. Returns the email once received. Times out after the specified duration.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inbox_idYesThe inbox ID to wait on
timeout_secondsNoMax seconds to wait (default: 60, max: 300)

Implementation Reference

  • The actual implementation of the "wait_for_email" tool handler, which polls an inbox for new emails.
    async ({ inbox_id, timeout_seconds }) => {
      const timeout = Math.min(timeout_seconds ?? 60, 300);
      const deadline = Date.now() + timeout * 1000;
      const interval = 2000;
    
      while (Date.now() < deadline) {
        const result = (await blipFetch(`/v1/inboxes/${inbox_id}`)) as {
          emails?: { id: string }[];
        };
    
        if (result?.emails && result.emails.length > 0) {
          // Return the full detail of the most recent email
          const email = await blipFetch(`/v1/emails/${result.emails[0].id}`);
          return {
            content: [{ type: "text", text: JSON.stringify(email, null, 2) }],
          };
        }
    
        await new Promise((resolve) => setTimeout(resolve, interval));
      }
    
      return {
        content: [
          {
            type: "text",
            text: `No email received in inbox ${inbox_id} after ${timeout} seconds.`,
          },
        ],
      };
    }
  • Registration and schema definition for the "wait_for_email" tool.
    server.tool(
      "wait_for_email",
      "Poll an inbox until an email arrives. Returns the email once received. Times out after the specified duration.",
      {
        inbox_id: z.string().describe("The inbox ID to wait on"),
        timeout_seconds: z
          .number()
          .optional()
          .describe("Max seconds to wait (default: 60, max: 300)"),
      },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/blipemail/blip'

If you have feedback or need assistance with the MCP directory API, please join our Discord server