/** * Tool: read_emails * * Retrieves and reads emails from Firefox Relay addresses with OTP extraction * and security analysis capabilities. * * Follows golden-standard programming practices: * - Zod v4 validation for input parameters * - Comprehensive error handling with custom error classes * - Database persistence with PQC encryption at rest * - OTP extraction and security analysis * - Audit logging for security and traceability */ import { z } from 'zod/v4'; import { DatabaseEmailLog, MCPTool, ToolResult, OtpExtractionResult, SecurityFlag } from '../types'; /** * Schema for validating read_emails tool input */ export declare const ReadEmailsInputSchema: z.ZodObject<{ relayAddressId: z.ZodOptional; relayAddress: z.ZodOptional; emailId: z.ZodOptional; limit: z.ZodDefault>; extractOtp: z.ZodDefault>; markAsRead: z.ZodDefault>; otpOnly: z.ZodDefault>; unreadOnly: z.ZodDefault>; searchQuery: z.ZodOptional; }, z.core.$strip>; /** * Type for validated input */ export type ReadEmailsInput = z.infer; /** * Response type for a retrieved email */ export interface RetrievedEmail { id: number; emailId: string; relayAddressId: number; fullRelayAddress: string; sender: string; recipient: string; subject: string; body: string | null; html: string | null; receivedAt: string; readAt: string | null; isRead: boolean; size: number; otpCode: string | null; isOtp: boolean; otpInfo: OtpExtractionResult | null; securityFlags: SecurityFlag[]; headers: Record | null; } /** * Response type for the read_emails tool */ export interface ReadEmailsResponse { success: boolean; emails: RetrievedEmail[]; count: number; totalAvailable: number; hasMore: boolean; requestId: string; timestamp: string; error?: string; } /** * Custom error for email retrieval failures */ export declare class EmailRetrievalError extends Error { readonly code: string; readonly details?: Record | undefined; constructor(message: string, code?: string, details?: Record | undefined); } /** * Custom error for not found resources */ export declare class ResourceNotFoundError extends Error { readonly resourceType: string; readonly identifier: string | number; constructor(message: string, resourceType: string, identifier: string | number); } /** * Process raw email content into structured format */ export declare function processEmailContent(dbEmail: DatabaseEmailLog & { full_address: string; }, extractOtp?: boolean): RetrievedEmail; /** * Retrieves and reads emails from Firefox Relay addresses * * This function: * 1. Validates input using Zod v4 * 2. Retrieves emails from the database based on criteria * 3. Extracts OTP codes if requested * 4. Performs security analysis on email content * 5. Marks emails as read if requested * 6. Logs all operations to audit trail * * @param input - Validated input parameters * @param context - MCP tool execution context * @returns Tool result with retrieved emails */ export declare function readEmailsHandler(input: unknown, context?: Record): Promise; /** * MCP Tool definition for read_emails */ export declare const readEmailsTool: MCPTool; export default readEmailsTool; //# sourceMappingURL=read_emails.d.ts.map