Skip to main content
Glama
railsware

Mailtrap Email Sending

by railsware

show-sandbox-email-message

Retrieve and display email message details and content from the Mailtrap sandbox test inbox for debugging and verification purposes.

Instructions

Show sandbox email message details and content from the sandbox test inbox

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
message_idYesID of the sandbox email message to retrieve

Implementation Reference

  • The handler function `showEmailMessage` that executes the tool logic: fetches sandbox email message details, HTML, and text content from Mailtrap API, formats them, and returns as MCP content.
    async function showEmailMessage({
      message_id,
    }: ShowEmailMessageRequest): Promise<{ content: any[]; 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);
    
        // Get message details
        // The showEmailMessage method takes inboxId and messageId
        const message = await sandboxClient.testing.messages.showEmailMessage(
          inboxId,
          message_id
        );
    
        if (!message) {
          return {
            content: [
              {
                type: "text",
                text: `Message with ID ${message_id} not found.`,
              },
            ],
            isError: true,
          };
        }
    
        // Get HTML and text content
        let htmlContent = "";
        let textContent = "";
    
        try {
          htmlContent = await sandboxClient.testing.messages.getHtmlMessage(
            inboxId,
            message_id
          );
        } catch (error) {
          // HTML might not be available
          console.warn("Could not retrieve HTML content:", error);
        }
    
        try {
          textContent = await sandboxClient.testing.messages.getTextMessage(
            inboxId,
            message_id
          );
        } catch (error) {
          // Text might not be available
          console.warn("Could not retrieve text content:", error);
        }
    
        const messageDetails = [
          `Message ID: ${message.id}`,
          `From: ${message.from_email}`,
          `To: ${message.to_email}`,
          `Subject: ${message.subject}`,
          `Sent: ${message.sent_at}`,
          `Read: ${message.is_read ? "Yes" : "No"}`,
          message.html_body_size
            ? `HTML Size: ${message.html_body_size} bytes`
            : "",
          message.text_body_size
            ? `Text Size: ${message.text_body_size} bytes`
            : "",
          message.email_size ? `Total Size: ${message.email_size} bytes` : "",
        ]
          .filter(Boolean)
          .join("\n");
    
        let contentText = `Sandbox Email Message Details:\n\n${messageDetails}`;
    
        if (htmlContent) {
          contentText += `\n\n--- HTML Content ---\n${htmlContent}`;
        }
    
        if (textContent) {
          contentText += `\n\n--- Text Content ---\n${textContent}`;
        }
    
        if (!htmlContent && !textContent) {
          contentText += "\n\nNote: Message body content could not be retrieved.";
        }
    
        return {
          content: [
            {
              type: "text",
              text: contentText,
            },
          ],
        };
      } catch (error) {
        console.error("Error showing sandbox email message:", error);
    
        const errorMessage = error instanceof Error ? error.message : String(error);
    
        return {
          content: [
            {
              type: "text",
              text: `Failed to show sandbox email message: ${errorMessage}`,
            },
          ],
          isError: true,
        };
      }
    }
  • The input schema defining the `message_id` parameter for the tool.
    const showEmailMessageSchema = {
      type: "object",
      properties: {
        message_id: {
          type: "number",
          description: "ID of the sandbox email message to retrieve",
        },
      },
      required: ["message_id"],
      additionalProperties: false,
    };
    
    export default showEmailMessageSchema;
  • src/server.ts:98-104 (registration)
    Registration of the tool in the server's tools array, linking name, schema, and handler.
    {
      name: "show-sandbox-email-message",
      description:
        "Show sandbox email message details and content from the sandbox test inbox",
      inputSchema: showEmailMessageSchema,
      handler: showEmailMessage,
    },
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states 'show' implies a read operation, but doesn't disclose behavioral traits like whether it requires authentication, rate limits, error handling (e.g., invalid message_id), or what 'details and content' includes (e.g., headers, body, attachments). This leaves significant gaps for a tool with no annotation coverage.

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 with zero waste. It's front-loaded with the core purpose and includes essential context ('from the sandbox test inbox'), making it appropriately sized for a simple tool.

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

Completeness3/5

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

Given 1 parameter with full schema coverage and no output schema, the description is minimally adequate. It specifies the resource scope ('sandbox test inbox') but lacks behavioral details (e.g., response format, error cases) and usage guidelines, leaving room for improvement despite the tool's low complexity.

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 input schema has 100% description coverage, with 'message_id' documented as 'ID of the sandbox email message to retrieve'. The description adds no additional parameter semantics beyond this, such as format examples or constraints. Baseline 3 is appropriate when schema does the heavy lifting.

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 'show' and the resource 'sandbox email message details and content', specifying it's from the 'sandbox test inbox'. It distinguishes from siblings like 'get-sandbox-messages' (which likely lists messages) and 'send-sandbox-email' (which sends messages), but doesn't explicitly contrast them in the description text.

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. It doesn't mention prerequisites (e.g., needing a valid message_id from the sandbox), exclusions, or comparisons to sibling tools like 'get-sandbox-messages' for listing messages first.

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