Skip to main content
Glama

send-email

Send emails directly from AI models using the Email MCP server. Specify recipient, subject, and content to dispatch messages with JWT authentication.

Instructions

发送邮件

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYes邮件收件人
subjectYes邮件主题
textYes邮件内容

Implementation Reference

  • Core handler function for sending emails. Supports Gmail OAuth2 API and generic SMTP. Handles attachments, HTML, configuration from env vars, and returns formatted MCP content response.
    export function createSendEmailTool() {
        return async (args) => {
            try {
                const config = getEmailConfig();
                // 验证必需的环境变量
                if (config.provider === "gmail") {
                    if (!config.gmail?.clientId || !config.gmail?.clientSecret || !config.gmail?.refreshToken) {
                        throw new Error("Gmail配置缺失。请设置 GMAIL_CLIENT_ID, GMAIL_CLIENT_SECRET, 和 GMAIL_REFRESH_TOKEN");
                    }
                }
                else {
                    if (!config.smtp?.auth.user || !config.smtp?.auth.pass) {
                        throw new Error("SMTP配置缺失。请设置 SMTP_USER 和 SMTP_PASS");
                    }
                }
                if (!config.defaultFrom) {
                    throw new Error("DEFAULT_FROM_EMAIL 环境变量是必需的");
                }
                let result;
                if (config.provider === "gmail") {
                    result = await sendViaGmail(args, config);
                }
                else {
                    result = await sendViaSMTP(args, config);
                }
                return {
                    content: [
                        {
                            type: "text",
                            text: `✅ 邮件发送成功!\n\n详情:\n- 收件人: ${args.to}\n- 主题: ${args.subject}\n- 提供商: ${result.provider}\n- 消息ID: ${result.messageId}\n- 格式: ${args.html ? "HTML" : "纯文本"}${args.attachments ? `\n- 附件数量: ${args.attachments.length}` : ""}`,
                        },
                    ],
                };
            }
            catch (error) {
                const errorMessage = error instanceof Error ? error.message : "发生未知错误";
                return {
                    content: [
                        {
                            type: "text",
                            text: `❌ 邮件发送失败: ${errorMessage}`,
                        },
                    ],
                };
            }
        };
    }
  • Zod validation schema for send_email tool input arguments.
    const SendEmailSchema = z.object({
        to: z.string().email(),
        subject: z.string(),
        body: z.string(),
        from: z.string().email().optional(),
        html: z.boolean().optional(),
        attachments: z.array(z.object({
            filename: z.string(),
            path: z.string().optional(),
            content: z.string().optional(),
        })).optional(),
    });
  • dist/index.js:65-105 (registration)
    MCP tool registration for 'send_email', including metadata and input schema for tool discovery via ListTools.
        name: "send_email",
        description: "Send an email to specified recipients",
        inputSchema: {
            type: "object",
            properties: {
                to: {
                    type: "string",
                    description: "Recipient email address",
                },
                subject: {
                    type: "string",
                    description: "Email subject",
                },
                body: {
                    type: "string",
                    description: "Email body content",
                },
                from: {
                    type: "string",
                    description: "Sender email address (optional)",
                },
                html: {
                    type: "boolean",
                    description: "Whether the body is HTML format",
                },
                attachments: {
                    type: "array",
                    description: "Email attachments",
                    items: {
                        type: "object",
                        properties: {
                            filename: { type: "string" },
                            path: { type: "string" },
                            content: { type: "string" },
                        },
                    },
                },
            },
            required: ["to", "subject", "body"],
        },
    },
  • Server-side dispatch handler that routes 'send_email' calls, validates args, instantiates tool, and executes.
    case "send_email": {
        const args = SendEmailSchema.parse(request.params.arguments);
        const sendEmailTool = createSendEmailTool();
        return await sendEmailTool(args);
Behavior1/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. '发送邮件' only states the action without any behavioral traits like whether it's a read/write operation, potential side effects (e.g., email delivery failures, rate limits), or authentication requirements. This is inadequate for a mutation tool with zero annotation coverage.

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?

The description is overly concise at just two characters ('发送邮件'), which represents under-specification rather than efficient brevity. It lacks any structure or front-loading of key information, failing to provide necessary context for tool selection and use.

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?

Given this is a mutation tool (sending email) with no annotations, no output schema, and a minimal description, the description is completely inadequate. It doesn't cover behavioral aspects, usage context, or any details beyond the basic action, leaving significant gaps for an AI agent to operate effectively.

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 clear descriptions for 'to', 'subject', and 'text' parameters in Chinese. The description adds no parameter information beyond what the schema provides, but since the schema does the heavy lifting, the baseline score of 3 is appropriate as it doesn't degrade understanding.

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 restates the tool name without providing any additional specificity. It doesn't distinguish what type of email sending this is (e.g., transactional, bulk, with attachments) or clarify the scope beyond the basic verb+resource. While the purpose is technically stated, it's minimal and lacks differentiation.

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 no guidance on when to use this tool, such as prerequisites (e.g., authentication needed), alternatives (though no siblings exist), or specific contexts. It's a single phrase with no usage instructions, leaving the agent to guess based on the tool name alone.

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

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