@kononenko-e/email-mcp 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +155 -0
- package/README.md +820 -0
- package/dist/cli/account-commands.d.ts +10 -0
- package/dist/cli/account-commands.d.ts.map +1 -0
- package/dist/cli/account-commands.js +703 -0
- package/dist/cli/account-commands.js.map +1 -0
- package/dist/cli/config-commands.d.ts +9 -0
- package/dist/cli/config-commands.d.ts.map +1 -0
- package/dist/cli/config-commands.js +156 -0
- package/dist/cli/config-commands.js.map +1 -0
- package/dist/cli/guard.d.ts +11 -0
- package/dist/cli/guard.d.ts.map +1 -0
- package/dist/cli/guard.js +18 -0
- package/dist/cli/guard.js.map +1 -0
- package/dist/cli/install-commands.d.ts +12 -0
- package/dist/cli/install-commands.d.ts.map +1 -0
- package/dist/cli/install-commands.js +320 -0
- package/dist/cli/install-commands.js.map +1 -0
- package/dist/cli/notify.d.ts +8 -0
- package/dist/cli/notify.d.ts.map +1 -0
- package/dist/cli/notify.js +143 -0
- package/dist/cli/notify.js.map +1 -0
- package/dist/cli/providers.d.ts +13 -0
- package/dist/cli/providers.d.ts.map +1 -0
- package/dist/cli/providers.js +180 -0
- package/dist/cli/providers.js.map +1 -0
- package/dist/cli/scheduler.d.ts +8 -0
- package/dist/cli/scheduler.d.ts.map +1 -0
- package/dist/cli/scheduler.js +268 -0
- package/dist/cli/scheduler.js.map +1 -0
- package/dist/cli/setup.d.ts +12 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +15 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli/test.d.ts +7 -0
- package/dist/cli/test.d.ts.map +1 -0
- package/dist/cli/test.js +67 -0
- package/dist/cli/test.js.map +1 -0
- package/dist/config/loader.d.ts +36 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +372 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/schema.d.ts +351 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +165 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/xdg.d.ts +27 -0
- package/dist/config/xdg.d.ts.map +1 -0
- package/dist/config/xdg.js +30 -0
- package/dist/config/xdg.js.map +1 -0
- package/dist/connections/manager.d.ts +43 -0
- package/dist/connections/manager.d.ts.map +1 -0
- package/dist/connections/manager.js +272 -0
- package/dist/connections/manager.js.map +1 -0
- package/dist/connections/types.d.ts +13 -0
- package/dist/connections/types.d.ts.map +1 -0
- package/dist/connections/types.js +2 -0
- package/dist/connections/types.js.map +1 -0
- package/dist/logging.d.ts +46 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +63 -0
- package/dist/logging.js.map +1 -0
- package/dist/main.d.ts +14 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +381 -0
- package/dist/main.js.map +1 -0
- package/dist/prompts/actions.prompt.d.ts +9 -0
- package/dist/prompts/actions.prompt.d.ts.map +1 -0
- package/dist/prompts/actions.prompt.js +64 -0
- package/dist/prompts/actions.prompt.js.map +1 -0
- package/dist/prompts/calendar.prompt.d.ts +9 -0
- package/dist/prompts/calendar.prompt.d.ts.map +1 -0
- package/dist/prompts/calendar.prompt.js +55 -0
- package/dist/prompts/calendar.prompt.js.map +1 -0
- package/dist/prompts/cleanup.prompt.d.ts +9 -0
- package/dist/prompts/cleanup.prompt.d.ts.map +1 -0
- package/dist/prompts/cleanup.prompt.js +78 -0
- package/dist/prompts/cleanup.prompt.js.map +1 -0
- package/dist/prompts/compose.prompt.d.ts +8 -0
- package/dist/prompts/compose.prompt.d.ts.map +1 -0
- package/dist/prompts/compose.prompt.js +116 -0
- package/dist/prompts/compose.prompt.js.map +1 -0
- package/dist/prompts/register.d.ts +8 -0
- package/dist/prompts/register.d.ts.map +1 -0
- package/dist/prompts/register.js +20 -0
- package/dist/prompts/register.js.map +1 -0
- package/dist/prompts/thread.prompt.d.ts +9 -0
- package/dist/prompts/thread.prompt.d.ts.map +1 -0
- package/dist/prompts/thread.prompt.js +58 -0
- package/dist/prompts/thread.prompt.js.map +1 -0
- package/dist/prompts/triage.prompt.d.ts +9 -0
- package/dist/prompts/triage.prompt.d.ts.map +1 -0
- package/dist/prompts/triage.prompt.js +64 -0
- package/dist/prompts/triage.prompt.js.map +1 -0
- package/dist/resources/accounts.resource.d.ts +9 -0
- package/dist/resources/accounts.resource.d.ts.map +1 -0
- package/dist/resources/accounts.resource.js +26 -0
- package/dist/resources/accounts.resource.js.map +1 -0
- package/dist/resources/mailboxes.resource.d.ts +10 -0
- package/dist/resources/mailboxes.resource.d.ts.map +1 -0
- package/dist/resources/mailboxes.resource.js +33 -0
- package/dist/resources/mailboxes.resource.js.map +1 -0
- package/dist/resources/register.d.ts +12 -0
- package/dist/resources/register.d.ts.map +1 -0
- package/dist/resources/register.js +20 -0
- package/dist/resources/register.js.map +1 -0
- package/dist/resources/scheduled.resource.d.ts +9 -0
- package/dist/resources/scheduled.resource.d.ts.map +1 -0
- package/dist/resources/scheduled.resource.js +31 -0
- package/dist/resources/scheduled.resource.js.map +1 -0
- package/dist/resources/stats.resource.d.ts +10 -0
- package/dist/resources/stats.resource.d.ts.map +1 -0
- package/dist/resources/stats.resource.js +45 -0
- package/dist/resources/stats.resource.js.map +1 -0
- package/dist/resources/templates.resource.d.ts +9 -0
- package/dist/resources/templates.resource.d.ts.map +1 -0
- package/dist/resources/templates.resource.js +34 -0
- package/dist/resources/templates.resource.js.map +1 -0
- package/dist/resources/unread.resource.d.ts +11 -0
- package/dist/resources/unread.resource.d.ts.map +1 -0
- package/dist/resources/unread.resource.js +46 -0
- package/dist/resources/unread.resource.js.map +1 -0
- package/dist/safety/audit.d.ts +17 -0
- package/dist/safety/audit.d.ts.map +1 -0
- package/dist/safety/audit.js +50 -0
- package/dist/safety/audit.js.map +1 -0
- package/dist/safety/rate-limiter.d.ts +22 -0
- package/dist/safety/rate-limiter.d.ts.map +1 -0
- package/dist/safety/rate-limiter.js +52 -0
- package/dist/safety/rate-limiter.js.map +1 -0
- package/dist/safety/validation.d.ts +44 -0
- package/dist/safety/validation.d.ts.map +1 -0
- package/dist/safety/validation.js +113 -0
- package/dist/safety/validation.js.map +1 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +25 -0
- package/dist/server.js.map +1 -0
- package/dist/services/calendar.service.d.ts +22 -0
- package/dist/services/calendar.service.d.ts.map +1 -0
- package/dist/services/calendar.service.js +115 -0
- package/dist/services/calendar.service.js.map +1 -0
- package/dist/services/event-bus.d.ts +28 -0
- package/dist/services/event-bus.d.ts.map +1 -0
- package/dist/services/event-bus.js +16 -0
- package/dist/services/event-bus.js.map +1 -0
- package/dist/services/hooks.service.d.ts +78 -0
- package/dist/services/hooks.service.d.ts.map +1 -0
- package/dist/services/hooks.service.js +497 -0
- package/dist/services/hooks.service.js.map +1 -0
- package/dist/services/imap.service.d.ts +133 -0
- package/dist/services/imap.service.d.ts.map +1 -0
- package/dist/services/imap.service.js +1393 -0
- package/dist/services/imap.service.js.map +1 -0
- package/dist/services/label-strategy.d.ts +20 -0
- package/dist/services/label-strategy.d.ts.map +1 -0
- package/dist/services/label-strategy.js +237 -0
- package/dist/services/label-strategy.js.map +1 -0
- package/dist/services/local-calendar.service.d.ts +126 -0
- package/dist/services/local-calendar.service.d.ts.map +1 -0
- package/dist/services/local-calendar.service.js +428 -0
- package/dist/services/local-calendar.service.js.map +1 -0
- package/dist/services/notifier.service.d.ts +66 -0
- package/dist/services/notifier.service.d.ts.map +1 -0
- package/dist/services/notifier.service.js +316 -0
- package/dist/services/notifier.service.js.map +1 -0
- package/dist/services/oauth.service.d.ts +47 -0
- package/dist/services/oauth.service.d.ts.map +1 -0
- package/dist/services/oauth.service.js +140 -0
- package/dist/services/oauth.service.js.map +1 -0
- package/dist/services/presets.d.ts +36 -0
- package/dist/services/presets.d.ts.map +1 -0
- package/dist/services/presets.js +173 -0
- package/dist/services/presets.js.map +1 -0
- package/dist/services/reminders.service.d.ts +63 -0
- package/dist/services/reminders.service.d.ts.map +1 -0
- package/dist/services/reminders.service.js +281 -0
- package/dist/services/reminders.service.js.map +1 -0
- package/dist/services/scheduler.service.d.ts +42 -0
- package/dist/services/scheduler.service.d.ts.map +1 -0
- package/dist/services/scheduler.service.js +260 -0
- package/dist/services/scheduler.service.js.map +1 -0
- package/dist/services/smtp.service.d.ts +40 -0
- package/dist/services/smtp.service.d.ts.map +1 -0
- package/dist/services/smtp.service.js +151 -0
- package/dist/services/smtp.service.js.map +1 -0
- package/dist/services/template.service.d.ts +33 -0
- package/dist/services/template.service.d.ts.map +1 -0
- package/dist/services/template.service.js +123 -0
- package/dist/services/template.service.js.map +1 -0
- package/dist/services/watcher.service.d.ts +37 -0
- package/dist/services/watcher.service.d.ts.map +1 -0
- package/dist/services/watcher.service.js +244 -0
- package/dist/services/watcher.service.js.map +1 -0
- package/dist/tools/account-config.tool.d.ts +14 -0
- package/dist/tools/account-config.tool.d.ts.map +1 -0
- package/dist/tools/account-config.tool.js +245 -0
- package/dist/tools/account-config.tool.js.map +1 -0
- package/dist/tools/accounts.tool.d.ts +7 -0
- package/dist/tools/accounts.tool.d.ts.map +1 -0
- package/dist/tools/accounts.tool.js +29 -0
- package/dist/tools/accounts.tool.js.map +1 -0
- package/dist/tools/analytics.tool.d.ts +9 -0
- package/dist/tools/analytics.tool.d.ts.map +1 -0
- package/dist/tools/analytics.tool.js +27 -0
- package/dist/tools/analytics.tool.js.map +1 -0
- package/dist/tools/attachments.tool.d.ts +7 -0
- package/dist/tools/attachments.tool.d.ts.map +1 -0
- package/dist/tools/attachments.tool.js +45 -0
- package/dist/tools/attachments.tool.js.map +1 -0
- package/dist/tools/bulk.tool.d.ts +7 -0
- package/dist/tools/bulk.tool.d.ts.map +1 -0
- package/dist/tools/bulk.tool.js +75 -0
- package/dist/tools/bulk.tool.js.map +1 -0
- package/dist/tools/calendar.tool.d.ts +19 -0
- package/dist/tools/calendar.tool.d.ts.map +1 -0
- package/dist/tools/calendar.tool.js +538 -0
- package/dist/tools/calendar.tool.js.map +1 -0
- package/dist/tools/contacts.tool.d.ts +7 -0
- package/dist/tools/contacts.tool.d.ts.map +1 -0
- package/dist/tools/contacts.tool.js +44 -0
- package/dist/tools/contacts.tool.js.map +1 -0
- package/dist/tools/drafts.tool.d.ts +8 -0
- package/dist/tools/drafts.tool.d.ts.map +1 -0
- package/dist/tools/drafts.tool.js +92 -0
- package/dist/tools/drafts.tool.js.map +1 -0
- package/dist/tools/emails.tool.d.ts +7 -0
- package/dist/tools/emails.tool.d.ts.map +1 -0
- package/dist/tools/emails.tool.js +400 -0
- package/dist/tools/emails.tool.js.map +1 -0
- package/dist/tools/folders.tool.d.ts +7 -0
- package/dist/tools/folders.tool.d.ts.map +1 -0
- package/dist/tools/folders.tool.js +111 -0
- package/dist/tools/folders.tool.js.map +1 -0
- package/dist/tools/health.tool.d.ts +10 -0
- package/dist/tools/health.tool.d.ts.map +1 -0
- package/dist/tools/health.tool.js +78 -0
- package/dist/tools/health.tool.js.map +1 -0
- package/dist/tools/label.tool.d.ts +11 -0
- package/dist/tools/label.tool.d.ts.map +1 -0
- package/dist/tools/label.tool.js +165 -0
- package/dist/tools/label.tool.js.map +1 -0
- package/dist/tools/locate.tool.d.ts +11 -0
- package/dist/tools/locate.tool.d.ts.map +1 -0
- package/dist/tools/locate.tool.js +59 -0
- package/dist/tools/locate.tool.js.map +1 -0
- package/dist/tools/mailboxes.tool.d.ts +7 -0
- package/dist/tools/mailboxes.tool.d.ts.map +1 -0
- package/dist/tools/mailboxes.tool.js +38 -0
- package/dist/tools/mailboxes.tool.js.map +1 -0
- package/dist/tools/manage.tool.d.ts +7 -0
- package/dist/tools/manage.tool.d.ts.map +1 -0
- package/dist/tools/manage.tool.js +125 -0
- package/dist/tools/manage.tool.js.map +1 -0
- package/dist/tools/register.d.ts +21 -0
- package/dist/tools/register.d.ts.map +1 -0
- package/dist/tools/register.js +55 -0
- package/dist/tools/register.js.map +1 -0
- package/dist/tools/scheduler.tool.d.ts +9 -0
- package/dist/tools/scheduler.tool.d.ts.map +1 -0
- package/dist/tools/scheduler.tool.js +104 -0
- package/dist/tools/scheduler.tool.js.map +1 -0
- package/dist/tools/send.tool.d.ts +7 -0
- package/dist/tools/send.tool.d.ts.map +1 -0
- package/dist/tools/send.tool.js +123 -0
- package/dist/tools/send.tool.js.map +1 -0
- package/dist/tools/templates.tool.d.ts +12 -0
- package/dist/tools/templates.tool.d.ts.map +1 -0
- package/dist/tools/templates.tool.js +140 -0
- package/dist/tools/templates.tool.js.map +1 -0
- package/dist/tools/thread.tool.d.ts +10 -0
- package/dist/tools/thread.tool.d.ts.map +1 -0
- package/dist/tools/thread.tool.js +146 -0
- package/dist/tools/thread.tool.js.map +1 -0
- package/dist/tools/watcher.tool.d.ts +9 -0
- package/dist/tools/watcher.tool.d.ts.map +1 -0
- package/dist/tools/watcher.tool.js +282 -0
- package/dist/tools/watcher.tool.js.map +1 -0
- package/dist/types/index.d.ts +271 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/calendar-notes.d.ts +31 -0
- package/dist/utils/calendar-notes.d.ts.map +1 -0
- package/dist/utils/calendar-notes.js +99 -0
- package/dist/utils/calendar-notes.js.map +1 -0
- package/dist/utils/calendar-state.d.ts +27 -0
- package/dist/utils/calendar-state.d.ts.map +1 -0
- package/dist/utils/calendar-state.js +85 -0
- package/dist/utils/calendar-state.js.map +1 -0
- package/dist/utils/conference-details.d.ts +12 -0
- package/dist/utils/conference-details.d.ts.map +1 -0
- package/dist/utils/conference-details.js +71 -0
- package/dist/utils/conference-details.js.map +1 -0
- package/dist/utils/meeting-url.d.ts +10 -0
- package/dist/utils/meeting-url.d.ts.map +1 -0
- package/dist/utils/meeting-url.js +30 -0
- package/dist/utils/meeting-url.js.map +1 -0
- package/package.json +103 -0
package/dist/main.js
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Email MCP Server โ Main entry point.
|
|
4
|
+
*
|
|
5
|
+
* Subcommands:
|
|
6
|
+
* stdio Run as MCP server over stdio (default)
|
|
7
|
+
* http Run as MCP server over Streamable HTTP (port 8080 by default)
|
|
8
|
+
* setup Interactive account setup wizard
|
|
9
|
+
* test Test IMAP/SMTP connections
|
|
10
|
+
* config Config management (show, path, init)
|
|
11
|
+
* scheduler Email scheduling management
|
|
12
|
+
*/
|
|
13
|
+
import { randomUUID } from 'node:crypto';
|
|
14
|
+
import { createServer as createHttpServer } from 'node:http';
|
|
15
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
16
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
17
|
+
import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
18
|
+
import { loadConfig } from './config/loader.js';
|
|
19
|
+
import ConnectionManager from './connections/manager.js';
|
|
20
|
+
import { bindServer, markInitialized, mcpLog } from './logging.js';
|
|
21
|
+
import registerAllPrompts from './prompts/register.js';
|
|
22
|
+
import registerAllResources from './resources/register.js';
|
|
23
|
+
import RateLimiter from './safety/rate-limiter.js';
|
|
24
|
+
import createServer, { PKG_VERSION } from './server.js';
|
|
25
|
+
import CalendarService from './services/calendar.service.js';
|
|
26
|
+
import HooksService from './services/hooks.service.js';
|
|
27
|
+
import ImapService from './services/imap.service.js';
|
|
28
|
+
import LocalCalendarService from './services/local-calendar.service.js';
|
|
29
|
+
import OAuthService from './services/oauth.service.js';
|
|
30
|
+
import RemindersService from './services/reminders.service.js';
|
|
31
|
+
import SchedulerService from './services/scheduler.service.js';
|
|
32
|
+
import SmtpService from './services/smtp.service.js';
|
|
33
|
+
import TemplateService from './services/template.service.js';
|
|
34
|
+
import WatcherService from './services/watcher.service.js';
|
|
35
|
+
import registerAllTools from './tools/register.js';
|
|
36
|
+
const HELP = `
|
|
37
|
+
email-mcp โ Email MCP Server (IMAP + SMTP)
|
|
38
|
+
|
|
39
|
+
Usage:
|
|
40
|
+
email-mcp [command]
|
|
41
|
+
|
|
42
|
+
Commands:
|
|
43
|
+
stdio Run as MCP server over stdio (default)
|
|
44
|
+
http [port] Run as MCP server over Streamable HTTP (default port: 8080)
|
|
45
|
+
account Account management (list, add, edit, delete)
|
|
46
|
+
setup Alias for 'account add'
|
|
47
|
+
test Test connections for all or a specific account
|
|
48
|
+
install Register/unregister with MCP clients (Claude, Cursor, โฆ)
|
|
49
|
+
config Config management (show, edit, path, init)
|
|
50
|
+
scheduler Email scheduling management (check, list, install, uninstall, status)
|
|
51
|
+
notify Test and diagnose desktop notifications
|
|
52
|
+
help Show this help message
|
|
53
|
+
|
|
54
|
+
Examples:
|
|
55
|
+
email-mcp # Start MCP server (stdio)
|
|
56
|
+
email-mcp http # Start HTTP server on port 8080
|
|
57
|
+
email-mcp http 9090 # Start HTTP server on port 9090
|
|
58
|
+
email-mcp account list # List configured accounts
|
|
59
|
+
email-mcp account add # Add a new email account
|
|
60
|
+
email-mcp account edit personal # Edit an account
|
|
61
|
+
email-mcp account delete work # Delete an account
|
|
62
|
+
email-mcp setup # Alias for account add
|
|
63
|
+
email-mcp test # Test all accounts
|
|
64
|
+
email-mcp test personal # Test specific account
|
|
65
|
+
email-mcp install # Register with detected MCP clients
|
|
66
|
+
email-mcp install status # Show client registration status
|
|
67
|
+
email-mcp install remove # Unregister from MCP clients
|
|
68
|
+
email-mcp config show # Show config (passwords masked)
|
|
69
|
+
email-mcp config edit # Edit global settings
|
|
70
|
+
email-mcp config path # Print config file path
|
|
71
|
+
email-mcp config init # Create template config
|
|
72
|
+
email-mcp scheduler check # Send overdue scheduled emails
|
|
73
|
+
email-mcp scheduler install # Install OS periodic check
|
|
74
|
+
email-mcp notify test # Send a test notification
|
|
75
|
+
email-mcp notify status # Check notification platform support
|
|
76
|
+
`.trim();
|
|
77
|
+
async function runServer() {
|
|
78
|
+
const config = await loadConfig();
|
|
79
|
+
const oauthService = new OAuthService();
|
|
80
|
+
const connections = new ConnectionManager(config.accounts, oauthService);
|
|
81
|
+
const rateLimiter = new RateLimiter(config.settings.rateLimit);
|
|
82
|
+
const imapService = new ImapService(connections);
|
|
83
|
+
const smtpService = new SmtpService(connections, rateLimiter, imapService);
|
|
84
|
+
const templateService = new TemplateService();
|
|
85
|
+
const calendarService = new CalendarService();
|
|
86
|
+
const localCalendarService = new LocalCalendarService();
|
|
87
|
+
const remindersService = new RemindersService();
|
|
88
|
+
const schedulerService = new SchedulerService(smtpService, imapService);
|
|
89
|
+
const watcherService = new WatcherService(config.settings.watcher, config.accounts);
|
|
90
|
+
const hooksService = new HooksService(config.settings.hooks, imapService);
|
|
91
|
+
const server = createServer();
|
|
92
|
+
bindServer(server);
|
|
93
|
+
registerAllTools(server, connections, imapService, smtpService, config, templateService, calendarService, localCalendarService, remindersService, schedulerService, watcherService, hooksService, oauthService);
|
|
94
|
+
registerAllResources(server, connections, imapService, templateService, schedulerService);
|
|
95
|
+
registerAllPrompts(server);
|
|
96
|
+
const transport = new StdioServerTransport();
|
|
97
|
+
await server.connect(transport);
|
|
98
|
+
// --- Post-handshake initialization ----------------------------------------
|
|
99
|
+
// Everything below is deferred until the client completes the MCP
|
|
100
|
+
// `initialize` / `initialized` handshake. This prevents notifications
|
|
101
|
+
// from being written to stdout before the client is ready, which would
|
|
102
|
+
// crash clients like Vibe, and ensures `getClientCapabilities()` returns
|
|
103
|
+
// the real capabilities (including `sampling` support).
|
|
104
|
+
// --------------------------------------------------------------------------
|
|
105
|
+
let schedulerInterval;
|
|
106
|
+
const lowLevelServer = server.server;
|
|
107
|
+
lowLevelServer.oninitialized = () => {
|
|
108
|
+
markInitialized();
|
|
109
|
+
// eslint-disable-next-line no-void
|
|
110
|
+
void (async () => {
|
|
111
|
+
try {
|
|
112
|
+
const clientCaps = lowLevelServer.getClientCapabilities?.() ?? {};
|
|
113
|
+
hooksService.start(lowLevelServer, { sampling: clientCaps.sampling != null });
|
|
114
|
+
await watcherService.start();
|
|
115
|
+
await mcpLog('info', 'server', 'Email MCP server started');
|
|
116
|
+
// Check for overdue scheduled emails on startup
|
|
117
|
+
try {
|
|
118
|
+
const result = await schedulerService.checkAndSend();
|
|
119
|
+
if (result.sent > 0) {
|
|
120
|
+
await mcpLog('info', 'scheduler', `Sent ${result.sent} overdue email(s) on startup`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
// Non-fatal: scheduler check failure shouldn't prevent server start
|
|
125
|
+
}
|
|
126
|
+
// Periodic scheduler check every 60 seconds
|
|
127
|
+
schedulerInterval = setInterval(async () => {
|
|
128
|
+
try {
|
|
129
|
+
await schedulerService.checkAndSend();
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
// Silent โ don't spam logs
|
|
133
|
+
}
|
|
134
|
+
}, 60_000);
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
// Log to stderr โ mcpLog may not be safe if init itself errored
|
|
138
|
+
process.stderr.write(`[email-mcp] post-init error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
139
|
+
}
|
|
140
|
+
})();
|
|
141
|
+
};
|
|
142
|
+
// Graceful shutdown
|
|
143
|
+
const shutdown = async () => {
|
|
144
|
+
if (schedulerInterval)
|
|
145
|
+
clearInterval(schedulerInterval);
|
|
146
|
+
hooksService.stop();
|
|
147
|
+
await watcherService.stop();
|
|
148
|
+
await connections.closeAll();
|
|
149
|
+
await server.close();
|
|
150
|
+
};
|
|
151
|
+
process.on('SIGINT', shutdown);
|
|
152
|
+
process.on('SIGTERM', shutdown);
|
|
153
|
+
}
|
|
154
|
+
async function readBody(req) {
|
|
155
|
+
return new Promise((resolve, reject) => {
|
|
156
|
+
const chunks = [];
|
|
157
|
+
req.on('data', (chunk) => chunks.push(chunk));
|
|
158
|
+
req.on('end', () => resolve(Buffer.concat(chunks)));
|
|
159
|
+
req.on('error', reject);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
async function runHttpServer(port) {
|
|
163
|
+
const config = await loadConfig();
|
|
164
|
+
// Shared services โ created once for the process lifetime
|
|
165
|
+
const oauthService = new OAuthService();
|
|
166
|
+
const connections = new ConnectionManager(config.accounts, oauthService);
|
|
167
|
+
const rateLimiter = new RateLimiter(config.settings.rateLimit);
|
|
168
|
+
const imapService = new ImapService(connections);
|
|
169
|
+
const smtpService = new SmtpService(connections, rateLimiter, imapService);
|
|
170
|
+
const templateService = new TemplateService();
|
|
171
|
+
const calendarService = new CalendarService();
|
|
172
|
+
const localCalendarService = new LocalCalendarService();
|
|
173
|
+
const remindersService = new RemindersService();
|
|
174
|
+
const schedulerService = new SchedulerService(smtpService, imapService);
|
|
175
|
+
const watcherService = new WatcherService(config.settings.watcher, config.accounts);
|
|
176
|
+
const hooksService = new HooksService(config.settings.hooks, imapService);
|
|
177
|
+
// Per-session factory: tools share service instances but each MCP session
|
|
178
|
+
// needs its own McpServer because the SDK binds one transport per server.
|
|
179
|
+
function buildMcpSession() {
|
|
180
|
+
const server = createServer();
|
|
181
|
+
bindServer(server);
|
|
182
|
+
registerAllTools(server, connections, imapService, smtpService, config, templateService, calendarService, localCalendarService, remindersService, schedulerService, watcherService, hooksService, oauthService);
|
|
183
|
+
registerAllResources(server, connections, imapService, templateService, schedulerService);
|
|
184
|
+
registerAllPrompts(server);
|
|
185
|
+
return server;
|
|
186
|
+
}
|
|
187
|
+
const transports = new Map();
|
|
188
|
+
const httpServer = createHttpServer(async (req, res) => {
|
|
189
|
+
if (req.url === '/health') {
|
|
190
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
191
|
+
res.end(JSON.stringify({ ok: true, version: PKG_VERSION }));
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (req.url !== '/mcp') {
|
|
195
|
+
res.writeHead(404);
|
|
196
|
+
res.end('Not Found');
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
let body;
|
|
200
|
+
if (req.method === 'POST') {
|
|
201
|
+
const raw = await readBody(req);
|
|
202
|
+
if (raw.length > 0) {
|
|
203
|
+
try {
|
|
204
|
+
body = JSON.parse(raw.toString());
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
208
|
+
res.end(JSON.stringify({
|
|
209
|
+
jsonrpc: '2.0',
|
|
210
|
+
error: { code: -32700, message: 'Parse error' },
|
|
211
|
+
id: null,
|
|
212
|
+
}));
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const sessionIdHeader = req.headers['mcp-session-id'];
|
|
218
|
+
const sessionId = Array.isArray(sessionIdHeader) ? sessionIdHeader[0] : sessionIdHeader;
|
|
219
|
+
let transport;
|
|
220
|
+
const existing = sessionId ? transports.get(sessionId) : undefined;
|
|
221
|
+
if (existing) {
|
|
222
|
+
transport = existing;
|
|
223
|
+
}
|
|
224
|
+
else if (!sessionId && req.method === 'POST' && isInitializeRequest(body)) {
|
|
225
|
+
const newTransport = new StreamableHTTPServerTransport({
|
|
226
|
+
sessionIdGenerator: () => randomUUID(),
|
|
227
|
+
onsessioninitialized: (sid) => {
|
|
228
|
+
transports.set(sid, newTransport);
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
newTransport.onclose = () => {
|
|
232
|
+
const sid = newTransport.sessionId;
|
|
233
|
+
if (sid)
|
|
234
|
+
transports.delete(sid);
|
|
235
|
+
};
|
|
236
|
+
const mcpServer = buildMcpSession();
|
|
237
|
+
await mcpServer.connect(newTransport);
|
|
238
|
+
// Register hooks on the *first* client init for this session so the
|
|
239
|
+
// HTTP path also wires up email:new โ sampling/createMessage. Without
|
|
240
|
+
// this, only stdio mode triggered the hooks (see 36eb8ca on main).
|
|
241
|
+
const ls = mcpServer.server;
|
|
242
|
+
ls.oninitialized = () => {
|
|
243
|
+
markInitialized();
|
|
244
|
+
// eslint-disable-next-line no-void
|
|
245
|
+
void (async () => {
|
|
246
|
+
try {
|
|
247
|
+
const clientCaps = ls.getClientCapabilities?.() ?? {};
|
|
248
|
+
hooksService.start(ls, { sampling: clientCaps.sampling != null });
|
|
249
|
+
await mcpLog('info', 'server', 'Email MCP server ready (HTTP mode)');
|
|
250
|
+
}
|
|
251
|
+
catch (err) {
|
|
252
|
+
process.stderr.write(`[email-mcp] hooks init error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
253
|
+
}
|
|
254
|
+
})();
|
|
255
|
+
};
|
|
256
|
+
transport = newTransport;
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
260
|
+
res.end(JSON.stringify({
|
|
261
|
+
jsonrpc: '2.0',
|
|
262
|
+
error: {
|
|
263
|
+
code: -32000,
|
|
264
|
+
message: 'Bad Request: provide mcp-session-id or send an initialize request',
|
|
265
|
+
},
|
|
266
|
+
id: null,
|
|
267
|
+
}));
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
await transport.handleRequest(req, res, body);
|
|
271
|
+
});
|
|
272
|
+
await watcherService.start();
|
|
273
|
+
const checkInterval = setInterval(async () => {
|
|
274
|
+
try {
|
|
275
|
+
await schedulerService.checkAndSend();
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
// Silent
|
|
279
|
+
}
|
|
280
|
+
}, 60_000);
|
|
281
|
+
try {
|
|
282
|
+
const result = await schedulerService.checkAndSend();
|
|
283
|
+
if (result.sent > 0) {
|
|
284
|
+
process.stderr.write(`[scheduler] Sent ${result.sent} overdue email(s) on startup\n`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
catch {
|
|
288
|
+
// Non-fatal
|
|
289
|
+
}
|
|
290
|
+
await new Promise((resolve, reject) => {
|
|
291
|
+
httpServer.listen(port, () => {
|
|
292
|
+
process.stderr.write(`email-mcp HTTP server listening on :${port}\n`);
|
|
293
|
+
process.stderr.write(` Endpoint : http://0.0.0.0:${port}/mcp\n`);
|
|
294
|
+
process.stderr.write(` Health : http://0.0.0.0:${port}/health\n`);
|
|
295
|
+
resolve();
|
|
296
|
+
});
|
|
297
|
+
httpServer.once('error', reject);
|
|
298
|
+
});
|
|
299
|
+
const shutdown = async () => {
|
|
300
|
+
clearInterval(checkInterval);
|
|
301
|
+
hooksService.stop();
|
|
302
|
+
await watcherService.stop();
|
|
303
|
+
// Close all transports concurrently; errors are ignored individually.
|
|
304
|
+
await Promise.allSettled(Array.from(transports.values(), async (t) => t.close()));
|
|
305
|
+
await connections.closeAll();
|
|
306
|
+
httpServer.close();
|
|
307
|
+
};
|
|
308
|
+
process.on('SIGINT', shutdown);
|
|
309
|
+
process.on('SIGTERM', shutdown);
|
|
310
|
+
}
|
|
311
|
+
async function main() {
|
|
312
|
+
const command = process.argv[2] ?? 'stdio';
|
|
313
|
+
switch (command) {
|
|
314
|
+
case 'stdio':
|
|
315
|
+
await runServer();
|
|
316
|
+
break;
|
|
317
|
+
case 'http': {
|
|
318
|
+
const portArg = process.argv[3];
|
|
319
|
+
const port = portArg !== undefined ? Number.parseInt(portArg, 10) : 8080;
|
|
320
|
+
if (Number.isNaN(port) || port < 1 || port > 65535) {
|
|
321
|
+
console.error(`Invalid port: ${portArg}`);
|
|
322
|
+
throw new Error(`Invalid port: ${portArg}`);
|
|
323
|
+
}
|
|
324
|
+
await runHttpServer(port);
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
case 'setup': {
|
|
328
|
+
const { default: runSetup } = await import('./cli/setup.js');
|
|
329
|
+
await runSetup();
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
case 'account': {
|
|
333
|
+
const { default: runAccountCommand } = await import('./cli/account-commands.js');
|
|
334
|
+
await runAccountCommand(process.argv[3], process.argv[4]);
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
case 'test': {
|
|
338
|
+
const { default: runTest } = await import('./cli/test.js');
|
|
339
|
+
await runTest(process.argv[3]);
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
case 'config': {
|
|
343
|
+
const { default: runConfigCommand } = await import('./cli/config-commands.js');
|
|
344
|
+
await runConfigCommand(process.argv[3]);
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
case 'install': {
|
|
348
|
+
const { default: runInstallCommand } = await import('./cli/install-commands.js');
|
|
349
|
+
await runInstallCommand(process.argv[3]);
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
case 'scheduler': {
|
|
353
|
+
const { default: runSchedulerCommand } = await import('./cli/scheduler.js');
|
|
354
|
+
await runSchedulerCommand(process.argv[3]);
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
case 'notify': {
|
|
358
|
+
const { default: runNotifyCommand } = await import('./cli/notify.js');
|
|
359
|
+
await runNotifyCommand(process.argv[3]);
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
case '--version':
|
|
363
|
+
case '-v':
|
|
364
|
+
console.log(PKG_VERSION);
|
|
365
|
+
break;
|
|
366
|
+
case 'help':
|
|
367
|
+
case '--help':
|
|
368
|
+
case '-h':
|
|
369
|
+
console.log(HELP);
|
|
370
|
+
break;
|
|
371
|
+
default:
|
|
372
|
+
console.error(`Unknown command: ${command}\n`);
|
|
373
|
+
console.log(HELP);
|
|
374
|
+
throw new Error(`Unknown command: ${command}`);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
main().catch((err) => {
|
|
378
|
+
console.error('Fatal error:', err instanceof Error ? err.message : String(err));
|
|
379
|
+
process.exitCode = 1;
|
|
380
|
+
});
|
|
381
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAA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E,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAC;YACtE,MAAM,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACxC,MAAM;QACR,CAAC;QAED,KAAK,WAAW,CAAC;QACjB,KAAK,IAAI;YACP,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YACzB,MAAM;QAER,KAAK,MAAM,CAAC;QACZ,KAAK,QAAQ,CAAC;QACd,KAAK,IAAI;YACP,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAClB,MAAM;QAER;YACE,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,IAAI,CAAC,CAAC;YAC/C,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAChF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Prompt: extract_action_items
|
|
3
|
+
*
|
|
4
|
+
* Instructs the LLM to scan recent emails and extract actionable items
|
|
5
|
+
* including tasks, deadlines, commitments, and pending questions.
|
|
6
|
+
*/
|
|
7
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
8
|
+
export default function registerActionsPrompt(server: McpServer): void;
|
|
9
|
+
//# sourceMappingURL=actions.prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.prompt.d.ts","sourceRoot":"","sources":["../../src/prompts/actions.prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA4DrE"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Prompt: extract_action_items
|
|
3
|
+
*
|
|
4
|
+
* Instructs the LLM to scan recent emails and extract actionable items
|
|
5
|
+
* including tasks, deadlines, commitments, and pending questions.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
export default function registerActionsPrompt(server) {
|
|
9
|
+
server.prompt('extract_action_items', 'Scan recent emails and extract action items, deadlines, and commitments. Produces a structured task list with source references.', {
|
|
10
|
+
account: z.string().describe('Account name'),
|
|
11
|
+
mailbox: z.string().default('INBOX').describe('Mailbox to scan (default: INBOX)'),
|
|
12
|
+
limit: z.string().default('20').describe('Number of recent emails to scan (default: 20)'),
|
|
13
|
+
}, async ({ account, mailbox, limit }) => {
|
|
14
|
+
const limitNum = Math.min(Math.max(parseInt(limit, 10) || 20, 1), 50);
|
|
15
|
+
return {
|
|
16
|
+
messages: [
|
|
17
|
+
{
|
|
18
|
+
role: 'user',
|
|
19
|
+
content: {
|
|
20
|
+
type: 'text',
|
|
21
|
+
text: `Extract action items from recent emails in the "${mailbox}" mailbox of the "${account}" account.
|
|
22
|
+
|
|
23
|
+
Follow these steps:
|
|
24
|
+
1. Call list_emails with account="${account}", mailbox="${mailbox}", pageSize=${limitNum} to get recent emails.
|
|
25
|
+
2. For each email that looks like it might contain action items (based on subject/preview), call get_email to read the full content.
|
|
26
|
+
3. Extract ALL actionable items from the emails.
|
|
27
|
+
|
|
28
|
+
Look for:
|
|
29
|
+
- **Direct requests:** "Please...", "Can you...", "Could you...", "I need..."
|
|
30
|
+
- **Deadlines:** Dates, "by end of week", "ASAP", "before the meeting"
|
|
31
|
+
- **Commitments you made:** "I will...", "I'll send...", "Let me..."
|
|
32
|
+
- **Questions awaiting your response:** Questions directed at you
|
|
33
|
+
- **Meeting follow-ups:** Action items from meetings mentioned in emails
|
|
34
|
+
- **Approvals needed:** Requests for sign-off or review
|
|
35
|
+
|
|
36
|
+
Output a structured report in this format:
|
|
37
|
+
|
|
38
|
+
## โ
Action Items โ ${account}
|
|
39
|
+
**Scanned:** [Count] emails from ${mailbox}
|
|
40
|
+
|
|
41
|
+
### ๐ด Urgent / Has Deadline
|
|
42
|
+
- [ ] [Action description] โ from [Sender] ([Date])
|
|
43
|
+
๐ง Re: [Subject] | โฐ Deadline: [deadline if mentioned]
|
|
44
|
+
|
|
45
|
+
### ๐ก Needs Response
|
|
46
|
+
- [ ] [Reply to / Answer question about...] โ from [Sender] ([Date])
|
|
47
|
+
๐ง Re: [Subject]
|
|
48
|
+
|
|
49
|
+
### ๐ต Tasks / Commitments
|
|
50
|
+
- [ ] [Task description] โ from [Sender] ([Date])
|
|
51
|
+
๐ง Re: [Subject]
|
|
52
|
+
|
|
53
|
+
### ๐ Summary
|
|
54
|
+
- **Total action items:** [count]
|
|
55
|
+
- **With deadlines:** [count]
|
|
56
|
+
- **Awaiting your response:** [count]
|
|
57
|
+
- **Commitments you made:** [count]`,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=actions.prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.prompt.js","sourceRoot":"","sources":["../../src/prompts/actions.prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,MAAiB;IAC7D,MAAM,CAAC,MAAM,CACX,sBAAsB,EACtB,kIAAkI,EAClI;QACE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC;QAC5C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,kCAAkC,CAAC;QACjF,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,+CAA+C,CAAC;KAC1F,EACD,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE;QACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACtE,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,MAAe;oBACrB,OAAO,EAAE;wBACP,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,mDAAmD,OAAO,qBAAqB,OAAO;;;oCAGtE,OAAO,eAAe,OAAO,eAAe,QAAQ;;;;;;;;;;;;;;sBAclE,OAAO;mCACM,OAAO;;;;;;;;;;;;;;;;;;oCAkBN;qBACvB;iBACF;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Prompt: summarize_meetings
|
|
3
|
+
*
|
|
4
|
+
* Instructs the LLM to scan recent emails for calendar invites
|
|
5
|
+
* and produce a structured meeting overview.
|
|
6
|
+
*/
|
|
7
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
8
|
+
export default function registerCalendarPrompt(server: McpServer): void;
|
|
9
|
+
//# sourceMappingURL=calendar.prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.prompt.d.ts","sourceRoot":"","sources":["../../src/prompts/calendar.prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAmDtE"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Prompt: summarize_meetings
|
|
3
|
+
*
|
|
4
|
+
* Instructs the LLM to scan recent emails for calendar invites
|
|
5
|
+
* and produce a structured meeting overview.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
export default function registerCalendarPrompt(server) {
|
|
9
|
+
server.prompt('summarize_meetings', 'Scan recent emails for calendar invites and produce a meeting overview grouped by timeframe.', {
|
|
10
|
+
account: z.string().describe('Account name to scan'),
|
|
11
|
+
days: z.string().default('7').describe('Number of days to look back (default: 7)'),
|
|
12
|
+
}, async ({ account, days }) => {
|
|
13
|
+
const daysNum = Math.min(Math.max(parseInt(days, 10) || 7, 1), 30);
|
|
14
|
+
return {
|
|
15
|
+
messages: [
|
|
16
|
+
{
|
|
17
|
+
role: 'user',
|
|
18
|
+
content: {
|
|
19
|
+
type: 'text',
|
|
20
|
+
text: `Scan the "${account}" account for calendar invitations from the last ${daysNum} days.
|
|
21
|
+
|
|
22
|
+
Follow these steps:
|
|
23
|
+
1. Call search_emails with account="${account}", mailbox="INBOX", since="${new Date(Date.now() - daysNum * 86400000).toISOString().split('T')[0]}" to find recent emails.
|
|
24
|
+
2. For each email that might contain a calendar invite (look for subjects with "Meeting", "Invitation", "Calendar", or from calendar systems), call extract_calendar to check for ICS content.
|
|
25
|
+
3. Collect all calendar events found.
|
|
26
|
+
|
|
27
|
+
Then produce a meeting brief in this format:
|
|
28
|
+
|
|
29
|
+
## ๐
Meeting Brief โ ${account}
|
|
30
|
+
**Period:** Last ${daysNum} days | **Events found:** [count]
|
|
31
|
+
|
|
32
|
+
### ๐ Today
|
|
33
|
+
- **[Time]** [Summary] โ [Location] | ๐ค [Organizer] | [Attendee count] attendees
|
|
34
|
+
Status: [CONFIRMED/TENTATIVE/CANCELLED]
|
|
35
|
+
|
|
36
|
+
### ๐ This Week
|
|
37
|
+
- (same format)
|
|
38
|
+
|
|
39
|
+
### ๐ Next Week
|
|
40
|
+
- (same format)
|
|
41
|
+
|
|
42
|
+
### โ ๏ธ Conflicts
|
|
43
|
+
- [List any overlapping events]
|
|
44
|
+
|
|
45
|
+
### โ Cancelled
|
|
46
|
+
- [List any cancelled events]
|
|
47
|
+
|
|
48
|
+
If no calendar events are found, say "No meeting invitations found in the last ${daysNum} days."`,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=calendar.prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.prompt.js","sourceRoot":"","sources":["../../src/prompts/calendar.prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,MAAiB;IAC9D,MAAM,CAAC,MAAM,CACX,oBAAoB,EACpB,8FAA8F,EAC9F;QACE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC;QACpD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,0CAA0C,CAAC;KACnF,EACD,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;QAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACnE,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,MAAe;oBACrB,OAAO,EAAE;wBACP,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,aAAa,OAAO,oDAAoD,OAAO;;;sCAG7D,OAAO,8BAA8B,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,GAAG,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;;;;;;wBAMxH,OAAO;mBACZ,OAAO;;;;;;;;;;;;;;;;;;iFAkBuD,OAAO,SAAS;qBACpF;iBACF;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Prompt: cleanup_inbox
|
|
3
|
+
*
|
|
4
|
+
* Instructs the LLM to analyze and clean up the inbox with
|
|
5
|
+
* categorization and optional execution.
|
|
6
|
+
*/
|
|
7
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
8
|
+
export default function registerCleanupPrompt(server: McpServer): void;
|
|
9
|
+
//# sourceMappingURL=cleanup.prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanup.prompt.d.ts","sourceRoot":"","sources":["../../src/prompts/cleanup.prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA6ErE"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Prompt: cleanup_inbox
|
|
3
|
+
*
|
|
4
|
+
* Instructs the LLM to analyze and clean up the inbox with
|
|
5
|
+
* categorization and optional execution.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
export default function registerCleanupPrompt(server) {
|
|
9
|
+
server.prompt('cleanup_inbox', 'AI-guided inbox cleanup โ categorizes emails and suggests or executes organization actions.', {
|
|
10
|
+
account: z.string().describe('Account name to clean up'),
|
|
11
|
+
older_than_days: z
|
|
12
|
+
.string()
|
|
13
|
+
.default('30')
|
|
14
|
+
.describe('Only consider emails older than N days (default: 30)'),
|
|
15
|
+
dry_run: z
|
|
16
|
+
.string()
|
|
17
|
+
.default('true')
|
|
18
|
+
.describe("'true' = suggest only, 'false' = execute actions (default: true)"),
|
|
19
|
+
}, async ({ account, older_than_days: olderThan, dry_run: dryRun }) => {
|
|
20
|
+
const days = Math.max(parseInt(olderThan, 10) || 30, 1);
|
|
21
|
+
const execute = dryRun === 'false';
|
|
22
|
+
const beforeDate = new Date(Date.now() - days * 86400000).toISOString().split('T')[0];
|
|
23
|
+
return {
|
|
24
|
+
messages: [
|
|
25
|
+
{
|
|
26
|
+
role: 'user',
|
|
27
|
+
content: {
|
|
28
|
+
type: 'text',
|
|
29
|
+
text: `Help me clean up the "${account}" inbox. Analyze emails older than ${days} days.
|
|
30
|
+
|
|
31
|
+
Follow these steps:
|
|
32
|
+
1. Call list_emails with account="${account}", mailbox="INBOX", pageSize=50, before="${beforeDate}" to scan old emails.
|
|
33
|
+
2. For emails needing more context, use get_email to read the body.
|
|
34
|
+
3. Categorize each email into one of these groups:
|
|
35
|
+
|
|
36
|
+
๐๏ธ **Delete candidates** โ Old read promotional emails, automated notifications, expired offers
|
|
37
|
+
๐ **Archive candidates** โ Old read conversational emails with no pending action
|
|
38
|
+
๐ฉ **Needs attention** โ Unread or flagged emails that may still need a response
|
|
39
|
+
โ
**Keep** โ Recent or important emails that belong in inbox
|
|
40
|
+
|
|
41
|
+
4. Look for newsletter patterns (List-Unsubscribe headers, recurring senders with promotional content).
|
|
42
|
+
|
|
43
|
+
Present your findings as:
|
|
44
|
+
|
|
45
|
+
## ๐งน Inbox Cleanup โ ${account}
|
|
46
|
+
**Scanned:** [count] emails older than ${days} days
|
|
47
|
+
|
|
48
|
+
### ๐๏ธ Delete ([count])
|
|
49
|
+
- [Subject] from [Sender] โ [Reason]
|
|
50
|
+
|
|
51
|
+
### ๐ Archive ([count])
|
|
52
|
+
- [Subject] from [Sender] โ [Reason]
|
|
53
|
+
|
|
54
|
+
### ๐ฉ Needs Attention ([count])
|
|
55
|
+
- [Subject] from [Sender] โ [Why this needs action]
|
|
56
|
+
|
|
57
|
+
### โ
Keep ([count])
|
|
58
|
+
- [Subject] from [Sender] โ [Why to keep]
|
|
59
|
+
|
|
60
|
+
### ๐ฐ Newsletter Sources
|
|
61
|
+
- [Sender] โ [Frequency estimate] โ Consider unsubscribing?
|
|
62
|
+
|
|
63
|
+
### Summary
|
|
64
|
+
- Total scanned: X
|
|
65
|
+
- Suggested deletions: X
|
|
66
|
+
- Suggested archives: X
|
|
67
|
+
- Estimated space savings: X
|
|
68
|
+
|
|
69
|
+
${execute
|
|
70
|
+
? `**Mode: EXECUTE** โ After presenting the plan, proceed to execute the cleanup using bulk_action to move/delete emails as categorized. Report results for each action.`
|
|
71
|
+
: `**Mode: DRY RUN** โ Present the cleanup plan only. Ask if I want to proceed with any of the suggested actions.`}`,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=cleanup.prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanup.prompt.js","sourceRoot":"","sources":["../../src/prompts/cleanup.prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,MAAiB;IAC7D,MAAM,CAAC,MAAM,CACX,eAAe,EACf,6FAA6F,EAC7F;QACE,OAAO,EAAE,CAAC,CAAC,MAAM,E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