Skip to content

Add multi-account support#5

Open
nicholas-anthony-ai wants to merge 1 commit into
ArtyMcLabin:mainfrom
nicholas-anthony-ai:feature/multi-account
Open

Add multi-account support#5
nicholas-anthony-ai wants to merge 1 commit into
ArtyMcLabin:mainfrom
nicholas-anthony-ai:feature/multi-account

Conversation

@nicholas-anthony-ai

Copy link
Copy Markdown

Summary

  • Adds multi-account Gmail support — authenticate and use multiple Gmail accounts from a single MCP server instance
  • Fully backwards-compatible: existing single-account setups work unchanged

Details

  • New auth command: node dist/index.js auth <account-name> to authenticate named accounts
  • Credentials stored as ~/.gmail-mcp/credentials-<account-name>.json
  • All existing tools accept an optional account parameter; omit for default
  • New list_accounts tool to see configured accounts
  • Account name regex supports dots, hyphens, and underscores

This is a resubmission of GongRzhe/Gmail-MCP-Server#93.

Test plan

  • node dist/index.js auth work — authenticates a named account
  • list_accounts — shows all configured accounts
  • search_emails with account: "work" — searches the named account
  • All tools work without account param (default account, backwards-compatible)

🤖 Generated with Claude Code

Allow managing multiple Gmail accounts from a single server instance.
Each tool accepts an optional `account` parameter; omitting it uses
the default account for full backwards compatibility.

- Replace singleton OAuth2Client with per-account Gmail client map
- Add loadAllAccounts() to discover credentials-*.json files
- Add authenticate(accountName) for per-account auth flow
- Add `account` param to all 19 existing tool schemas
- Add list_accounts tool to show configured accounts
- Update README with multi-account usage docs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tansanDOTeth

tansanDOTeth commented Mar 4, 2026

Copy link
Copy Markdown

Wouldn't it be better to just add the same mcp multiple times so you can leverage existing enable/disable UI? there is an env var to help you namespace your auth keys via folders.

Here's an example of what you can do already:

  # Work account
  claude mcp add \
    --env GMAIL_OAUTH_PATH=~/.gmail-mcp/work/gcp-oauth.keys.json \
    --env GMAIL_CREDENTIALS_PATH=~/.gmail-mcp/work/credentials.json \
    gmail-work -- npx @gongrzhe/server-gmail-autoauth-mcp

  # Personal account
  claude mcp add \
    --env GMAIL_OAUTH_PATH=~/.gmail-mcp/personal/gcp-oauth.keys.json \
    --env GMAIL_CREDENTIALS_PATH=~/.gmail-mcp/personal/credentials.json \
    gmail-personal -- npx @gongrzhe/server-gmail-autoauth-mcp

This way, you can leverage existing tool permissions for each account for each mcp.

@ArtyMcLabin

Copy link
Copy Markdown
Owner

Thanks for this! I don't use multi-account myself, so I can't properly test or validate this PR. I'd like to get at least one community member who actually uses multiple Gmail accounts to test and review before merging.

If anyone reading this uses multi-account Gmail and can test this branch, please report back here.

Side note: the accountName parameter is used directly in filesystem paths (credentials-${accountName}.json) — would be good to add a /^[\w-]+$/ validation check to prevent path traversal edge cases.

@nicholas-anthony-ai

nicholas-anthony-ai commented Mar 8, 2026 via email

Copy link
Copy Markdown
Author

@ArtyMcLabin

Copy link
Copy Markdown
Owner

It takes 2 mins to create a gmail account.

On Sat, 7 Mar 2026 at 20:48, Arty McLabin @.> wrote: ArtyMcLabin left a comment (ArtyMcLabin/Gmail-MCP-Server#5) <#5 (comment)> Thanks for this! I don't use multi-account myself, so I can't properly test or validate this PR. I'd like to get at least one community member who actually uses multiple Gmail accounts to test and review before merging. If anyone reading this uses multi-account Gmail and can test this branch, please report back here. Side note: the accountName parameter is used directly in filesystem paths (credentials-${accountName}.json) — would be good to add a /^[\w-]+$/ validation check to prevent path traversal edge cases. — Reply to this email directly, view it on GitHub <#5 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/BNBT4L5AZKTZWH22HFQT33T4PPV7NAVCNFSM6AAAAACWGEWCPCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DAMJWGEYTQOJWHA . You are receiving this because you authored the thread.Message ID: @.>

creating an acc is not the problem. in fact i have more google accs already. the problem is that i cannot genchi genbutsu it since i don't need it for my day-to-day flow, so i cannot judge on it's performance correctly. need here someone who actually needs it and can confirm it's useful and functional :]

@ArtyMcLabin ArtyMcLabin added the help wanted Extra attention is needed label Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants