Skip to main content
Glama

mcp_email_send

Send emails through SMTP protocol by providing server credentials, recipient information, subject, and message content.

Instructions

发送邮件

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostYesSMTP服务器主机名
portYesSMTP服务器端口号
subjectYes邮件主题
toYes收件人邮箱地址
bodyYes邮件正文
fromYes发件人邮箱地址
fromPasswordYes发件人邮箱密码

Implementation Reference

  • The MCP tool handler function for 'mcp_email_send'. It logs the input parameters, instantiates EmailService, calls sendEmail with the parameters, logs the result, and returns a formatted text content response.
    server.tool('mcp_email_send', "发送邮件", param, async (param) => {
      log(JSON.stringify(param))
      // 调用EmailService发送邮件
      const emailService = new EmailService();
      const result = await emailService.sendEmail(param);
      log(JSON.stringify(result))
      return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2)
            }
          ]
        };
    })
  • Zod schema defining the input parameters for the mcp_email_send tool, including validation and descriptions.
    const param = {
      host: z.string().describe('SMTP服务器主机名'),
      port: z.number().int().positive().describe('SMTP服务器端口号'),
      subject: z.string().describe('邮件主题'),
      to: z.string().email("无效的邮箱地址").describe('收件人邮箱地址'),
      body: z.string().min(1, "邮件正文不能为空").describe('邮件正文'),
      from: z.string().email("无效的邮箱地址").describe('发件人邮箱地址'),
      fromPassword: z.string().min(1, "发件人邮箱密码不能为空").describe('发件人邮箱密码')
    }
  • src/server.ts:39-53 (registration)
    Registration of the 'mcp_email_send' tool with the MCP server using server.tool, providing name, description, schema, and handler.
    server.tool('mcp_email_send', "发送邮件", param, async (param) => {
      log(JSON.stringify(param))
      // 调用EmailService发送邮件
      const emailService = new EmailService();
      const result = await emailService.sendEmail(param);
      log(JSON.stringify(result))
      return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2)
            }
          ]
        };
    })
  • The EmailService.sendEmail helper method that implements the actual email sending logic using nodemailer, handling SMTP configuration, sending the email, and returning success/failure status.
    async sendEmail(param: EmailSendParam): Promise<{success: boolean, message: string}> {
        try {
            // 创建邮件传输器
            const transporter = nodemailer.createTransport({
                host: param.host,
                port: param.port,
                secure: true, // 使用SSL
                auth: {
                    user: param.from,
                    pass: param.fromPassword
                },
                tls: {
                    rejectUnauthorized: false // 允许使用自签名证书
                }
            });
    
            // 邮件选项
            const mailOptions = {
                from: param.from,
                to: param.to,
                subject: param.subject,
                html: param.body
            };
    
            // 发送邮件
            const info = await transporter.sendMail(mailOptions);
            
            console.log(`[${new Date().toISOString()}] 邮件发送成功!MessageID: ${info.messageId}`);
            
            return {
                success: true,
                message: `邮件发送成功,MessageID: ${info.messageId}`
            };
    
        } catch (error) {
            console.error(`[${new Date().toISOString()}] 邮件发送失败: ${error instanceof Error ? error.message : String(error)}`);
            
            return {
                success: false,
                message: `邮件发送失败: ${error instanceof Error ? error.message : String(error)}`
            };
        }
    }
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but fails completely. '发送邮件' reveals nothing about authentication requirements (though parameters suggest SMTP credentials), rate limits, error conditions, what happens upon success, or any side effects. For a tool that sends emails with sensitive credential parameters, this lack of transparency is particularly problematic.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

While technically concise with just two characters, this represents severe under-specification rather than effective brevity. The description fails to communicate essential information that would help an agent use the tool correctly. Every sentence should earn its place, but here the single phrase doesn't earn its place by providing meaningful guidance.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 7 required parameters (including sensitive credentials), no annotations, and no output schema, the description is completely inadequate. It doesn't explain what the tool returns, what happens on success/failure, authentication requirements, or any behavioral aspects. The description fails to compensate for the lack of structured metadata that would help an agent understand this complex email-sending operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with all 7 parameters well-documented in the schema itself. The description adds zero information about parameters beyond what's already in the schema. According to scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no parameter information in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '发送邮件' (send email) is a tautology that merely restates the tool name 'mcp_email_send'. It provides no additional specificity about what kind of email sending operation this performs, what resources it acts upon, or how it differs from other potential email tools. While the verb 'send' is clear, the description lacks any distinguishing details about scope or functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides absolutely no guidance on when to use this tool. There are no sibling tools mentioned, but the description doesn't indicate prerequisites, constraints, or appropriate contexts for invocation. An agent would have no information about when this tool is applicable versus alternatives that might exist elsewhere.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/caijianying/email-mcp'

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