types.d.ts 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. /**
  2. * Type Definitions for Apple Mail MCP Server
  3. *
  4. * This module contains all TypeScript interfaces and types used throughout
  5. * the Apple Mail MCP server. These types model:
  6. *
  7. * - Apple Mail data structures (messages, mailboxes, accounts)
  8. * - AppleScript execution results
  9. * - MCP tool parameters
  10. *
  11. * @module types
  12. */
  13. /**
  14. * Represents an email message in Apple Mail.
  15. */
  16. export interface Message {
  17. /** Unique identifier for the message */
  18. id: string;
  19. /** Subject line of the email */
  20. subject: string;
  21. /** Sender email address */
  22. sender: string;
  23. /** Sender display name (if available) */
  24. senderName?: string;
  25. /** Recipients (To field) */
  26. recipients: string[];
  27. /** CC recipients */
  28. ccRecipients?: string[];
  29. /** BCC recipients (only available for sent mail) */
  30. bccRecipients?: string[];
  31. /** Date the message was received */
  32. dateReceived: Date;
  33. /** Date the message was sent */
  34. dateSent?: Date;
  35. /** Whether the message has been read */
  36. isRead: boolean;
  37. /** Whether the message is flagged */
  38. isFlagged: boolean;
  39. /** Whether the message is marked as junk */
  40. isJunk: boolean;
  41. /** Whether the message has been deleted */
  42. isDeleted: boolean;
  43. /** Name of the mailbox containing the message */
  44. mailbox: string;
  45. /** Name of the account containing the message */
  46. account: string;
  47. /** Whether the message has attachments */
  48. hasAttachments: boolean;
  49. }
  50. /**
  51. * Represents the content of an email message.
  52. */
  53. export interface MessageContent {
  54. /** Message identifier */
  55. id: string;
  56. /** Subject line */
  57. subject: string;
  58. /** Plain text content */
  59. plainText: string;
  60. /** HTML content (if available) */
  61. htmlContent?: string;
  62. }
  63. /**
  64. * Represents a mailbox (folder) in Apple Mail.
  65. */
  66. export interface Mailbox {
  67. /** Display name of the mailbox */
  68. name: string;
  69. /** Account containing the mailbox */
  70. account: string;
  71. /** Number of unread messages */
  72. unreadCount: number;
  73. /** Total number of messages */
  74. messageCount: number;
  75. }
  76. /**
  77. * Represents an email account in Apple Mail.
  78. */
  79. export interface Account {
  80. /** Display name of the account */
  81. name: string;
  82. /** Primary email address for the account */
  83. email: string;
  84. /** Account type (e.g., "iCloud", "Gmail", "Exchange") */
  85. accountType?: string;
  86. /** Whether the account is enabled */
  87. enabled: boolean;
  88. }
  89. /**
  90. * Represents an email attachment.
  91. */
  92. export interface Attachment {
  93. /** Attachment identifier */
  94. id: string;
  95. /** Filename of the attachment */
  96. name: string;
  97. /** MIME type of the attachment */
  98. mimeType: string;
  99. /** Size in bytes */
  100. size: number;
  101. }
  102. /**
  103. * Options for AppleScript execution.
  104. */
  105. export interface AppleScriptOptions {
  106. /** Maximum execution time in milliseconds */
  107. timeoutMs?: number;
  108. /** Maximum number of retry attempts */
  109. maxRetries?: number;
  110. /** Initial delay between retries in milliseconds */
  111. retryDelayMs?: number;
  112. }
  113. /**
  114. * Result from executing an AppleScript command.
  115. */
  116. export interface AppleScriptResult {
  117. /** Whether the script executed successfully */
  118. success: boolean;
  119. /** Output from the script (stdout) */
  120. output: string;
  121. /** Error message if execution failed */
  122. error?: string;
  123. }
  124. /**
  125. * Parameters for searching messages.
  126. */
  127. export interface SearchMessagesParams {
  128. /** Text to search for (searches subject, sender, content) */
  129. query?: string;
  130. /** Filter by sender email address */
  131. from?: string;
  132. /** Filter by recipient email address */
  133. to?: string;
  134. /** Filter by subject line */
  135. subject?: string;
  136. /** Mailbox to search in */
  137. mailbox?: string;
  138. /** Account to search in */
  139. account?: string;
  140. /** Filter by read status */
  141. isRead?: boolean;
  142. /** Filter by flagged status */
  143. isFlagged?: boolean;
  144. /** Start date for search range */
  145. dateFrom?: Date;
  146. /** End date for search range */
  147. dateTo?: Date;
  148. /** Maximum number of results to return */
  149. limit?: number;
  150. }
  151. /**
  152. * Parameters for sending an email.
  153. */
  154. export interface SendEmailParams {
  155. /** Recipient email addresses (To field) */
  156. to: string[];
  157. /** CC recipients */
  158. cc?: string[];
  159. /** BCC recipients */
  160. bcc?: string[];
  161. /** Email subject line */
  162. subject: string;
  163. /** Email body content */
  164. body: string;
  165. /** Whether the body is HTML formatted */
  166. isHtml?: boolean;
  167. /** Account to send from */
  168. account?: string;
  169. }
  170. /**
  171. * Parameters for getting a message by ID.
  172. */
  173. export interface GetMessageParams {
  174. /** Message identifier */
  175. id: string;
  176. }
  177. /**
  178. * Parameters for listing messages.
  179. */
  180. export interface ListMessagesParams {
  181. /** Mailbox to list messages from */
  182. mailbox?: string;
  183. /** Account to list messages from */
  184. account?: string;
  185. /** Maximum number of messages to return */
  186. limit?: number;
  187. /** Filter to unread messages only */
  188. unreadOnly?: boolean;
  189. }
  190. /**
  191. * Parameters for mailbox operations.
  192. */
  193. export interface MailboxParams {
  194. /** Mailbox name */
  195. name: string;
  196. /** Account containing the mailbox */
  197. account?: string;
  198. }
  199. /**
  200. * Parameters for moving a message.
  201. */
  202. export interface MoveMessageParams {
  203. /** Message identifier */
  204. id: string;
  205. /** Destination mailbox name */
  206. mailbox: string;
  207. /** Account containing the destination mailbox */
  208. account?: string;
  209. }
  210. /**
  211. * A single recipient in a serial email (mail merge) operation.
  212. */
  213. export interface SerialEmailRecipient {
  214. /** Recipient email address */
  215. email: string;
  216. /** Variable values for placeholder replacement (e.g., { Name: "Alice", Company: "Acme" }) */
  217. variables: Record<string, string>;
  218. }
  219. /**
  220. * Result of sending a serial email to a single recipient.
  221. */
  222. export interface SerialEmailResult {
  223. /** Recipient email address */
  224. email: string;
  225. /** Whether the email was sent successfully */
  226. success: boolean;
  227. /** Error message if sending failed */
  228. error?: string;
  229. }
  230. /**
  231. * Individual check result in a health check.
  232. */
  233. export interface HealthCheckItem {
  234. /** Name of the check */
  235. name: string;
  236. /** Whether the check passed */
  237. passed: boolean;
  238. /** Details about the check result */
  239. message: string;
  240. }
  241. /**
  242. * Result of a health check operation.
  243. */
  244. export interface HealthCheckResult {
  245. /** Whether all checks passed */
  246. healthy: boolean;
  247. /** Individual check results */
  248. checks: HealthCheckItem[];
  249. }
  250. /**
  251. * Statistics for a mailbox.
  252. */
  253. export interface MailboxStats {
  254. /** Mailbox name */
  255. name: string;
  256. /** Total message count */
  257. messageCount: number;
  258. /** Unread message count */
  259. unreadCount: number;
  260. }
  261. /**
  262. * Statistics for an account.
  263. */
  264. export interface AccountStats {
  265. /** Account name */
  266. name: string;
  267. /** Total messages in account */
  268. totalMessages: number;
  269. /** Total unread messages */
  270. unreadMessages: number;
  271. /** Number of mailboxes */
  272. mailboxCount: number;
  273. /** Per-mailbox statistics */
  274. mailboxes: MailboxStats[];
  275. }
  276. /**
  277. * Recently received message counts.
  278. */
  279. export interface RecentlyReceivedStats {
  280. /** Messages received in last 24 hours */
  281. last24h: number;
  282. /** Messages received in last 7 days */
  283. last7d: number;
  284. /** Messages received in last 30 days */
  285. last30d: number;
  286. }
  287. /**
  288. * Overall mail statistics.
  289. */
  290. export interface MailStats {
  291. /** Total messages across all accounts */
  292. totalMessages: number;
  293. /** Total unread messages */
  294. totalUnread: number;
  295. /** Per-account statistics */
  296. accounts: AccountStats[];
  297. /** Recently received message counts */
  298. recentlyReceived?: RecentlyReceivedStats;
  299. }
  300. /**
  301. * Result of a batch operation on a single item.
  302. */
  303. export interface BatchOperationResult {
  304. /** Item identifier */
  305. id: string;
  306. /** Whether the operation succeeded */
  307. success: boolean;
  308. /** Error message if operation failed */
  309. error?: string;
  310. }
  311. /**
  312. * Represents a mail rule in Apple Mail.
  313. */
  314. export interface MailRule {
  315. /** Rule name */
  316. name: string;
  317. /** Whether the rule is enabled */
  318. enabled: boolean;
  319. }
  320. /**
  321. * Represents a contact from Contacts.app.
  322. */
  323. export interface Contact {
  324. /** Full name */
  325. name: string;
  326. /** Email addresses */
  327. emails: string[];
  328. /** Phone numbers */
  329. phones: string[];
  330. }
  331. /**
  332. * Represents a stored email template.
  333. */
  334. export interface EmailTemplate {
  335. /** Template identifier */
  336. id: string;
  337. /** Template name */
  338. name: string;
  339. /** Default subject line */
  340. subject: string;
  341. /** Template body */
  342. body: string;
  343. /** Default recipients */
  344. to?: string[];
  345. /** Default CC recipients */
  346. cc?: string[];
  347. }
  348. /**
  349. * Status of Mail.app sync activity.
  350. */
  351. export interface SyncStatus {
  352. /** Whether sync activity was detected */
  353. syncDetected: boolean;
  354. /** Number of items pending upload */
  355. pendingUpload: number;
  356. /** Whether there was recent database activity */
  357. recentActivity: boolean;
  358. /** Seconds since last database change */
  359. secondsSinceLastChange: number;
  360. /** Error message if status check failed */
  361. error?: string;
  362. }
  363. //# sourceMappingURL=types.d.ts.map