send-email
Send emails with subject, recipient address, and message body to communicate information or respond to messages through the email management system.
Instructions
Send Email with subject, destination and body
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | Yes | Email body, min 1 char and max 255 chars | |
| subject | Yes | Email subject, min 1 char and max 30 chars | |
| to | Yes | Destination email |
Implementation Reference
- src/tools/email.ts:104-132 (handler)Handler function for the 'send-email' tool. It extracts auth info from request headers, creates an EmailClient instance, calls sendEmail on it, and returns a structured response with success/error status.async (params, {requestInfo}) => { const authEmail = { port: requestInfo?.headers["email-port"], email: requestInfo?.headers["email-username"], password: requestInfo?.headers["email-password"], clientType: requestInfo?.headers["email-client-type"], } as AuthEmailType; const emailClient = new EmailClient (authEmail); const result = await emailClient.sendEmail(params); const response = { success: result, error: result ? null : "No hay conexión con el servidor" } return { isError: !result, content: [ { type: "text", text: JSON.stringify(response) }, ], structuredContent: response, };
- src/tools/email.ts:86-103 (registration)Registers the 'send-email' tool on the MCP server with title, description, annotations, examples, input and output schemas.server.registerTool( "send-email", { title: "Send Email", description: "Send Email with subject, destination and body", annotations: { openWorlHint: true, examples: { input: { to: "example@domain.com", subject: "Example Subject", body: "Example Body", }, }, }, inputSchema: SendEmailSchema.shape, outputSchema: OutputSendEmailSchema.shape, },
- src/types/email.ts:106-120 (schema)Zod input schema (SendEmailSchema) used by the 'send-email' tool, defining 'to', 'subject', and 'body' fields.export const SendEmailSchema = z.object({ to: z.string().email().describe('Destination email'), subject: z. string() .min(1) .max(30) .describe('Email subject, min 1 char and max 30 chars'), body: z. string() .min(1) .max(255). describe('Email body, min 1 char and max 255 chars'), }) export type SendEmailType = z.infer<typeof SendEmailSchema>;
- src/types/email.ts:122-126 (schema)Zod output schema (OutputSendEmailSchema) used by the 'send-email' tool, with 'success' boolean and optional 'error' string.export const OutputSendEmailSchema = z.object({ success: z.boolean(), error: z.string().nullish(), }); export type OutputSendEmailType = z.infer<typeof OutputSendEmailSchema>;
- src/models/email.ts:70-76 (helper)EmailClient.sendEmail helper method called by the tool handler. Currently a mock implementation that returns true randomly.sendEmail(params: SendEmailType) { const randonNumber = Math.random(); Logger.info ("Send email", params); return randonNumber > 0.15; }