|
| 1 | +# Gmail Postmaster Tools MCP |
| 2 | + |
| 3 | +[](LICENSE) |
| 4 | +[](https://github.com/anthropics/mcpb) |
| 5 | +[](https://nodejs.org) |
| 6 | +[](#why-zero-dependencies) |
| 7 | + |
| 8 | +An [MCP](https://modelcontextprotocol.io) server for the **Gmail Postmaster |
| 9 | +Tools API (v2)** — query your domains, sender compliance status, and Gmail |
| 10 | +traffic metrics from Claude, Cursor, or any MCP client. |
| 11 | + |
| 12 | +This is a **bring-your-own-credentials** tool for hands-on senders: you supply |
| 13 | +your own Google OAuth client, and the server runs the sign-in locally. Nothing |
| 14 | +is hosted and no data leaves your machine. |
| 15 | + |
| 16 | +> Want this without setting up a Google Cloud project? That's what |
| 17 | +> **[Postmaster+](https://postmasterplus.com)** is for — hosted, multi-provider |
| 18 | +> (Gmail + Outlook + more), with verification, history, and alerting. |
| 19 | +
|
| 20 | +Built & maintained by the **[Postmaster+](https://postmasterplus.com)** team at **[OptiPub](https://optipub.com)**. |
| 21 | + |
| 22 | +## What you get |
| 23 | + |
| 24 | +- `list_domains` / `get_domain` — your registered domains and their verification state |
| 25 | +- `get_compliance_status` — SPF, DKIM, DMARC, alignment, message formatting, DNS records, TLS encryption, user-reported spam rate, and one-click / honored unsubscribe verdicts |
| 26 | +- `query_domain_stats` — spam rate, auth success (SPF/DKIM/DMARC), TLS encryption rate, delivery errors, and feedback-loop metrics over any date range |
| 27 | +- `gpt_authenticate` / `gpt_auth_status` / `gpt_sign_out` |
| 28 | + |
| 29 | +> Note: Postmaster Tools **v2** covers traffic metrics + compliance. Domain and |
| 30 | +> IP *reputation* are not part of v2. |
| 31 | +
|
| 32 | +## Prerequisites: create a Google OAuth client (one-time, ~5 min) |
| 33 | + |
| 34 | +You need a Google Cloud OAuth client because Google doesn't offer a shared |
| 35 | +public one for this API. |
| 36 | + |
| 37 | +1. Go to the [Google Cloud Console](https://console.cloud.google.com/) and create (or pick) a project. |
| 38 | +2. **APIs & Services → Library** → search **"Gmail Postmaster Tools API"** → **Enable**. |
| 39 | +3. **APIs & Services → OAuth consent screen** (redirects to **Google Auth Platform**). If the project has never been configured, click **Get started** and set an **App name** + support email, **Audience = External**, and a contact email. If it's already configured, you'll just see the tabs — skip to the next step. |
| 40 | +4. Open the **Audience** tab. If **User type = External**, add your Google address under **Test users → + Add users** and **Save** (leave status as **Testing** — works without app verification, up to 100 users). If **User type = Internal** (a Workspace org project), no test users are needed — org users can sign in directly. |
| 41 | +5. Open the **Clients** tab (or **APIs & Services → Credentials**) → **Create client** → application type **Desktop app** → **Create**. |
| 42 | +6. Copy the **Client ID** and **Client secret**. |
| 43 | + |
| 44 | +You'll paste those two values into this extension's configuration at install |
| 45 | +time. (Make sure the Google account you sign in with is one that has access in |
| 46 | +[Gmail Postmaster Tools](https://postmaster.google.com/).) |
| 47 | + |
| 48 | +## Install in Claude / Cowork (the `.mcpb`) |
| 49 | + |
| 50 | +The `.mcpb` is a packaging convenience for Claude Desktop / Cowork only. |
| 51 | + |
| 52 | +1. Download `gmail-postmaster-tools.mcpb` from the [latest release](../../releases/latest). |
| 53 | +2. **Settings → Capabilities → install extension**, pick the file. |
| 54 | +3. When prompted, paste your **Google OAuth Client ID** and **Client Secret**. |
| 55 | +4. Run `gpt_authenticate` once — your browser opens for the Google sign-in. |
| 56 | + |
| 57 | +## Use with other MCP clients (Cursor, VS Code, Windsurf, …) |
| 58 | + |
| 59 | +Underneath, this is a standard **stdio MCP server** — any client that runs local |
| 60 | +MCP servers can use it directly, no `.mcpb` required. Clone or download the repo, |
| 61 | +then point the client at `server/index.js` and pass your Google credentials as |
| 62 | +env vars. |
| 63 | + |
| 64 | +**Cursor** — edit `~/.cursor/mcp.json` (global) or `.cursor/mcp.json` (per project): |
| 65 | + |
| 66 | +```json |
| 67 | +{ |
| 68 | + "mcpServers": { |
| 69 | + "gmail-postmaster-tools": { |
| 70 | + "command": "node", |
| 71 | + "args": ["/absolute/path/to/gmail-postmaster-tools-mcp/server/index.js"], |
| 72 | + "env": { |
| 73 | + "GPT_CLIENT_ID": "xxxxx.apps.googleusercontent.com", |
| 74 | + "GPT_CLIENT_SECRET": "xxxxx" |
| 75 | + } |
| 76 | + } |
| 77 | + } |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +**VS Code** (`.vscode/mcp.json`), **Windsurf**, **Claude Desktop** (manual config), |
| 82 | +and most other clients use the same `command` + `args` + `env` shape — only the |
| 83 | +config file location differs. Other env overrides are listed under |
| 84 | +[Configuration](#configuration-env-overrides). |
| 85 | + |
| 86 | +The first tool call (or `gpt_authenticate`) opens your browser for the Google |
| 87 | +sign-in; the `127.0.0.1` loopback works on any local desktop client. |
| 88 | + |
| 89 | +> **Remote-only clients (e.g. Perplexity, ChatGPT connectors):** these accept |
| 90 | +> only a remote HTTPS MCP server URL, not a local command, so this stdio build |
| 91 | +> can't be added directly. That would require hosting it — which is what |
| 92 | +> [Postmaster+](https://postmasterplus.com) provides. |
| 93 | +
|
| 94 | +## Usage examples |
| 95 | + |
| 96 | +- "Sign me in to Gmail Postmaster Tools" → `gpt_authenticate` |
| 97 | +- "List my Postmaster domains" → `list_domains` |
| 98 | +- "Is example.com compliant with Gmail's sender rules?" → `get_compliance_status { domain: "example.com" }` |
| 99 | +- "Spam rate for example.com over the last 30 days" → `query_domain_stats { domain: "example.com", start_date: "...", end_date: "...", metrics: ["SPAM_RATE"] }` |
| 100 | +- "DKIM auth success for example.com" → `query_domain_stats { domain: "example.com", metrics: [{ "standardMetric": "AUTH_SUCCESS_RATE", "filter": "auth_type=\"dkim\"" }] }` |
| 101 | + |
| 102 | +Some metrics require a filter: `AUTH_SUCCESS_RATE` (`auth_type=spf|dkim|dmarc`), |
| 103 | +`TLS_ENCRYPTION_RATE` (`traffic_direction=inbound|outbound`), |
| 104 | +`DELIVERY_ERROR_RATE` (optional `error_type=...`). `SPAM_RATE` needs none. |
| 105 | + |
| 106 | +## How authentication works |
| 107 | + |
| 108 | +OAuth 2.0 authorization-code + PKCE, over a `http://127.0.0.1:<dynamic-port>` |
| 109 | +loopback redirect (Google's recommended flow for desktop apps). On sign-in the |
| 110 | +server starts a short-lived listener on `127.0.0.1`, opens your browser, receives |
| 111 | +the code, and exchanges it (with your client secret + PKCE verifier) for tokens. |
| 112 | + |
| 113 | +Google requires a client secret even for desktop apps, which is why both values |
| 114 | +are needed. Tokens are stored only on your machine at |
| 115 | +`~/.gmail-postmaster-mcp/tokens.json` (`0600`) and are git-ignored. |
| 116 | + |
| 117 | +**Scopes:** by default the server requests |
| 118 | +`postmaster.traffic.readonly` (metrics + compliance) and `postmaster.domain` |
| 119 | +(list/get domains). Override with the `GPT_SCOPE` env var if you want to narrow |
| 120 | +it (e.g. traffic-only, dropping `list_domains`/`get_domain`). |
| 121 | + |
| 122 | +## Configuration (env overrides) |
| 123 | + |
| 124 | +| Variable | Purpose | Default | |
| 125 | +| --- | --- | --- | |
| 126 | +| `GPT_CLIENT_ID` | Google OAuth client ID (required) | — | |
| 127 | +| `GPT_CLIENT_SECRET` | Google OAuth client secret (required) | — | |
| 128 | +| `GPT_SCOPE` | Space-separated OAuth scopes | traffic.readonly + domain | |
| 129 | +| `GPT_API_BASE` | API base URL | `https://gmailpostmastertools.googleapis.com/v2` | |
| 130 | +| `GPT_TOKEN_DIR` | Token cache directory | `~/.gmail-postmaster-mcp` | |
| 131 | +| `GPT_LOGIN_TIMEOUT_MS` | Sign-in wait | `180000` | |
| 132 | +| `GPT_REQUEST_TIMEOUT_MS` | Per-request timeout | `60000` | |
| 133 | + |
| 134 | +## Build |
| 135 | + |
| 136 | +```bash |
| 137 | +npx @anthropic-ai/mcpb validate manifest.json |
| 138 | +npx @anthropic-ai/mcpb pack . gmail-postmaster-tools.mcpb |
| 139 | +``` |
| 140 | + |
| 141 | +Pushing a `vX.Y.Z` tag triggers CI to pack, attach the `.mcpb` to a GitHub |
| 142 | +Release, and publish to the MCP Registry. |
| 143 | + |
| 144 | +## Why zero dependencies |
| 145 | + |
| 146 | +Only Node.js built-ins (`http`, `https`, `crypto`, `readline`) — tiny bundle, no |
| 147 | +supply-chain risk, nothing to `npm install`. |
| 148 | + |
| 149 | +## Contributing |
| 150 | + |
| 151 | +See [CONTRIBUTING.md](CONTRIBUTING.md). |
| 152 | + |
| 153 | +## License |
| 154 | + |
| 155 | +[MIT](LICENSE) © OptiPub |
| 156 | + |
| 157 | +--- |
| 158 | + |
| 159 | +*Not affiliated with or endorsed by Google. "Gmail", "Google", and "Postmaster |
| 160 | +Tools" are trademarks of Google LLC.* |
0 commit comments