-
Notifications
You must be signed in to change notification settings - Fork 136
Feature: Support multiple Google accounts via GOOGLE_MCP_PROFILE env var #63
Description
Problem
When using this MCP server across multiple projects, each project may need to authenticate with a different Google account. Currently, there's a single token stored at ~/.config/google-docs-mcp/token.json, which means all projects share the same Google account. Switching accounts requires re-authenticating each time.
Proposed Solution
Add support for a GOOGLE_MCP_PROFILE environment variable that stores tokens in profile-specific subdirectories:
~/.config/google-docs-mcp/
├── token.json # default (no profile set)
├── project-a/token.json # GOOGLE_MCP_PROFILE=project-a
├── project-b/token.json # GOOGLE_MCP_PROFILE=project-b
The change is minimal — only the getConfigDir() function in auth.ts needs to be updated:
function getConfigDir(): string {
const xdg = process.env.XDG_CONFIG_HOME;
const base = xdg || path.join(os.homedir(), '.config');
const baseDir = path.join(base, 'google-docs-mcp');
const profile = process.env.GOOGLE_MCP_PROFILE;
return profile ? path.join(baseDir, profile) : baseDir;
}Why env var?
This follows the existing pattern in the project — configuration is done via environment variables (GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, SERVICE_ACCOUNT_PATH, XDG_CONFIG_HOME). Adding GOOGLE_MCP_PROFILE is consistent with that approach.
Usage example
{
"mcpServers": {
"google-docs-work": {
"command": "npx",
"args": ["-y", "@anthropic/google-docs-mcp"],
"env": {
"GOOGLE_CLIENT_ID": "...",
"GOOGLE_CLIENT_SECRET": "...",
"GOOGLE_MCP_PROFILE": "work"
}
}
}
}Backward compatible
Without GOOGLE_MCP_PROFILE set, behavior is unchanged — tokens are stored in the default location. Existing setups are not affected.
I have a working implementation and will follow up with a PR.