richard-hajek/macbird
If you are the rightful owner of macbird and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
This server provides direct access to all of your configured Thunderbird accounts. Only use it with trusted AI assistants.
[!WARNING] This server provides direct access to all of your configured Thunderbird accounts. Only use it with trusted AI assistants.
Thunderbird MCP Server
A Model Context Protocol (MCP) server that provides AI assistants with access to Thunderbird email functionality through a WebSocket connection to a Thunderbird extension.
Architecture
This project combines three components:
- MCP Server - Runs on stdio and provides MCP tools to AI assistants
- WebSocket Server - Connects to the Thunderbird extension on
ws://localhost:37842/ws - Thunderbird Extension - WebExtension that interfaces with Thunderbird APIs
AI Assistant (Claude, etc.)
↕ stdio (MCP protocol)
MCP Server (server.ts)
↕ WebSocket (localhost:37842)
Thunderbird Extension
↕ Thunderbird WebExtension APIs
Thunderbird Email Client
Quick Start
This software is not yet on any package repository, please download it and use manualy.
1. Install Server Dependencies
git clone https://github.com/richard-hajek/macbird.git
cd macbird
cd server
bun install
2. Load the Thunderbird Extension
- Open Thunderbird
- Go to Tools → Developer Tools → Debug Add-ons
- Click "Load Temporary Add-on"
- Navigate to
addon/directory and selectmanifest.json
The extension will automatically connect to the MCP server.
3. Configure MCP Client
Add to your MCP client configuration:
Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"thunderbird": {
"command": "bun",
"args": ["run", "/absolute/path/to/thunderbird-mcp/server/server.ts"]
}
}
}
Other MCP clients:
bun run /path/to/server/server.ts
4. Start Using!
Once configured, your AI assistant can access your email through the following tools.
Available Tools
list_accounts
List all email accounts configured in Thunderbird.
list_accounts()
// Returns: { accounts: [...], count: N }
list_folders
List all folders for a specific account or all accounts.
Parameters:
accountId(optional): Filter by account ID
list_folders()
list_folders({ accountId: "account1" })
list_unread_emails
List all unread emails from all accounts or a specific folder.
Parameters:
accountId(optional): Filter by account IDfolderId(optional): Filter by folder IDlimit(optional): Maximum number of emails (default: 50)includeSpam(optional): Include spam/junk/newsletter folders (default: false)afterDate(optional): Only emails after this date (ISO 8601 format)
list_unread_emails()
list_unread_emails({ accountId: "account1", limit: 20 })
list_unread_emails({ afterDate: "2024-01-01T00:00:00Z" })
search_emails
Search for emails using various criteria.
Parameters:
query(optional): Search query for subject/body/from/tofrom(optional): Filter by senderto(optional): Filter by recipientsubject(optional): Filter by subjectunread(optional): Filter by unread statusflagged(optional): Filter by flagged statuslimit(optional): Maximum results (default: 50)
search_emails({ from: "john@example.com" })
search_emails({ query: "invoice", unread: true })
read_email_raw
Read the raw full content of a specific email with all headers and original format.
Parameters:
messageId(required): The message ID to readmarkAsRead(optional): Mark as read (default: false)
read_email_raw({ messageId: 12345, markAsRead: true })
read_email
Read a specific email with important headers and body converted to markdown.
Parameters:
messageId(required): The message ID to readmarkAsRead(optional): Mark as read (default: false)
read_email({ messageId: 12345, markAsRead: true })
// Returns clean markdown-formatted email body
send_email
Send a new email.
Parameters:
to(required): Array of recipient email addressessubject(required): Email subjectbody(required): Email bodycc(optional): Array of CC addressesbcc(optional): Array of BCC addressesisHtml(optional): Whether body is HTML (default: false)accountId(optional): Account to send from
send_email({
to: ["recipient@example.com"],
subject: "Hello from MCP",
body: "This email was sent via the Thunderbird MCP server!",
cc: ["cc@example.com"]
})
read_email_attachments
Download all attachments from a specific email to a folder.
Parameters:
messageId(required): Message ID containing the attachmentsdownloadPath(required): Local path where files should be saved
read_email_attachments({
messageId: 12345,
downloadPath: "/home/user/Downloads"
})
download_attachment
Download a single specific attachment.
Parameters:
messageId(required): Message ID containing the attachmentpartName(required): Attachment part name/identifierdownloadPath(required): Local path where file should be saved
download_attachment({
messageId: 12345,
partName: "1.2",
downloadPath: "/home/user/Downloads/document.pdf"
})
Usage Example
Once configured, you can use these tools through your AI assistant:
You: "Can you check my unread emails?"
AI: *uses list_unread_emails tool*
AI: "You have 5 unread emails. The most recent is from..."
You: "Search for emails from john@example.com about the project"
AI: *uses search_emails tool*
AI: "I found 3 emails from john@example.com..."
You: "Read that email and convert it to markdown"
AI: *uses read_email tool*
AI: "Here's the email in markdown format: ..."
You: "Send a reply"
AI: *uses send_email tool*
AI: "I've sent the reply."
Development
Project Structure
thunderbird-mcp/
├── addon/ # Thunderbird WebExtension
│ ├── background.js # Main extension logic (182 lines)
│ ├── background_handlers.js # Command handlers (388 lines)
│ └── manifest.json # Extension manifest
├── server/ # MCP Server
│ └── server.ts # Combined MCP + WebSocket server
├── DEVELOPMENT.md # Development guide
└── README.md # This file
Development Scripts
Server:
cd server
bun run lint # Check for linting errors
bun run lint:fix # Auto-fix linting errors
bun run typecheck # Type-check TypeScript
bun run dev # Run server
Addon:
cd addon
bun install # Install dev dependencies
bun run lint # Check for linting errors
bun run lint:fix # Auto-fix linting errors
Running the Server Directly
cd server
bun run server.ts
This starts both:
- MCP server on stdio
- WebSocket server on
ws://localhost:37842/ws
Checking Connection Status
Visit http://localhost:37842/status to see the connected Thunderbird client.
Debugging
The server logs to stderr (visible in MCP client logs). The addon logs to the Thunderbird console (Ctrl+Shift+J).
Features
- ✅ HTML to Markdown conversion - Emails are converted to clean markdown using Turndown
- ✅ Single client model - New connections kick away old ones for simplicity
- ✅ Auto-reconnect - Extension automatically reconnects every 5 seconds if disconnected
- ✅ Spam filtering - Automatically excludes spam/junk/newsletter folders by default
- ✅ Date filtering - Filter emails by date
- ✅ Type-safe - Server written in TypeScript with strict type checking
- ✅ Linted - Both server and addon have ESLint configured
- ✅ Modular handlers - Clean separation of command handling logic
Troubleshooting
"No Thunderbird client connected"
- Ensure the Thunderbird extension is loaded
- Check that Thunderbird is running
- Look for connection messages in the Thunderbird console (Ctrl+Shift+J)
WebSocket Connection Failed
- The extension will auto-reconnect every 5 seconds
- Check that port 37842 is not in use:
lsof -i :37842 - Look for CSP (Content Security Policy) errors in Thunderbird console
MCP Tools Not Working
- Ensure the server is started by the MCP client (check logs)
- Verify the command path in your MCP client configuration is correct
- Check that
bunis installed and in your PATH
Search Timing Out
- The search has a 25-second timeout in the extension
- Try being more specific with your search query
- Use
list_unread_emailsinstead for simpler queries
Port Configuration
The server uses port 37842 to avoid conflicts with common development ports (3000, 8080, etc.). You can change this in:
server/server.ts- Line 43addon/background.js- Line 7addon/manifest.json- Line 83
License
MIT