A JavaScript MCP server that integrates with the Gmail API, allowing AI agents to search, read, send, and manage emails.
| Feature | Status |
|---|---|
| Search emails | ✅ |
| Read email content | ✅ |
| Send emails (text/HTML) | ✅ |
| List labels | ✅ |
| Modify labels | ✅ |
| Delete emails | ✅ |
| Attachments (send) | ❌ |
| Attachments (download) | ❌ |
Search emails using Gmail's query syntax.
Input:
{
"query": "from:notifications@github.com after:2024/01/01",
"maxResults": 10
}Output:
ID: 18abc123def
Subject: [repo] New pull request
From: GitHub <notifications@github.com>
Date: Mon, 15 Jan 2024 10:30:00 -0800
ID: 18abc456ghi
Subject: [repo] Issue closed
...
Read the full content of an email by ID.
Input:
{
"messageId": "18abc123def"
}Send a new email.
Input:
{
"to": ["recipient@example.com"],
"subject": "Hello from Harbor",
"body": "This email was sent via Harbor's Gmail MCP server.",
"htmlBody": "<p>This email was sent via <b>Harbor</b>.</p>",
"cc": ["cc@example.com"],
"bcc": ["bcc@example.com"]
}List all Gmail labels (system and user-created).
Input:
{}Add or remove labels from an email.
Input:
{
"messageId": "18abc123def",
"addLabelIds": ["STARRED"],
"removeLabelIds": ["UNREAD"]
}Permanently delete an email.
Input:
{
"messageId": "18abc123def"
}- Open Harbor sidebar
- Go to MCP Servers → Add Server
- Enter the manifest URL or upload
manifest.json - Complete the Google OAuth authorization
- Copy
manifest.jsonandgmail-harbor.jsto your server - Add the server in Harbor settings
- Configure OAuth credentials
This server requires Google OAuth with the following scopes:
gmail.readonly- Read emailsgmail.send- Send emailsgmail.modify- Modify labels
Harbor handles the OAuth flow automatically. When you first use the server, you'll be prompted to authorize Gmail access.
The search_emails tool uses Gmail's native query syntax:
| Query | Description |
|---|---|
from:example@gmail.com |
Emails from a specific sender |
to:me |
Emails sent to you |
subject:meeting |
Emails with "meeting" in subject |
has:attachment |
Emails with attachments |
after:2024/01/01 |
Emails after a date |
before:2024/12/31 |
Emails before a date |
is:unread |
Unread emails |
label:important |
Emails with a label |
in:inbox |
Emails in inbox |
Combine queries: from:boss@company.com subject:urgent after:2024/01/01
- Runs in Harbor's sandboxed JavaScript runtime
- Only
gmail.googleapis.comnetwork access is allowed - No filesystem access
- OAuth tokens are managed securely by Harbor
- Never stores credentials in the server code
{
"capabilities": {
"network": {
"required": true,
"hosts": ["gmail.googleapis.com"]
}
},
"oauth": {
"provider": "google",
"scopes": [
"https://www.googleapis.com/auth/gmail.readonly",
"https://www.googleapis.com/auth/gmail.send",
"https://www.googleapis.com/auth/gmail.modify"
]
}
}- No attachments - The sandbox doesn't have filesystem access
- No batch operations - Simplified implementation
- Token refresh - Harbor must handle token refresh
This is a simplified, browser-compatible version based on Gmail-MCP-Server.
Key differences from the original:
- Uses
fetch()instead ofgoogleapisSDK - Uses
MCP.readLine/writeLineinstead of@modelcontextprotocol/sdk - No Node.js dependencies
- OAuth handled externally by Harbor
manifest.json- Server configurationgmail-harbor.js- Server implementationREADME.md- This documentation
MIT