Skip to main content
Glama

get-email-templates

Retrieve all available email templates from the SMTP MCP Server for use in automated email campaigns with variable substitution.

Instructions

Get all email templates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'get-email-templates' tool. It retrieves all email templates using getEmailTemplates() from config.ts and returns them wrapped in a success response object.
    async function handleGetEmailTemplates() { try { const templates = await getEmailTemplates(); return { success: true, templates: templates }; } catch (error) { logToFile('Error in handleGetEmailTemplates:'); logToFile(error instanceof Error ? error.message : 'Unknown error'); return { success: false, message: error instanceof Error ? error.message : 'Unknown error' }; }
  • The tool schema definition for 'get-email-templates', including name, description, and empty input schema (no parameters required).
    "get-email-templates": { name: "get-email-templates", description: "Get all email templates", inputSchema: { type: "object", properties: {}, required: [] }
  • Switch case in the CallToolRequestSchema handler that dispatches 'get-email-templates' tool calls to the handleGetEmailTemplates function.
    case "get-email-templates": return await handleGetEmailTemplates();
  • src/index.ts:59-62 (registration)
    Creates the tool definitions object (including 'get-email-templates') using createToolDefinitions() and passes it to setupRequestHandlers for server registration.
    const TOOLS = createToolDefinitions(); // Setup request handlers await setupRequestHandlers(server, TOOLS);
  • Helper function getEmailTemplates() that reads all JSON template files from the templates directory and returns the list of EmailTemplate objects. Called by the tool handler.
    export async function getEmailTemplates(): Promise<EmailTemplate[]> { try { const files = await fs.readdir(TEMPLATES_DIR); const templates: EmailTemplate[] = []; for (const file of files) { if (file.endsWith('.json')) { const templatePath = path.join(TEMPLATES_DIR, file); const template = await fs.readJson(templatePath) as EmailTemplate; templates.push(template); } } return templates; } catch (error) { logToFile('Error reading email templates:'); return [DEFAULT_TEMPLATE, BUSINESS_TEMPLATE, NEWSLETTER_TEMPLATE]; } }

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/samihalawa/mcp-server-smtp'

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