main
1package main
2
3import (
4 "context"
5 "flag"
6 "fmt"
7 "log"
8
9 "github.com/xlgmokha/mcp/pkg/maildir"
10)
11
12func printHelp() {
13 fmt.Printf(`Maildir MCP Server
14
15DESCRIPTION:
16 A Model Context Protocol server that provides secure email management through Maildir format.
17 Enables comprehensive email analysis, searching, and contact management capabilities.
18
19USAGE:
20 mcp-maildir [directory]
21
22ARGUMENTS:
23 directory Path to the Maildir directory (default: current directory)
24
25OPTIONS:
26 --help Show this help message
27
28EXAMPLE USAGE:
29 # Use current directory
30 mcp-maildir
31
32 # Single mailbox
33 mcp-maildir ~/.local/share/mail
34
35 # Test with MCP protocol
36 echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "maildir_scan_folders", "arguments": {"maildir_path": "~/.local/share/mail"}}}' | mcp-maildir ~/.local/share/mail
37
38MCP CAPABILITIES:
39 - Tools: maildir_scan_folders, maildir_list_messages, maildir_read_message, maildir_search_messages, maildir_get_thread, maildir_analyze_contacts, maildir_get_statistics
40 - Resources: maildir:// URIs for email folder access
41 - Features: Email parsing, search, contact analysis, privacy sanitization
42 - Security: Read-only access with path validation and content filtering
43 - Protocol: JSON-RPC 2.0 over stdio
44
45For detailed documentation, see: cmd/maildir/README.md
46`)
47}
48
49func main() {
50 var help = flag.Bool("help", false, "Show help message")
51 flag.Parse()
52
53 if *help {
54 printHelp()
55 return
56 }
57
58 var directory string
59 if len(flag.Args()) > 0 {
60 directory = flag.Arg(0)
61 } else {
62 directory = "."
63 }
64
65 server := maildir.New([]string{directory})
66
67 ctx := context.Background()
68 if err := server.Run(ctx); err != nil {
69 log.Fatalf("Server error: %v", err)
70 }
71}