Skip to main content
Glama
mailtrap

MCP Mailtrap Server

Official
by mailtrap

list-templates

Retrieve all available email templates from the Mailtrap server for managing transactional emails and testing scenarios.

Instructions

List all email templates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'list-templates' tool. It fetches the list of email templates from the Mailtrap API, formats them into a readable list, or returns an error message if the operation fails.
    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 parameters are required.
    const listTemplatesSchema = { type: "object", properties: {}, additionalProperties: false, }; export default listTemplatesSchema;
  • src/server.ts:55-63 (registration)
    Registration of the 'list-templates' tool in the tools array, linking the name, description, schema, and handler function.
    { 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