Skip to main content
Glama

Multi-Account MCP

A self-hosted server that connects several email, calendar and document accounts (Gmail and Google Workspace, Microsoft 365 and Outlook.com) and exposes them to AI clients through one remote MCP endpoint. Claude Code, Codex, ChatGPT and other MCP clients can then search, read and draft across all of your accounts, with every result tagged by the account it came from.

Example requests once a client is connected:

"Search my work account for messages from Sam this week." "Find an open hour Thursday across all my calendars." "Draft a reply to that message."

Replies are always drafted from the mailbox that received the original message.

What it does

The server holds the OAuth connection to each account you own and serves 19 MCP tools over one Streamable HTTP endpoint (/mcp):

  • Mail: search one account or all of them, read messages and threads, create drafts, create reply drafts locked to the originating mailbox, mark read or unread, archive, trash, and send (send is off unless you grant it).

  • Calendars: search events across accounts, create events, and find_free_time, which merges availability across every calendar.

  • Documents: search Google Drive across accounts, read Google Docs as Markdown and Sheets as CSV.

  • Composed: search_all (mail, documents and events in one call) and daily_brief (unread mail and today's events across every account).

A server-rendered admin UI covers owner setup, guided Google and Microsoft OAuth app setup, connecting accounts with per-service access and aliases, per-client tokens, an activity log, and security settings.

ChatGPT, which cannot send a static bearer token, connects through a small built-in OAuth 2.1 server. It is off by default; see docs/CHATGPT-OAUTH.md.

Related MCP server: multi-mail-mcp

Requirements

  • A Linux server with systemd. The provisioning script targets a fresh Ubuntu LTS VPS (it uses apt, ufw and Caddy). 1 vCPU and 1 GB of RAM is enough. Other distributions work if you follow the same steps by hand.

  • Node.js 22 or later. The provisioning script installs it.

  • A domain or subdomain with an A record pointing at the server. Caddy obtains the TLS certificate automatically.

  • Your own OAuth apps. The server talks to Google and Microsoft using OAuth clients that you register yourself; nothing goes through a shared vendor app. The admin UI walks you through both.

    • Google: you create a Google Cloud project, an External OAuth consent screen and a Web client. The app will be unverified, so Google shows an "app hasn't been verified" warning each time you connect an account, and you click through it. Gmail scopes are restricted scopes, so an unverified app is limited to a small number of users (100); that is fine for one person's accounts but not for offering the server to others. Publish the consent screen to "In production": in "Testing" mode only listed test users can connect and Google expires the connection after 7 days.

    • Microsoft: you register a multitenant Entra app with a client secret. Secrets expire (24 months at most), and you must create and save a new one before that happens. Some Microsoft 365 or Workspace tenants require an administrator to approve the app.

Quick start

See docs/QUICKSTART.md. In short: run deploy/install.sh on the server, clone this repository to /opt/multi-account-mcp/app, run npm ci and npm run build, start the multi-account-mcp systemd service, then finish setup in the browser. Updating, backups and restore are in deploy/README.md.

Security model

  • Single owner. The first visit runs a setup wizard that creates one owner account with a password (argon2id) and a required TOTP second factor, plus recovery codes. After setup, the wizard is permanently disabled. Sensitive actions require recent re-authentication.

  • Encryption at rest. OAuth tokens, OAuth client secrets and TOTP secrets are encrypted with AES-256-GCM using ENCRYPTION_KEY. A copy of the database without that key exposes none of them. Losing the key makes the stored credentials unrecoverable, so back it up separately.

  • No mailbox copy. Mail and documents are fetched from the provider on demand and are not stored.

  • Per-client tokens. Each MCP client gets its own bearer token, shown once and stored only as a SHA-256 hash. Each token has its own permissions (for example search, read, draft, send, calendar write), an optional list of allowed accounts, and an optional expiry, and can be revoked at any time. Permissions are enforced on the server for every tool call.

  • Content-free activity log. Tool calls are recorded by action, account and outcome, never by message content. Entries are kept for 90 days.

  • Least-privilege provider scopes. Each connected account requests only the Google or Microsoft scopes for the access level you choose.

  • Network exposure. The app listens on 127.0.0.1 only. Caddy terminates TLS and is the only public entry point; the provisioning script enables a firewall that allows ports 22, 80 and 443.

Local development

npm ci
npm run typecheck
npm test
npm run build

To run the server locally, create a .env from .env.example and fill in the two required secrets. ENCRYPTION_KEY must decode to exactly 32 bytes of base64 and SESSION_SECRET must be at least 32 characters:

cp .env.example .env
openssl rand -base64 32   # paste as ENCRYPTION_KEY
openssl rand -base64 32   # paste as SESSION_SECRET

For local use, also set APP_URL=http://localhost:8080 and NODE_ENV=development in .env (production mode sets the Secure flag on the session cookie, which breaks login over plain HTTP). The server reads its configuration from environment variables, so export the file before starting it:

set -a; . ./.env; set +a
npm run dev

The database is created under DATA_DIR (default ./data) and migrations run on startup.

License

MIT. See LICENSE.

Security issues

Please report vulnerabilities privately through GitHub security advisories on this repository, not in public issues.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Connects AI assistants to multiple Gmail accounts simultaneously, enabling search, read, draft, send, and reply operations with per-account permission controls.
      54
      ISC
    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to access multiple Gmail/Google Workspace accounts for searching and reading mail, calendars, and attachments.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables an AI assistant to search and read multiple Hotmail/Outlook and Gmail accounts plus Google Drive and Calendar, and to create drafts, calendar events, and files without sending email. It supports local and remote operation with owner-only authentication and audit logging.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to access and manage multiple Gmail and Google Workspace accounts simultaneously, including unified search, reading, drafting, sending, labeling, unsubscribing, package tracking, and follow-up reminders.
      1
      MIT