{
  "markdown": "# Gemini Account Switcher\n\nSwitch between multiple Google OAuth accounts in Gemini CLI — seamless quota management for automation workflows.\n\n## 🎯 What is Account Switcher?\n\nAccount Switcher is a lightweight MCP extension that enables:\n1. **Save** your current OAuth session as a named profile\n2. **Switch** between saved profiles instantly\n3. **Manage** multiple Google accounts without re-authenticating\n4. **Automate** quota rotation for uninterrupted workflows\n\n### Key Insight\n\nWhen API quota is exhausted on one account, simply switch to another and continue working. Perfect for automation tools that need to run overnight or handle heavy workloads.\n\n### Real-World Use Cases\n\n- ✅ Rotate accounts when quota is exhausted during long automation sessions\n- ✅ Separate work and personal accounts\n- ✅ Development vs. production credential isolation\n- ✅ Automated failover in CI/CD pipelines\n\n## ✨ Features\n\n| Feature                       | Description                                            |\n| ----------------------------- | ------------------------------------------------------ |\n| **MCP-based Tools**           | Native Gemini CLI integration via Model Context Protocol |\n| **Self-Contained Bundle**     | Pre-built with all dependencies — no npm install needed |\n| **Secure Storage**            | Credentials stored with 600 permissions                |\n| **Path Traversal Protection** | Strict profile name validation prevents exploits       |\n| **Automatic Backups**         | Creates timestamped backups before switching (keeps 5) |\n| **Cross-Platform**            | Works on Windows, macOS, and Linux                     |\n\n## 📦 Installation\n\n### From GitHub (Recommended)\n\n```bash\ngemini extensions install https://github.com/kranthik123/Gemini-Account-Switcher.git\n```\n\n### Verify Installation\n\n```bash\n# List installed extensions\ngemini extensions list\n\n# Start Gemini CLI and check MCP connection\ngemini\n/mcp list\n```\n\nYou should see:\n```\n🟢 accountSwitcher (from gemini-account-switcher) - Ready (6 tools)\n```\n\n## 🚀 Quick Start\n\n### Step 1: Save Your First Profile\n\nStart Gemini CLI and save your current OAuth session:\n\n```\n> save my profile as work\n╭─────────────────────────────────────────────────────────────────╮\n│ ✓  account_save (accountSwitcher MCP Server) {\"name\":\"work\"}    │\n│                                                                 │\n│ ✓ Saved profile \"work\".                                         │\n╰─────────────────────────────────────────────────────────────────╯\n```\n\n### Step 2: Add Another Account\n\n```\n> add another account\n\n╭─────────────────────────────────────────────────────────────────╮\n│ ✓  account_add (accountSwitcher MCP Server) {\"name\":\"work\"}     │\n│                                                                 │\n│ ✓ Updated profile \"work\".                                       │\n│                                                                 │\n│ NEXT STEPS TO ADD ANOTHER ACCOUNT:                              │\n│ ───────────────────────────────────                             │\n│ 1. Run: /auth logout                                            │\n│ 2. Run: /auth login (choose a different Google account)         │\n│ 3. Run: account_save with the new profile name                  │\n╰─────────────────────────────────────────────────────────────────╯\n```\n\nThen run `/auth login`, authenticate with a different Google account, and save it:\n\n```\n> save my profile as personal\n╭─────────────────────────────────────────────────────────────────╮\n│ ✓  account_save (accountSwitcher MCP Server) {\"name\":\"personal\"}│\n│                                                                 │\n│ ✓ Saved profile \"personal\".                                     │\n╰─────────────────────────────────────────────────────────────────╯\n```\n\n### Step 3: List Your Profiles\n\n```\n> list my profiles\n\n╭─────────────────────────────────────────────────────────────────╮\n│ ✓  account_list (accountSwitcher MCP Server) {}                 │\n│                                                                 │\n│ SAVED PROFILES                                                  │\n│ ────────────────────────────────────────                        │\n│ • personal ● active                                             │\n│ • work                                                          │\n╰─────────────────────────────────────────────────────────────────╯\n```\n\n### Step 4: Switch Between Accounts\n\n```\n> switch to work\n\n╭─────────────────────────────────────────────────────────────────╮\n│ ✓  account_switch (accountSwitcher MCP Server) {\"name\":\"work\"}  │\n│                                                                 │\n│ ✓ Switched to profile \"work\".                                   │\n│                                                                 │\n│ ⚠️  Restart required: Type /quit then run 'gemini' again.       │\n╰─────────────────────────────────────────────────────────────────╯\n```\n\n**Important:** After switching, type `/quit` and restart `gemini` for the change to take effect.\n\n## 📖 Available MCP Tools\n\n| Tool             | Description                                              | Example Prompts                    |\n| ---------------- | -------------------------------------------------------- | ---------------------------------- |\n| `account_list`   | Show all saved profiles                                  | \"list my profiles\", \"show accounts\"|\n| `account_save`   | Save current login as a profile                          | \"save as work\", \"save profile dev\" |\n| `account_switch` | Switch to a saved profile                                | \"switch to personal\", \"use work\"   |\n| `account_delete` | Remove a saved profile                                   | \"delete profile test\"              |\n| `account_current`| Show active profile                                      | \"which account?\", \"current profile\"|\n| `account_add`    | Save current session and get instructions for adding more| \"add another account\"              |\n\n### Profile Name Rules\n\n- Must start with a letter\n- Can contain letters, numbers, hyphens (`-`), and underscores (`_`)\n- Length: 1-32 characters\n- **No dots allowed** (e.g., `kranthi.work` is invalid, use `kranthi-work` instead)\n\n## 🔒 Security\n\n### How Credentials Are Stored\n\n```\n~/.gemini/\n├── oauth_creds.json          # Active credentials (used by Gemini CLI)\n└── accounts/\n    ├── .current_profile      # Tracks active profile name\n    ├── work/\n    │   └── oauth_creds.json  # Saved profile credentials\n    └── personal/\n        └── oauth_creds.json\n```\n\n### Security Measures\n\n| Protection                   | Implementation                                  |\n| ---------------------------- | ----------------------------------------------- |\n| **File Permissions**         | All credential files use `0600` (owner only)    |\n| **Directory Permissions**    | Account directories use `0700`                  |\n| **Profile Validation**       | Names must match `^[a-zA-Z][a-zA-Z0-9_-]{0,31}$`|\n| **Reserved Names Blocked**   | `.`, `..`, `con`, `prn`, `aux`, `nul`           |\n| **Backup Rotation**          | Keeps only last 5 backups                       |\n\n## 📁 Project Structure\n\n```\nGemini-Account-Switcher/\n├── src/\n│   ├── server.ts           # MCP server exposing account tools\n│   ├── cli.ts              # Standalone CLI entry point\n│   ├── profiles.ts         # Profile CRUD operations\n│   └── utils.ts            # File system utilities and validation\n├── dist/                   # Pre-built JavaScript (bundled with esbuild)\n├── gemini-extension.json   # Extension manifest with MCP config\n├── GEMINI.md               # Context file for Gemini CLI\n├── package.json            # Node.js package configuration\n├── tsconfig.json           # TypeScript configuration\n└── LICENSE                 # Apache-2.0 License\n```\n\n## 🔧 Automation Integration\n\n### Quota Rotation Example (Python)\n\n```python\nimport subprocess\n\ndef switch_gemini_account(profile_name):\n    \"\"\"Switch Gemini CLI to a different OAuth profile.\"\"\"\n    result = subprocess.run(\n        [\"node\", \"path/to/dist/cli.js\", \"switch\", profile_name],\n        capture_output=True,\n        text=True\n    )\n    return result.returncode == 0\n\ndef handle_quota_exhausted():\n    \"\"\"Called when Gemini API returns quota exceeded error.\"\"\"\n    accounts = [\"account1\", \"account2\", \"account3\"]\n    current = get_current_account()  # Your tracking logic\n    \n    next_idx = (accounts.index(current) + 1) % len(accounts)\n    next_account = accounts[next_idx]\n    \n    if switch_gemini_account(next_account):\n        print(f\"Switched to {next_account}, restarting Gemini CLI...\")\n        restart_gemini_cli()\n```\n\n### Standalone CLI (Alternative)\n\nYou can also use the CLI directly without MCP:\n\n```bash\n# List profiles\nnode dist/cli.js list\n\n# Save current session\nnode dist/cli.js save work\n\n# Switch account\nnode dist/cli.js switch personal\n\n# Show current profile\nnode dist/cli.js current\n\n# Delete profile\nnode dist/cli.js delete old-account\n\n# Show help\nnode dist/cli.js help\n```\n\n## 🛠️ Development\n\n### Prerequisites\n\n- Node.js 18+\n- npm\n\n### Setup\n\n```bash\n# Clone the repository\ngit clone https://github.com/kranthik123/Gemini-Account-Switcher.git\ncd Gemini-Account-Switcher\n\n# Install dependencies\nnpm install\n\n# Build (TypeScript + esbuild bundle)\nnpm run build\n\n# Link for local development\ngemini extensions link .\n```\n\n### Available Scripts\n\n| Script           | Description                                      |\n| ---------------- | ------------------------------------------------ |\n| `npm run build`  | Compile TypeScript and bundle with esbuild       |\n| `npm run watch`  | Watch mode for TypeScript development            |\n| `npm run clean`  | Remove dist folder                               |\n| `npm run rebuild`| Clean + build                                    |\n\n### Tech Stack\n\n- **TypeScript** — Type-safe development\n- **esbuild** — Fast bundling with zero runtime dependencies\n- **Node.js 18+** — Runtime environment\n- **MCP SDK** — Model Context Protocol integration\n- **ES Modules** — Modern JavaScript modules\n\n## ⚠️ Important Notes\n\n1. **Restart Required**: After switching profiles, restart Gemini CLI (`/quit` then `gemini`)\n2. **Credential Validity**: Saved credentials may expire. If authentication fails, re-login and save again.\n3. **Terms of Service**: This tool manages your own legitimate OAuth credentials. Ensure compliance with Google's ToS.\n\n## 🤝 Contributing\n\nContributions are welcome! Please:\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## 🙏 Acknowledgments\n\n- [Gemini CLI](https://github.com/google-gemini/gemini-cli) — The CLI this extension enhances\n- [Model Context Protocol](https://modelcontextprotocol.io/) — The protocol powering the integration\n\n## 📚 Resources\n\n- [Gemini CLI Documentation](https://geminicli.com/)\n- [MCP Protocol](https://modelcontextprotocol.io/)\n- [Building Gemini Extensions](https://geminicli.com/docs/extensions/getting-started-extensions/)\n\n## 📜 License\n\nApache-2.0 License — see [LICENSE](LICENSE) file.\n\n---\n\n> **Disclaimer**: This extension is for educational and personal use. Always use responsibly and respect API rate limits and terms of service.\n\nMade with ❤️ by [Kranthi Kavuri](https://github.com/kranthik123)\n",
  "bytes": 11481,
  "sha": "d9ee9e4d3989bb269788c920df800e2d1cb61ea44203b6ac762b7b49d21bbcd5",
  "repo_slug": "kranthik123/gemini-account-switcher",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/plg_kranthik123_gemini_account_switcher_c662357e/readme"
}