Skip to main content
Glama
Inbox Switchboard

Inbox Switchboard

README.md
<h1 align="center">Inbox Switchboard</h1>

<p align="center"><b>Connect every Gmail inbox to your AI, not just one.</b></p>

<p align="center">
  <a href="https://www.gregkowalczyk.com/tools/inbox-switchboard/#video"><b>Explainer video</b></a> ·
  <a href="https://www.gregkowalczyk.com/tools/inbox-switchboard/">Setup guide with pictures</a> ·
  <a href="https://www.gregkowalczyk.com/tools/inbox-switchboard/#step-1">Step-by-step walkthrough</a> ·
  <a href="#setup-about-15-minutes-once">Quick start</a>
</p>

<p align="center">
  <img alt="MIT licence" src="https://img.shields.io/badge/licence-MIT-f06000">
  <img alt="Node 18+" src="https://img.shields.io/badge/node-18%2B-12171d">
  <img alt="Zero dependencies" src="https://img.shields.io/badge/dependencies-0-12171d">
  <img alt="MCP server" src="https://img.shields.io/badge/MCP-server-12171d">
</p>

<p align="center">
  <a href="https://www.gregkowalczyk.com/tools/inbox-switchboard/#video">
    <img src="docs/explainer-poster.jpg" alt="Watch the two-minute explainer video" width="820">
  </a>
  <br>
  <a href="https://www.gregkowalczyk.com/tools/inbox-switchboard/#video"><b>▶ Watch the two-minute explainer</b></a>
</p>

Most AI assistants let you connect a single inbox. If you run a business you probably have several: your own, support@, billing@, a personal Gmail. Inbox Switchboard is a small MCP server that puts any number of them behind one connection. Claude (or any MCP client) can search, read, label, draft and send from each, and always knows which mailbox it is working in.

