{
  "markdown": "# Gemini Account Switcher (Rust)\n\n> A high-performance Rust extension for [Gemini CLI](https://github.com/google/gemini-cli) that adds multi-account support with an intelligent background watcher for quota management.\n\n![Language](https://img.shields.io/badge/Language-Rust-orange?style=flat-square)\n![MCP](https://img.shields.io/badge/MCP-Supported-blue?style=flat-square)\n![Platform](https://img.shields.io/badge/Platform-Linux%20%7C%20macOS%20%7C%20Windows-green?style=flat-square)\n\n---\n\n## Why?\n\nGemini CLI typically allows one Google account at a time. For heavy workloads, you can hit the free tier quota quickly. This tool allows you to:\n\n- **Rotate multiple accounts** to bypass single-account limits.\n- **Switch instantly** via slash commands inside your Gemini session.\n- **Background Monitor** logs in real-time to detect `RESOURCE_EXHAUSTED` errors and prompt for an immediate switch to your most \"rested\" account.\n\n## Features\n\n- **MCP Integration**: Fully compliant Model Context Protocol server exposing account tools.\n- **Smart Auto-Switch**: Automatically identifies the account with the most remaining quota when you get blocked.\n- **Background Watcher**: Real-time log monitoring with native desktop notifications.\n- **Session Safety**: Automatically backs up your active session before every switch.\n- **Native Performance**: Single binary, low memory footprint, and blazing fast file operations.\n\n## Architecture\n\n1.  **MCP Server (`mcp`)**: Handles tool calls from Gemini CLI (list, save, switch, delete).\n2.  **Watcher (`watch`)**: A background loop that scans logs, tracks usage, and provides the interactive switch UI.\n\n---\n\n## Installation\n\n### 1. Build from Source\n```bash\ncargo build --release\n```\nThe binary will be generated at `target/release/gemini-account-switcher-rs`.\n\n### 2. Register the Extension\nLink the extension to your Gemini CLI by ensuring your `gemini-extension.json` exists in the project root:\n\n```json\n{\n  \"name\": \"GeminiAccountSwitcherRs\",\n  \"version\": \"0.1.0\",\n  \"mcpServers\": {\n    \"accountSwitcher\": {\n      \"command\": \"/absolute/path/to/target/release/gemini-account-switcher-rs\",\n      \"args\": [\"mcp\"]\n    }\n  }\n}\n```\n\n---\n\n## Usage\n\n### Step 1: Save your accounts\nInside Gemini CLI, save your current session under a name:\n```\n/accounts:save main\n/accounts:save secondary\n```\n\n### Step 2: Start the Watcher\nIn a separate terminal window, keep the watcher running:\n```bash\n./target/release/gemini-account-switcher-rs watch\n```\n\n### Watcher Output Example\n\n```text\n╔══════════════════════════════════════════════════╗\n║     Gemini Account Switcher — Watcher (Rust)     ║\n╚══════════════════════════════════════════════════╝\n\n👤 Current account: main\n\n📊 Today's usage:\n   main: 847 requests — OK\n   secondary: 12 requests — OK\n\n👁️  Watching Gemini CLI logs for quota errors...\n```\n\nWhen quota exhausts, the watcher prompts you:\n```text\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n  ⚠️  QUOTA EXHAUSTED: main\n  Switch to: secondary (12 requests used today)\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n  Switch now? (y/n): y\n  ✅ Switched to secondary. Please restart your Gemini CLI session.\n```\n\n---\n\n## How It Works\n\n### Account Storage\nGemini CLI stores credentials in `~/.gemini/`. This tool creates a profile for each account in `~/.gemini-accounts/<name>/` and swaps the files (`oauth_creds.json`, etc.) whenever you switch.\n\n### Quota Detection\nThe watcher polls `~/.gemini/tmp/*/logs.json` every 5 seconds. It uses high-performance stream reading to detect `RESOURCE_EXHAUSTED` strings without re-reading the entire log file every time.\n\n### Selection Logic\nWhen a switch is needed, the tool scans all saved accounts that aren't marked as \"Exhausted\" today and picks the one with the lowest `daily_requests` count.\n\n---\n\n## File & Folder Locations\n\n| Item | Location |\n| :--- | :--- |\n| **Saved accounts** | `~/.gemini-accounts/` |\n| **Usage tracker** | `~/.gemini-accounts/_usage_tracker.json` |\n| **Session backup** | `~/.gemini-accounts/_previous_session/` |\n| **Gemini CLI logs** | `~/.gemini/tmp/*/logs.json` |\n\n---\n\n## License\nApache License 2.0\n",
  "bytes": 4124,
  "sha": "039192e13e839e31bccf68bc8ff857ed44f70766e74b5ec80185fdace450b50e",
  "repo_slug": "alexander-nilsson/gemini-cli-acount-switcher-mcp",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/plg_alexander_nilsson_gemini_cli_acount_swit_c128b746/readme"
}