get-email-logs
Retrieve and filter email sending activity logs to monitor delivery status and troubleshoot issues.
Instructions
Get logs of all email sending activity
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of log entries to return (most recent first) | |
| filterBySuccess | No | Filter logs by success status (true = successful emails, false = failed emails) |
Implementation Reference
- src/requestHandler.ts:99-130 (handler)Executes the get-email-logs tool: calls getEmailLogs, applies optional filtering by success, sorts by timestamp descending, limits results, and returns them.case "get-email-logs": { const { limit, filterBySuccess } = toolParams as { limit?: number; filterBySuccess?: boolean; }; try { let logs = await getEmailLogs(); // Filter by success status if specified if (filterBySuccess !== undefined) { logs = logs.filter((log: EmailLogEntry) => log.success === filterBySuccess); } // Sort by timestamp in descending order (newest first) logs = logs.sort((a: EmailLogEntry, b: EmailLogEntry) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime() ); // Limit the number of results if specified if (limit && limit > 0) { logs = logs.slice(0, limit); } return { result: logs }; } catch (error) { logToFile(`Error getting email logs: ${error}`); throw new Error("Failed to retrieve email logs"); } }
- src/tools.ts:368-384 (schema)Tool definition including name, description, and input schema for get-email-logs."get-email-logs": { name: "get-email-logs", description: "Get logs of all email sending activity", inputSchema: { type: "object", properties: { limit: { type: "number", description: "Maximum number of log entries to return (most recent first)" }, filterBySuccess: { type: "boolean", description: "Filter logs by success status (true = successful emails, false = failed emails)" } } } }
- src/config.ts:287-297 (helper)Reads email log entries from the JSON log file, returns empty array if not found or on error.export async function getEmailLogs(): Promise<EmailLogEntry[]> { try { if (await fs.pathExists(LOG_FILE)) { return await fs.readJson(LOG_FILE) as EmailLogEntry[]; } return []; } catch (error) { logToFile('Error reading email logs:'); return []; } }