Why I Replaced Google Workspace MCP with gwscli and Nix

Google’s official gwscli replaces nine GA Workspace MCP servers with one local binary and finally supports personal Gmail accounts. Wire it declaratively in Nix with isolated personal and work wrappers and narrow write scopes.

Woojong Koh

  ·  8 min read · 1588 words

Four months ago, I documented how to connect Google Workspace MCP servers to Antigravity CLI with Nix and SOPS. That setup worked, yet it carried real baggage. It required enrolling a paid custom domain in Google’s Workspace Developer Preview, waiting 16 hours for edge-proxy permissions to propagate, wiring six separate remote MCP endpoints into mcp_config.json, and templating OAuth client secrets through sops-nix. Personal Gmail accounts were locked out with 403 errors.

On November 24, 2026, Google ended that ceremony. The core Google Workspace remote MCP servers reached General Availability, personal Gmail accounts gained one-click OAuth setup, and Google shipped gwscli, an official unified CLI for Gmail, Drive, Docs, Sheets, Slides, Calendar, Chat, Tasks, and Contacts.

For terminal AI agents such as Antigravity CLI, Claude Code, and Codex, a single local CLI still beats the new GA remote MCP servers across authentication, data filtering, local file handling, and multi-account isolation. I retired all six Workspace MCP servers across my Macs and replaced them with gwscli, official agent skills, and two Nix-managed wrapper binaries that keep personal and work accounts completely separate on the same machine.

Why gwscli Beats the New GA Remote MCP Servers #

The November 24 GA release added Sheets, Slides, and Tasks, expanding the core remote MCP catalog to nine separate servers per Google account. If you want both a personal Gmail inbox and a work domain wired into remote MCP, you end up managing eighteen server entries and eighteen Web OAuth handshakes on every workstation, alongside sops.templates client-secret plumbing in mcp_config.json. When an OAuth client flag or refresh token shifts, half your servers silently fail to load.

gwscli collapses all nine services into one Go binary and one Desktop OAuth flow per account. It works identically across Antigravity CLI, Claude Code, Codex, and plain shell scripts with zero per-client MCP duplication. Running gwscli skills install drops Google’s own command guide into your agent’s global skills directory so fresh sessions discover subcommands cleanly.

DimensionNew GA Remote MCPgwscli
Auth9 servers per account, 18 for dual accounts, Web OAuth1 Desktop login per wrapper, 2 scripts for dual accounts
FilteringRaw API JSON returns directly into model contextPipe stdout through jq or Python before the model sees it
Local filesClunky for local disk paths and binary uploadsReads Drive files locally and attaches local files to drafts
PortabilityConfigured separately per MCP hostOne binary on PATH plus global skills across every agent
HITL approvalsNative MCP form prompts in supported UIsPauses on stdin and stderr for ALLOW_ONCE or ALLOW_TOOL_ALWAYS

Watch out for one immediate naming trap before installing anything. gwscli is brand new and is neither in Homebrew nor in nixpkgs yet. Installing googleworkspace-cli from Homebrew or building github:googleworkspace/cli gives you gws, an older unofficial open-source Rust CLI, rather than Google’s official gwscli binary.

Handling a Floating Binary in Nix Without Breaking Builds #

Google currently distributes gwscli only as unversioned floating binaries through https://dl.google.com/workspace-cli/install.sh. Wrapping a floating URL in pkgs.fetchurl with a fixed SHA-256 hash is an antipattern: the moment Google ships a silent binary update, your next darwin-rebuild switch fails with a hash mismatch.

A cleaner declarative boundary is to bootstrap the binary and its agent skills inside a Home Manager activation hook when absent, then pair it with an explicit upgrade task when you choose to pull a newer build:

home.sessionPath = [
  "${config.home.homeDirectory}/.local/bin"
];

home.activation.installGwscli = lib.hm.dag.entryAfter ["writeBoundary"] ''
  if [ ! -x "$HOME/.local/bin/gwscli" ]; then
    export PATH="${pkgs.curl}/bin:${pkgs.bash}/bin:/usr/bin:/bin:$PATH"
    ${pkgs.curl}/bin/curl -fsSL https://dl.google.com/workspace-cli/install.sh | ${pkgs.bash}/bin/bash || true
  fi
  if [ -x "$HOME/.local/bin/gwscli" ]; then
    if [ ! -d "$HOME/.gemini/config/skills/gwscli" ]; then
      mkdir -p "$HOME/.gemini/config/skills"
      "$HOME/.local/bin/gwscli" skills install --dir "$HOME/.gemini/config/skills" || true
    fi
    if [ ! -d "$HOME/.agents/skills/gwscli" ]; then
      mkdir -p "$HOME/.agents/skills"
      "$HOME/.local/bin/gwscli" skills install --dir "$HOME/.agents/skills" || true
    fi
  fi
'';

Syncing skills into both ~/.gemini/config/skills and ~/.agents/skills covers Antigravity CLI alongside other local coding agents automatically on every new workstation. When you want a newer release, one Taskfile command updates the binary and refreshes both skill directories in place:

upgrade-gwscli:
  desc: Download latest Google Workspace CLI binary and refresh agent skills
  cmds:
    - curl -fsSL https://dl.google.com/workspace-cli/install.sh | bash
    - ~/.local/bin/gwscli version
    - mkdir -p ~/.gemini/config/skills ~/.agents/skills
    - ~/.local/bin/gwscli skills install --dir ~/.gemini/config/skills --overwrite
    - ~/.local/bin/gwscli skills install --dir ~/.agents/skills --overwrite

Isolating Personal and Work Accounts on One Machine #

The first real gap you hit with gwscli is multi-account access. The binary ships without a --profile or --account flag. Inspecting the Go binary shows why isolation is still straightforward: gwscli calls os.UserConfigDir() and writes client_credentials.json and token.json as plain files under $HOME/Library/Application Support/gwscli on macOS rather than locking them inside macOS Keychain.

Overriding HOME, XDG_CONFIG_HOME, and XDG_CACHE_HOME inside dedicated wrapper scripts isolates each Google identity completely across macOS and Linux. Resist the temptation to use shell aliases in .zshrc. Non-interactive subshells spawned by coding agents ignore shell aliases, whereas real executables generated by pkgs.writeShellScriptBin sit on PATH for both you and every agent:

home.packages = [
  (pkgs.writeShellScriptBin "gwscli-personal" ''
    set -euo pipefail
    REAL_HOME="$HOME"
    PROFILE_HOME="$REAL_HOME/.gwscli/profiles/personal"
    mkdir -p "$PROFILE_HOME"
    chmod 700 "$PROFILE_HOME"
    export HOME="$PROFILE_HOME"
    export XDG_CONFIG_HOME="$PROFILE_HOME/.config"
    export XDG_CACHE_HOME="$PROFILE_HOME/.cache"
    exec "$REAL_HOME/.local/bin/gwscli" "$@"
  '')
  (pkgs.writeShellScriptBin "gwscli-work" ''
    set -euo pipefail
    REAL_HOME="$HOME"
    PROFILE_HOME="$REAL_HOME/.gwscli/profiles/work"
    mkdir -p "$PROFILE_HOME"
    chmod 700 "$PROFILE_HOME"
    export HOME="$PROFILE_HOME"
    export XDG_CONFIG_HOME="$PROFILE_HOME/.config"
    export XDG_CACHE_HOME="$PROFILE_HOME/.cache"
    exec "$REAL_HOME/.local/bin/gwscli" "$@"
  '')
];

Each account gets its own Desktop OAuth client JSON via Google Cloud Console Personal Mode. That link pre-selects a Desktop application flagged for an AI-powered agent, enables the core Workspace and MCP APIs, skips OAuth consent-screen verification, and requires no billing account or credit card on the free Standard Tier. Personal Gmail accounts work with the exact same flow as custom Workspace domains.

Least-Privilege Scopes Over Full Write Access #

