Skip to main content
Glama
mailtrap

MCP Mailtrap Server

Official
by mailtrap

list-templates

Retrieve all email templates from the Mailtrap MCP server to manage and use them for transactional emails or testing.

Instructions

List all email templates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that executes the 'list-templates' tool logic. It lists email templates from the Mailtrap API, formats them nicely, and handles errors.
    async function listTemplates(): Promise<{ content: any[]; isError?: boolean }> { try { if (!client) { throw new Error("MAILTRAP_API_TOKEN environment variable is required"); } const templates = await client.templates.getList(); if (!templates || templates.length === 0) { return { content: [ { type: "text", text: "No templates found in your Mailtrap account.", }, ], }; } const templateList = templates .map( (template) => `• ${template.name} (ID: ${template.id}, UUID: ${template.uuid})\n Subject: ${template.subject}\n Category: ${template.category}\n Created: ${template.created_at}\n` ) .join("\n"); return { content: [ { type: "text", text: `Found ${templates.length} template(s):\n\n${templateList}`, }, ], }; } catch (error) { console.error("Error listing templates:", error); const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to list templates: ${errorMessage}`, }, ], isError: true, }; } }
  • The input schema for the 'list-templates' tool, defining an empty object since no input parameters are required.
    const listTemplatesSchema = { type: "object", properties: {}, additionalProperties: false, };
  • src/server.ts:55-63 (registration)
    The registration of the 'list-templates' tool in the server's tools array, linking the name, description, schema, and handler.
    { name: "list-templates", description: "List all email templates", inputSchema: listTemplatesSchema, handler: listTemplates, annotations: { readOnlyHint: true, }, },

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

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