send-email
Send emails with subject, recipient, and body content through the Email Management MCP Server.
Instructions
Send Email with subject, destination and body
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | Destination email | |
| subject | Yes | Email subject, min 1 char and max 30 chars | |
| body | Yes | Email body, min 1 char and max 255 chars |
Implementation Reference
- src/tools/email.ts:104-131 (handler)Handler function registered for the 'send-email' tool. It constructs auth from headers, instantiates EmailClient, calls sendEmail, and returns structured response with success/error.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/types/email.ts:106-120 (schema)Zod input schema (SendEmailSchema) defining parameters for send-email tool: to, subject, body with validations.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) for send-email tool response: 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/tools/email.ts:86-133 (registration)MCP tool registration call for 'send-email' specifying title, description, annotations, input/output schemas, and handler function.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, }, 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/models/email.ts:70-76 (helper)Supporting method in EmailClient class that implements the email sending logic (mock implementation using random success). Called by the tool handler.sendEmail(params: SendEmailType) { const randonNumber = Math.random(); Logger.info ("Send email", params); return randonNumber > 0.15; }