Skip to main content
Glama
railsware

Mailtrap Email Sending

by railsware

get-sandbox-messages

Retrieve test email messages from the Mailtrap sandbox inbox for debugging and verification purposes.

Instructions

Get list of messages from the sandbox test inbox

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNoPage number for pagination
last_idNoPagination using last message ID. Returns messages after the specified message ID.
searchNoSearch query to filter messages

Implementation Reference

  • The handler function that retrieves and formats messages from the Mailtrap sandbox test inbox, supporting pagination with page/last_id and search.
    async function getMessages({
      page,
      last_id,
      search,
    }: GetMessagesRequest): Promise<{
      content: { type: string; text: string }[];
      isError?: boolean;
    }> {
      try {
        const { MAILTRAP_TEST_INBOX_ID } = process.env;
    
        if (!MAILTRAP_TEST_INBOX_ID) {
          throw new Error(
            "MAILTRAP_TEST_INBOX_ID environment variable is required for sandbox mode"
          );
        }
    
        // Check if sandbox client is available
        if (!sandboxClient) {
          throw new Error(
            "Sandbox client is not available. Please set MAILTRAP_TEST_INBOX_ID environment variable."
          );
        }
    
        const inboxId = Number(MAILTRAP_TEST_INBOX_ID);
        if (Number.isNaN(inboxId)) {
          throw new Error("MAILTRAP_TEST_INBOX_ID must be a valid number");
        }
    
        // Get messages from the inbox
        // MessageListOptions supports: page, last_id, and search
        const options: {
          page?: number;
          last_id?: number;
          search?: string;
        } = {};
    
        if (page !== undefined) {
          options.page = page;
        }
        if (last_id !== undefined) {
          options.last_id = last_id;
        }
        if (search !== undefined) {
          options.search = search;
        }
    
        const messages = await sandboxClient.testing.messages.get(
          inboxId,
          Object.keys(options).length > 0 ? options : undefined
        );
    
        if (!messages || messages.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: "No messages found in the sandbox inbox.",
              },
            ],
          };
        }
    
        const messageList = messages
          .map(
            (message: (typeof messages)[0]) =>
              `• Message ID: ${message.id}\n  From: ${message.from_email}\n  To: ${
                message.to_email
              }\n  Subject: ${message.subject}\n  Sent: ${
                message.sent_at
              }\n  Read: ${message.is_read ? "Yes" : "No"}\n`
          )
          .join("\n");
    
        return {
          content: [
            {
              type: "text",
              text: `Found ${messages.length} message(s) in sandbox inbox:\n\n${messageList}`,
            },
          ],
        };
      } catch (error) {
        console.error("Error getting messages:", error);
    
        const errorMessage = error instanceof Error ? error.message : String(error);
    
        return {
          content: [
            {
              type: "text",
              text: `Failed to get messages: ${errorMessage}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Input schema defining optional parameters: page (number >=1), last_id (number >=1), search (string).
    const getMessagesSchema = {
      type: "object",
      properties: {
        page: {
          type: "number",
          description: "Page number for pagination",
          minimum: 1,
        },
        last_id: {
          type: "number",
          description:
            "Pagination using last message ID. Returns messages after the specified message ID.",
          minimum: 1,
        },
        search: {
          type: "string",
          description: "Search query to filter messages",
        },
      },
      required: [],
      additionalProperties: false,
    };
  • src/server.ts:92-97 (registration)
    Tool registration in the tools array, linking name, description, schema, and handler.
    {
      name: "get-sandbox-messages",
      description: "Get list of messages from the sandbox test inbox",
      inputSchema: getMessagesSchema,
      handler: getMessages,
    },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action but lacks details on permissions, rate limits, response format, or whether this is a read-only operation. For a list operation with zero annotation coverage, this leaves significant gaps.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words or redundancy, making it appropriately front-loaded and concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain the return format, pagination behavior beyond schema hints, or how it interacts with sibling tools, leaving the agent with insufficient context for a list operation.

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

Parameters3/5

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

The schema description coverage is 100%, so the schema fully documents all three parameters (page, last_id, search). The description adds no additional parameter semantics beyond what the schema provides, meeting the baseline for high coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and resource 'list of messages from the sandbox test inbox', making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'show-sandbox-email-message' which might retrieve a single message, leaving some ambiguity about scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'show-sandbox-email-message' or 'send-sandbox-email', nor does it mention any prerequisites or contextual constraints for usage.

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

Install Server

Other Tools

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/railsware/mailtrap-mcp'

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