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

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

ExitMeaning
0Everything works
1Configuration problem
2Credentials rejected
3Network 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 set proxy.url in the config.
  • Two accounts, one repo? Use separate id values; storage is per account id.