UNPKG

gmail-mcp-server

Version:

Gmail MCP Server with on-demand authentication for SIYA/Claude Desktop. Complete Gmail integration with multi-user support and OAuth2 security.

205 lines 5.23 kB
import { EnhancedSearchQuery, SearchResult, CrossReferenceInfo } from './enhanced-search.js'; export interface EmailAttachment { filename: string; content: Buffer | string; contentType?: string; encoding?: string; } export interface EmailMessage { to: string[]; cc?: string[]; bcc?: string[]; subject: string; text?: string; html?: string; attachments?: EmailAttachment[]; replyTo?: string; } export interface SearchCriteria { query?: string; from?: string; to?: string; subject?: string; after?: string; before?: string; hasAttachment?: boolean; label?: string; isUnread?: boolean; maxResults?: number; useEnhancedSearch?: boolean; fuzzyThreshold?: number; includeCrossReferences?: boolean; } export interface EmailInfo { id: string; threadId: string; snippet: string; payload: any; labelIds: string[]; internalDate: string; historyId: string; sizeEstimate: number; } export interface DraftInfo { id: string; message: EmailInfo; } /** * Gmail operations manager class */ export declare class GmailOperations { private gmail; private enhancedSearchManager; private resilienceManager; private performanceManager; constructor(); /** * Reset cached Gmail client (called when authentication changes) */ resetClient(): void; /** * Get system status including resilience metrics */ getSystemStatus(): { features: Record<string, "enabled" | "disabled" | "error">; circuitBreakers: Record<string, { state: string; failureCount: number; successCount: number; }>; rateLimiting: { active: boolean; }; }; /** * Get performance metrics */ getPerformanceMetrics(): import("./performance-optimization.js").PerformanceMetrics; /** * Get authenticated Gmail client */ private getGmailClient; /** * Encode string to base64url */ private encodeBase64Url; /** * Decode base64url string */ private decodeBase64Url; /** * Create email message in RFC 2822 format */ private createRawMessage; /** * Send an email with resilience */ sendEmail(message: EmailMessage): Promise<{ id: string; threadId: string; }>; /** * Get email by ID with caching and batch optimization */ getEmail(messageId: string, format?: 'minimal' | 'full' | 'raw' | 'metadata'): Promise<EmailInfo>; /** * Get email attachment */ getAttachment(messageId: string, attachmentId: string): Promise<{ data: string; size: number; }>; /** * Enhanced search emails with natural language processing, fuzzy matching, resilience, and caching */ searchEmails(criteria?: SearchCriteria): Promise<{ messages: EmailInfo[]; nextPageToken?: string; enhancedResults?: { structuredQuery: EnhancedSearchQuery; searchResults: SearchResult[]; crossReferences: CrossReferenceInfo[]; }; }>; /** * Perform enhanced search with natural language processing */ private performEnhancedSearch; /** * Perform traditional Gmail search */ private performTraditionalSearch; /** * Build base query for enhanced search to get a broader set of emails */ private buildBaseQuery; /** * Detect if a query looks like natural language */ private isNaturalLanguageQuery; /** * Mark email as read/unread */ markEmail(messageId: string, read: boolean): Promise<void>; /** * Move email to label/folder */ moveToLabel(messageId: string, labelId: string, removeLabelIds?: string[]): Promise<void>; /** * Delete email */ deleteEmail(messageId: string): Promise<void>; /** * Create a draft email */ createDraft(message: EmailMessage): Promise<{ id: string; message: EmailInfo; }>; /** * List draft emails */ listDrafts(maxResults?: number): Promise<{ drafts: DraftInfo[]; nextPageToken?: string; }>; /** * Get draft by ID */ getDraft(draftId: string): Promise<DraftInfo>; /** * Update draft email */ updateDraft(draftId: string, message: EmailMessage): Promise<{ id: string; message: EmailInfo; }>; /** * Delete draft email */ deleteDraft(draftId: string): Promise<void>; /** * Send draft email */ sendDraft(draftId: string): Promise<{ id: string; threadId: string; }>; /** * List emails in inbox, sent, or custom label */ listEmails(labelId?: string, maxResults?: number): Promise<{ messages: EmailInfo[]; nextPageToken?: string; }>; /** * Extract email content from payload */ extractEmailContent(payload: any): { text?: string; html?: string; attachments: any[]; }; } export declare const gmailOperations: GmailOperations; //# sourceMappingURL=gmail-operations.d.ts.map