Install
Up and running in five minutes.
MailGlass needs Node 22.13+ and one config file. There is no cloud setup and no OAuth application to register.
1. Prerequisites
- Node.js 22.13+ (uses the built-in
node:sqlitefor the local index). - Gmail: 2-Step Verification enabled, an app password created at myaccount.google.com/apppasswords, and IMAP enabled in Gmail settings. How to create one.
- Or any IMAP server: host, port, TLS mode, username and password.
2. Install
terminal
npm install -g mailglass-email-mcp
mailglass --version
Or run the container:
docker
docker run -i --rm \
-v "$PWD/config.json:/cfg/config.json:ro" \
-e MAILGLASS_CONFIG=/cfg/config.json \
anantanandgupta/mailglass-email-mcp
There are no ports: it is an MCP stdio server, so -i is required.
3. Write the config
One JSON file, at ~/.config/mailglass/config.json (or anywhere, via
MAILGLASS_CONFIG). Secrets are references, never literals.
config.json
{
"defaultAccount": "work",
"accounts": [
{
"id": "work",
"provider": "gmail",
"email": "you@gmail.com",
"auth": { "password": { "file": "~/.secrets/gmail_app_password" } }
}
]
}
Save the app password as the only content of that file, then chmod 600 it.
The full schema is in the configuration reference. If you do not have an app password yet, see Create a Gmail app password.
4. Connect your host
opencode, for example:
opencode.jsonc
{
"mcp": {
"servers": {
"mailglass": {
"type": "local",
"command": ["mailglass"],
"environment": {
"MAILGLASS_CONFIG": "/Users/you/.config/mailglass/config.json"
}
}
}
}
}
Only the config path is passed, so no credential ever reaches a process environment.
5. Verify
terminal
mailglass --check
✓ config /Users/you/.config/mailglass/config.json
✓ work (gmail) y***@gmail.com readOnly: true
✓ connect + auth imap.gmail.com:993
✓ folders 16
✓ capabilities X-GM-EXT-1
Exit codes
| Exit | Meaning |
|---|---|
0 | Everything works |
1 | Configuration problem |
2 | Credentials rejected |
3 | Network or proxy problem |
Common issues
- Exit 2: app password revoked, spaces not stripped, IMAP disabled, or a Workspace admin disabled app passwords.
- Exit 3: VPN or proxy blocking IMAP ports. Check
nc -vz imap.gmail.com 993, or setproxy.urlin the config. - Two accounts, one repo? Use separate
idvalues; storage is per account id.