Skip to main content
Glama
samihalawa

SMTP MCP Server

add-smtp-config

Configure SMTP server settings for sending emails by specifying host, port, credentials, and security options. Add multiple configurations to manage email delivery through the SMTP MCP Server.

Instructions

Add a new SMTP configuration

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the SMTP configuration
hostYesSMTP host
portYesSMTP port
secureNoWhether to use secure connection (SSL/TLS)
userYesSMTP username
passYesSMTP password
isDefaultNoWhether this configuration should be the default

Implementation Reference

  • The main handler function that executes the 'add-smtp-config' tool. It generates a unique ID, creates the SMTP config object from parameters, handles setting as default by unsetting others, appends to list, and saves.
    async function handleAddSmtpConfig(parameters: any) {
      try {
        // Get existing configs
        const configs = await getSmtpConfigs();
        
        // Create a new config
        const newConfig: SmtpServerConfig = {
          id: generateUUID(),
          name: parameters.name,
          host: parameters.host,
          port: parameters.port,
          secure: parameters.secure ?? false,
          auth: {
            user: parameters.user,
            pass: parameters.pass
          },
          isDefault: parameters.isDefault ?? false
        };
        
        // If this is set as default, update other configs
        if (newConfig.isDefault) {
          configs.forEach(config => {
            config.isDefault = false;
          });
        }
        
        // Add the new config to the list
        configs.push(newConfig);
        
        // Save the updated configs
        await saveSmtpConfigs(configs);
        
        return {
          success: true,
          config: newConfig
        };
      } catch (error) {
        logToFile('Error in handleAddSmtpConfig:');
        logToFile(error instanceof Error ? error.message : 'Unknown error');
        return {
          success: false,
          message: error instanceof Error ? error.message : 'Unknown error'
        };
      }
    }
  • The tool schema definition for 'add-smtp-config', including input schema with properties and required fields.
    "add-smtp-config": {
      name: "add-smtp-config",
      description: "Add a new SMTP configuration",
      inputSchema: {
        type: "object",
        properties: {
          name: {
            type: "string",
            description: "Name of the SMTP configuration"
          },
          host: {
            type: "string",
            description: "SMTP host"
          },
          port: {
            type: "number",
            description: "SMTP port"
          },
          secure: {
            type: "boolean",
            description: "Whether to use secure connection (SSL/TLS)"
          },
          user: {
            type: "string",
            description: "SMTP username"
          },
          pass: {
            type: "string",
            description: "SMTP password"
          },
          isDefault: {
            type: "boolean",
            description: "Whether this configuration should be the default"
          }
        },
        required: ["name", "host", "port", "user", "pass"]
      }
    },
  • The switch case registration in the CallToolRequestHandler that dispatches 'add-smtp-config' tool calls to the specific handler function.
    case "add-smtp-config":
      return await handleAddSmtpConfig(toolParams);

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