- One server, unlimited mailboxes (Google Workspace and personal Gmail both work)
- 21 tools: search, read threads and attachments, labels, archive, spam, trash, drafts, replies, forwards, send ([what each one does](#the-21-tools))
- Your mail stays between your computer and Google. There is no middleman server and nobody else's keys are involved
- Zero dependencies: one JavaScript file, needs only Node 18+
- Cannot permanently delete mail (it uses Google's `gmail.modify` permission, which does not allow it)
- Optional drafts-only mode, so nothing is ever sent without you pressing Send in Gmail

## How it works

<p align="center"><img src="docs/how-it-works.png" alt="Your inboxes connect to Inbox Switchboard on your computer, which connects to your AI assistant" width="820"></p>

You create your own free Google "app" (an OAuth client) once. Each mailbox then signs in to that app through the normal Google consent screen. The key and every sign-in are kept in your computer's password vault (Keychain on a Mac), never in a plain file and never in the chat.

## Setup (about 15 minutes, once)

### 1. Create your Google key

**The easy way: let your AI do the clicking.** If you use [Claude in Chrome](https://claude.com/chrome) or another browser agent, paste this:

```
Walk me through creating a Google OAuth client for a tool called Inbox Switchboard.
Work in my browser, one step at a time, and tell me what you are about to click before you click it.
1. Open console.cloud.google.com and create a new project named "Inbox Switchboard".
2. In APIs & Services > Library, enable the Gmail API for that project.
3. Open Google Auth Platform and click Get started. App name "Inbox Switchboard", my email for
   support and contact. For Audience choose Internal if all my mailboxes are in one Google
   Workspace; otherwise choose External.
4. If you chose External: on the Audience page, click Publish app so the status is "In production".
5. On the Clients page, create a client with application type "Desktop app", then download its JSON.
Stop and let me handle any sign-in, password or billing screen myself. Do not change anything else
in my Google account. The downloaded JSON file is a secret: do not open it, read it, or show its
contents, and never ask me to paste it into this chat. When it has downloaded, just tell me to run
"npx -y github:kowalcg/inbox-switchboard setup" in my own terminal.
```

**The manual way:**

1. Go to [console.cloud.google.com](https://console.cloud.google.com/) and create a new project (any name).
2. Open **APIs & Services → Library**, find **Gmail API**, click **Enable**.
3. Open **Google Auth Platform** and click **Get started**. Enter an app name and your email.
   - If every mailbox is in the same Google Workspace, choose **Internal**. Done.
   - Otherwise choose **External**. When the wizard finishes, open **Audience** and click **Publish app** so the status reads "In production". You do not need Google's verification for your own use; you will see an "unverified app" notice when signing in (click **Advanced → Go to app**).
   - Do not leave an External app in "Testing": Google then expires every sign-in after 7 days.
4. Open **Clients → Create client**. Application type: **Desktop app**. Create it, then **Download JSON**.

Google renames these screens from time to time. The names above were checked in December 2026.

### 2. Lock the key in your password vault

Open a terminal (Terminal on a Mac, PowerShell on Windows) and run:

```bash
npx -y github:kowalcg/inbox-switchboard setup
```

It finds the `client_secret…json` file in your Downloads folder, stores the key in your computer's password vault, and deletes the download. You should see:

```
Stored your Google key in macOS Keychain.
Deleted the downloaded file: …/Downloads/client_secret_….json
```

**Three rules that keep the key safe**

1. **Never paste the key into a chat**, including your AI assistant. You run the command; the assistant never sees the key.
2. **Never email it or leave it in a shared or synced folder.** After setup there is no file left to leak.
3. **If it ever gets out, cancel it.** Delete the client in Google Cloud Console and run `setup` again with a new one.

Other commands: `… status` shows where things are stored and which mailboxes are connected. `… forget` removes the key and every sign-in from this computer.

### 3. Install

**Claude Code:**

```
/plugin marketplace add kowalcg/inbox-switchboard
/plugin install inbox-switchboard@inbox-switchboard
```

**Claude Desktop, Cursor, or any other MCP client:** add this to the client's MCP config (Claude Desktop: Settings → Developer → Edit Config) and restart it. It needs [Node.js](https://nodejs.org/) 18 or newer.

```json
{
  "mcpServers": {
    "inbox-switchboard": {
      "command": "npx",
      "args": ["-y", "github:kowalcg/inbox-switchboard"]
    }
  }
}
```

Prefer a fixed copy you control? Download [`server.mjs`](plugins/inbox-switchboard/server.mjs) and use `"command": "node", "args": ["/full/path/to/server.mjs"]` instead.

### 4. Connect your mailboxes

Ask your assistant:

> Connect my mailbox you@yourcompany.com

It gives you a Google sign-in link. Open it, pick that account, approve. Repeat for each mailbox. Then try:

> List my mailboxes, then show me unread mail from this week in each one.

## What it does

Inbox Switchboard gives your AI assistant 21 actions ("tools") it can use in any mailbox you have connected. You never call them yourself. You ask in plain words, and the assistant picks the right tools and the right mailbox.

**What that lets you do**

- **One search across every inbox.** "Check all my mailboxes for anything from our accountant this month."
- **Clear a shared inbox.** "Draft replies to the five oldest unanswered emails in support@." You review the drafts and send.
- **Chase paperwork.** "Find last week's invoices in billing@, save the PDFs' details and list who has not paid."
- **Tidy up.** "Archive the newsletters in my personal Gmail, label the receipts, and mark the rest read."
- **Reply from the right address.** A customer email to support@ is answered from support@, not from your personal account.
- **Daily brief.** "Give me the three things that need me today across all inboxes."

Every tool except `list_mailboxes` and `authorize_mailbox` takes an `account` (the mailbox address), so the assistant always states which inbox it is acting in.

### The 21 tools

**Mailboxes (3)**

| Tool | What it does | Example request |
|---|---|---|
| `list_mailboxes` | Lists every mailbox that is connected. The assistant calls this first. | "Which inboxes can you see?" |
| `authorize_mailbox` | Connects a new mailbox, or reconnects one whose access expired. Returns a Google sign-in link for you to approve. | "Connect my mailbox billing@mycompany.com" |
| `remove_mailbox` | Disconnects a mailbox by deleting its saved sign-in from your computer. | "Disconnect my personal Gmail" |

**Find and read (4)**

| Tool | What it does | Example request |
|---|---|---|
| `search_mail` | Searches one mailbox with Gmail's own search language (`from:`, `newer_than:7d`, `has:attachment`…), including archived mail. Returns up to 100 results a page. | "Anything from Amy in the last week?" |
| `get_message` | Opens one email: sender, subject, body and the list of attachments. | "Open the latest one" |
| `get_thread` | Reads a whole conversation, every message in order. | "Summarise this thread" |
| `get_attachment` | Fetches one attachment from an email. | "What does the attached quote say?" |

**Labels (3)**

| Tool | What it does | Example request |
|---|---|---|
| `list_labels` | Lists the labels (folders) in a mailbox. | "What labels do I have in support@?" |
| `create_label` | Creates a new label. | "Make a label called Receipts 2026" |
| `apply_labels` | Adds or removes labels on one or many emails. | "Label these five as Receipts 2026" |

**Organise (5)**

| Tool | What it does | Example request |
|---|---|---|
| `mark_read` | Marks emails read or unread. | "Mark the newsletters as read" |
| `star_mail` | Stars or unstars emails. | "Star anything from the bank" |
| `archive_mail` | Removes emails from the inbox but keeps them in All Mail. | "Archive everything older than a month" |
| `mark_spam` | Sends emails to Spam, or rescues them from it. | "That one is spam" |
| `trash_mail` | Moves emails to Trash. Gmail keeps them 30 days; nothing is deleted for good. | "Bin these three" |

**Write (2)**

| Tool | What it does | Example request |
|---|---|---|
| `draft_mail` | Writes a new email and leaves it in Drafts. Plain text or HTML, with CC and BCC. | "Draft a note to Sam about Friday" |
| `reply_draft` | Writes a reply inside the existing conversation and leaves it in Drafts. Reply or reply-all. | "Draft a reply saying yes" |

**Send (4)**

| Tool | What it does | Example request |
|---|---|---|
| `send_mail` | Sends a new email from the mailbox you name. | "Send it from billing@" |
| `reply_mail` | Sends a reply in the existing conversation. | "Reply that we ship Monday" |
| `send_draft` | Sends a draft that is already in the mailbox. | "Looks good, send that draft" |
| `forward_mail` | Forwards an email with its attachments. Makes a draft unless told to send now. | "Forward this to my bookkeeper" |

The assistant is told to confirm recipients and wording with you before any of the four send tools. With drafts-only mode on (see Options), `send_mail`, `reply_mail` and `send_draft` are removed and `forward_mail` can only create drafts, which leaves 18 tools.

**What it cannot do:** permanently delete mail, change Gmail settings or filters, read contacts or calendar, or touch any mailbox you have not connected.

## Options

Set these as environment variables in the MCP config (`"env": { ... }`):

| Variable | Effect |
|---|---|
| `INBOX_SWITCHBOARD_NO_SEND=1` | Drafts only. Removes `send_mail`, `reply_mail` and `send_draft`, and blocks `forward_mail` from sending. Recommended while you are getting comfortable. |
| `INBOX_SWITCHBOARD_VAULT=file` | Only for computers with no password vault (for example a headless Linux server). Stores the key and sign-ins in one file only your account can read, in `~/.config/inbox-switchboard/` or `$INBOX_SWITCHBOARD_HOME`. |

## Security

How it is built:

- **Local only.** The server talks to three Google addresses (`accounts.google.com`, `oauth2.googleapis.com`, `gmail.googleapis.com`) and nothing else. No analytics, no update checks, no third-party services.
- **Keys live in the vault, not in files.** The Google key and each mailbox sign-in are stored in the operating system's password vault: Keychain on macOS, the Secret Service keyring on Linux, and a file encrypted for your Windows account (DPAPI) on Windows. Secrets are handed to the vault on standard input, never on a command line. Nothing is bundled with this repository.
- **The assistant never handles the key.** You store it yourself with the `setup` command. The server tells the assistant not to ask for keys, open key files or print them.
- **Upgrading is automatic.** If version 1.0 left `oauth-client.json` and `tokens.json` on disk, the first run moves them into the vault and deletes the files.
- **Careful sign-in.** The Google sign-in uses PKCE and a one-time state value, listens on `127.0.0.1` only, and refuses to store a mailbox if the approved account is not the one you asked for.
- **Least privilege that still works.** It requests `gmail.modify`, which cannot permanently delete mail.
- **One file, no dependencies.** [`server.mjs`](plugins/inbox-switchboard/server.mjs) is about 600 lines. You can read all of it.

What to keep in mind:

- The vault protects the key from being synced, backed up, shared or pasted by accident. It does not protect against malicious software already running under your own login, which can ask the vault the same way this tool does. Keep your computer clean and locked.
- Tested on macOS. The Linux and Windows vault paths follow each system's documented tools but have not been tested on real machines yet; please open an issue if one misbehaves.
- The server asks the assistant to confirm with you before sending. For a hard guarantee, use `INBOX_SWITCHBOARD_NO_SEND=1`.
- Email is untrusted input. A message can contain text written to trick an AI assistant; review what your assistant proposes before approving actions.
- To revoke access completely, remove your app at [myaccount.google.com/permissions](https://myaccount.google.com/permissions).

## Troubleshooting

| Problem | Fix |
|---|---|
| "Setup needed: no Google key is stored yet" | Run `npx -y github:kowalcg/inbox-switchboard setup` in your terminal after downloading the key (step 2). |
| `403 access_denied` at sign-in | The app is External + Testing and this mailbox is not a test user. Publish the app (step 1). |
| A mailbox stops working after a week | Same cause: app still in Testing. Publish it, then reconnect the mailbox. |
| "Wrong account" after approving | You picked a different Google account than the one requested. Ask for a new link. |
| "authorization has expired or was revoked" | Ask your assistant to connect that mailbox again. |

## Want it set up for you?

I build AI systems inside small and medium-sized businesses. If you would rather have this installed, connected and working with your team's inboxes in one sitting, [get in touch](https://www.gregkowalczyk.com/contact/).

Greg Kowalczyk · [gregkowalczyk.com](https://www.gregkowalczyk.com/)

## License

MIT. Not affiliated with or endorsed by Google. Gmail is a trademark of Google LLC.