update-smtp-config
Modify SMTP server settings for email sending in the SMTP MCP Server. Change host, port, security, credentials, or default status of existing configurations.
Instructions
Update an existing SMTP configuration
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the SMTP configuration to update | |
| name | No | Name of the SMTP configuration | |
| host | No | SMTP host | |
| port | No | SMTP port | |
| secure | No | Whether to use secure connection (SSL/TLS) | |
| user | No | SMTP username | |
| pass | No | SMTP password | |
| isDefault | No | Whether this configuration should be the default |
Implementation Reference
- src/requestHandler.ts:288-347 (handler)The main handler function that executes the update-smtp-config tool logic: finds the SMTP config by ID, applies provided updates to its properties, manages default status across configs, and persists the changes using saveSmtpConfigs.* Handle update-smtp-config tool call */ async function handleUpdateSmtpConfig(parameters: any) { try { // Get existing configs const configs = await getSmtpConfigs(); // Find the config to update const configIndex = configs.findIndex(config => config.id === parameters.id); if (configIndex === -1) { return { success: false, message: `SMTP configuration with ID ${parameters.id} not found` }; } // Update the config const updatedConfig = { ...configs[configIndex] }; if (parameters.name !== undefined) updatedConfig.name = parameters.name; if (parameters.host !== undefined) updatedConfig.host = parameters.host; if (parameters.port !== undefined) updatedConfig.port = parameters.port; if (parameters.secure !== undefined) updatedConfig.secure = parameters.secure; if (parameters.user !== undefined) updatedConfig.auth.user = parameters.user; if (parameters.pass !== undefined) updatedConfig.auth.pass = parameters.pass; // Handle default flag if (parameters.isDefault !== undefined) { updatedConfig.isDefault = parameters.isDefault; // If setting as default, update other configs if (updatedConfig.isDefault) { configs.forEach((config, index) => { if (index !== configIndex) { config.isDefault = false; } }); } } // Update the config in the list configs[configIndex] = updatedConfig; // Save the updated configs await saveSmtpConfigs(configs); return { success: true, config: updatedConfig }; } catch (error) { logToFile('Error in handleUpdateSmtpConfig:'); logToFile(error instanceof Error ? error.message : 'Unknown error'); return { success: false, message: error instanceof Error ? error.message : 'Unknown error' }; } }
- src/tools.ts:227-268 (schema)The Tool definition object including inputSchema for validating parameters of the update-smtp-config tool (requires 'id', optional fields for name, host, port, secure, user, pass, isDefault)."update-smtp-config": { name: "update-smtp-config", description: "Update an existing SMTP configuration", inputSchema: { type: "object", properties: { id: { type: "string", description: "ID of the SMTP configuration to update" }, 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: ["id"] } },
- src/requestHandler.ts:81-82 (registration)The switch case in the call_tool request handler that registers and dispatches to the specific handlerUpdateSmtpConfig for the update-smtp-config tool.case "update-smtp-config": return await handleUpdateSmtpConfig(toolParams);
- src/index.ts:59-59 (registration)Where the tools record (including update-smtp-config) is created via createToolDefinitions() and passed to setupRequestHandlers for MCP server registration.const TOOLS = createToolDefinitions();