gwscli merges scopes incrementally across repeated auth login calls, which lets you grant narrow write capabilities without handing an agent unrestricted delete authority. Starting from --bundle=readonly and adding five targeted capabilities gives an agent high daily utility with a small blast radius:

  • Baseline reads with --bundle=readonly: Covers read access across all nine GA Workspace services for triage, search, and morning briefings.
  • Drafts without delete power via "gmail create_draft": Grants gmail.compose so an agent can prepare reviewable replies without holding gmail.modify, label edits, or mail deletion.
  • Scoped Drive access via "drive list_recent_files": Grants drive.file for listing recent files and creating new uploads without unrestricted delete rights across your entire Drive.
  • Scheduling via calendar and tasks: Lets an agent convert incoming emails into calendar holds, invite updates, and action items.
  • Identity checks via "people get_user_profile": Adds userinfo.profile so auth status prints the signed-in account and prevents personal and work mix-ups.

Run the setup interactively in your own terminal once per wrapper so tokens land inside each mode 0700 profile directory:

gwscli-personal auth setup --oauth_client_file=/path/to/personal_client_secret.json
gwscli-personal auth login --bundle=readonly
gwscli-personal auth login "gmail create_draft" "drive list_recent_files" "people get_user_profile" calendar tasks
gwscli-personal auth status

gwscli-work auth setup --oauth_client_file=/path/to/work_client_secret.json
gwscli-work auth login --bundle=readonly
gwscli-work auth login "gmail create_draft" "drive list_recent_files" "people get_user_profile" calendar tasks
gwscli-work auth status

Once both wrappers report active tokens, document them in your global agent instructions file such as ~/.gemini/GEMINI.md so every fresh session knows which wrapper owns personal mail and which owns work mail, and never attempts headless interactive login.

Pre-Approving Read-Only Tools in an Interactive Terminal #

After login, daily agent runs quickly hit Google’s server-side Human-in-the-Loop approvals. External-sender emails, subscribed calendars, and shared Drive files trigger an MCP elicitation pause on stderr and stdin. Over a non-interactive agent pipe, gwscli disables persistent approvals and allows only single-request ALLOW_ONCE. Run each read-only tool once yourself in a real terminal and enter the literal enum ALLOW_TOOL_ALWAYS rather than the display label; Google persists that grant server-side across future headless invocations:

# Pass an external messageId from `gmail search_threads` and a query matching an external event
gwscli-work gmail get_message --messageId="<external-message-id>" > /dev/null
gwscli-work calendar list_calendars > /dev/null
gwscli-work calendar search_events --query="meeting" > /dev/null
gwscli-work drive list_recent_files --pageSize=3 > /dev/null

Redirecting stdout to /dev/null hides raw JSON while keeping the stderr prompt visible; repeat with gwscli-personal if needed. Restrict ALLOW_TOOL_ALWAYS to read-only inspection commands. Leave in-scope write tools such as calendar delete_event and calendar update_event unapproved so they still gate on confirmation, and keep gmail send_message or gmail trash_message unapproved if you ever widen OAuth scopes later.

Three Tradeoffs to Know Before Migrating #

Moving from a stack of remote MCP endpoints to wrapped gwscli binaries removes a pile of Nix and OAuth machinery, yet three practical limits remain:

  1. Remaining Human-in-the-Loop Prompts: Pre-approving core read-only tools removes most daily friction, yet first-time reads of externally shared Docs, Sheets, or Slides and mutating actions still pause on stdin. That policy lives on Google’s Workspace MCP backend to block indirect prompt injection, and GA remote MCP renders smoother native forms for those remaining gates.
  2. Unpinned Upstream Binary: Installing from Google’s floating install.sh endpoint trades bit-for-bit Nix store reproducibility for clean rebuilds until Google publishes versioned release artifacts or nixpkgs packages gwscli.
  3. API and Remote MCP Gaps: gwscli gmail cannot download incoming binary attachments yet and rejects RAW format on multipart messages. GUI chat clients without shell access still need remote MCP endpoints, and Google’s cross-application workspace-universal tool currently ships as a remote MCP server only.

For developers living in terminal agents across both a personal Gmail inbox and a work domain, gwscli paired with two tiny Nix wrappers is a clear upgrade. You avoid nine remote MCP endpoints per account, delete SOPS client-secret plumbing from mcp_config.json, gain free personal account support, and keep every token pinned to its own isolated profile.