Skip to main content
Glama
README.md
# Gemini Web → PC Agent (Windows)

An **MCP (Model Context Protocol) server + offline-first Local Admin Dashboard** that lets **Gemini Web** (`gemini.google.com`) safely control your Windows PC: run shell commands, edit files, inspect Windows UI, automate browsers, manage Git repositories, and bridge external MCP servers — all protected by granular security guardrails.

```
Gemini Web (gemini.google.com)                 Your Browser (localhost ONLY)
        │  HTTPS + Shared Secret                       │  http://127.0.0.1:8768
        ▼                                              ▼
Tailscale Funnel / Serve (or Cloudflare)       Local Admin Dashboard (admin.py)
        │  → http://127.0.0.1:8767                     │  (admin-token.txt + CSRF + TOTP)
        ▼                                              │
WindowsPCAgent (server.py — 54+ MCP tools) ◄── config.json ──► watchdog.py
        │                                                       (auto-restart + scheduler)
        ▼
Windows 10/11 Desktop Session + External MCP Hub (mcp_servers.json)
```

---

## Key Features

- **54 Built-in MCP Tools + 3 Resources + 2 Prompts**:
  - **Shell & Background Jobs**: `run_command` (PowerShell/cmd), `start_job`, `get_job_output`, `list_jobs`, `stop_job`
  - **Files & Images**: `read_file` (line ranges + mtime cache), `edit_file` (partial patch), `write_file`, `read_image`, `list_directory`, `search_files`, `delete_path`, `move_path`
  - **Screen & Windows UI Automation**: `take_screenshot` (multi-monitor, region, window, coordinate grid overlay, JPEG/resize), `get_screen_info`, `inspect_ui`, `click_element`
  - **Mouse, Keyboard & Window Control**: `mouse_*`, `type_text`, `press_key`, `clipboard`, `clipboard_history`, `clipboard_image`, `list_windows`, `focus_window`, `close_window`, `wait_for_window`, `sleep_seconds`, `resize_move_window`, `set_window_state`
  - **Browser Automation (Playwright)**: `browser_open`, `browser_click`, `browser_type`, `browser_read`, `browser_screenshot`, `browser_close`
  - **Git & System Power**: `git_status`, `git_diff`, `git_branch`, `git_commit`, `get_system_info`, `list_processes`, `kill_process`, `open_application`, `prevent_sleep`, `get_battery_info`, `set_volume`, `lock_screen`
  - **Productivity**: `notify_user` (Windows Toast / ntfy), `memory_read`, `memory_write`
  - **MCP Resources**: `pc://system/summary`, `pc://memory`, `pc://logs/recent`
  - **MCP Prompts**: `daily_health_check`, `safe_workspace_cleanup`
- **Multi-App External MCP Hub**: Connect other MCP servers (`stdio`, `http`, or `sse` — e.g., Obsidian, Notion, Blender, SQLite) from the Dashboard and expose them through the same Gemini endpoint (`<server_id>__<tool>`).
- **Granular Security & Control**:
  - **Access Scope Modes**: `Full Access`, `Project Folders Only`, `Apps Only`, or `Project + Apps` (hot-reload).
  - **Per-Tool Policies**: `allow` / `ask` / `deny` (denied tools are dynamically hidden from `list_tools`).
  - **Live Approval Queue**: Tools set to `ask` pause and show an impact card in the Dashboard for 1-click Approve/Deny.
  - **Undo Stack + Diff Viewer**: Automatic snapshots before `write_file`/`edit_file`/`delete_path`/`move_path` with 1-click restore.
  - **Hardening**: Separate MCP & Admin tokens, constant-time verification, CSRF protection, optional TOTP 2FA, sliding-window rate limiter, command regex denylist, stdout secret redaction, and **Emergency Kill**.
- **Offline-First Local Admin Dashboard (`http://127.0.0.1:8768`)**: Zero npm/CDN dependencies, SSE live status & audit log stream, CPU/RAM/Disk sparklines, Windows Autostart ON/OFF toggle, screenshot gallery, prompt library, persistent `memory.md` editor, and local scheduled tasks.

---

## Quick Start (Windows 10/11)

### Prerequisites
- **Windows 10/11** (interactive logged-in desktop session required for GUI tools)
- **Python 3.11 – 3.14**
- **Tailscale** (recommended — gives a free, permanent `https://<your-host>.ts.net` URL) or **cloudflared** (temporary URL)

### 1. Tailscale One-Time Setup (Recommended for Permanent URL)
If you want a permanent HTTPS URL that never changes across restarts:
1. **Install & Sign In**: Download Tailscale for Windows from https://tailscale.com/download/windows and sign in from the system tray icon.
2. **Enable MagicDNS & HTTPS Certificates**: Open the [Tailscale Admin Console → DNS](https://login.tailscale.com/admin/dns), ensure **MagicDNS** is **ON**, then scroll down and click **Enable HTTPS**.
3. **Enable Funnel (one-time)**: Run once in PowerShell:
   ```powershell
   tailscale funnel --bg 8767
   ```
   If Funnel is not enabled on your tailnet yet, Tailscale will print an approval link — open it in your browser and click **Enable Funnel**.
   > Want private tailnet-only access instead of public Funnel? Switch `tunnel.expose` to `"private"` in the Dashboard **Settings** tab (uses `tailscale serve`).

### 2. Download & Run Setup
```powershell
git clone https://github.com/AmajinXLab/gemini-pc-agent.git
cd gemini-pc-agent
powershell -ExecutionPolicy Bypass -File .\setup.ps1
```
`setup.ps1` automatically creates an isolated `.venv` (pinning `mcp==1.30.0`), installs all dependencies, copies `config.example.json` → `config.json`, and generates `secret-token.txt` & `admin-token.txt` with user-only ACLs.

### 3. Start the Agent
```powershell
powershell -ExecutionPolicy Bypass -File .\start.ps1 -Mode tailscale
```
Other modes:
```powershell
powershell -ExecutionPolicy Bypass -File .\start.ps1 -Mode cloudflare  # temporary trycloudflare URL
powershell -ExecutionPolicy Bypass -File .\start.ps1 -Mode none        # local only (127.0.0.1:8767)
```
Your full MCP URL (`https://<your-host>.ts.net/<TOKEN>/mcp`) is saved to `public-url.txt` and copied to your clipboard automatically.

### 4. Open Local Admin Dashboard
Open **`http://127.0.0.1:8768`** in your browser and log in with the token in `admin-token.txt`.
From here you can toggle **Windows Autostart (ON/OFF)**, set **Access Scope** (`Full` / `Project Folders` / `Apps Only` / `Project + Apps`), configure tool policies, approve `ask` requests, connect external MCP apps, and monitor live logs.

### 5. Connect to Gemini Web
1. Open `gemini.google.com` → **Settings** → **Connected Apps** → **Custom apps** → **Add a custom app**.
2. Paste your MCP URL: `https://<your-host>.ts.net/<TOKEN>/mcp`
3. Approve the connection — Gemini can now see and invoke your enabled PC tools.

---

## Useful Commands

| Command | Description |
|---|---|
| `powershell -ExecutionPolicy Bypass -File .\start.ps1` | Start / restart agent using `config.json` |
| `powershell -ExecutionPolicy Bypass -File .\start.ps1 -Status` | Check Watchdog, MCP, Admin & Public health |
| `powershell -ExecutionPolicy Bypass -File .\start.ps1 -Stop` | Stop MCP server, Admin Dashboard, Watchdog & tunnel |
| `powershell -ExecutionPolicy Bypass -File .\new-token.ps1 -Force` | Rotate MCP `secret-token.txt` |
| `powershell -ExecutionPolicy Bypass -File .\new-token.ps1 -Admin -Force` | Rotate Dashboard `admin-token.txt` |
| `powershell -ExecutionPolicy Bypass -File .\install-shortcuts.ps1` | Create Desktop & Start Menu shortcuts |

## Verification Tests

```powershell
.\.venv\Scripts\python.exe .\tests\test_auth.py https://<your-host>.ts.net (Get-Content .\secret-token.txt -Raw).Trim()
.\.venv\Scripts\python.exe .\tests\test_tools.py (Get-Content .\public-url.txt -Raw).Trim()
.\.venv\Scripts\python.exe .\tests\test_guardrails.py
.\.venv\Scripts\python.exe .\tests\test_phase3.py
.\.venv\Scripts\python.exe .\tests\test_phase4.py
.\.venv\Scripts\python.exe .\tests\test_phase5.py
.\.venv\Scripts\python.exe .\tests\test_phase6a.py
.\.venv\Scripts\python.exe .\tests\test_phase6b.py
```

## Security Notice

Read [SECURITY.md](SECURITY.md) before exposing your endpoint. Never commit `secret-token.txt`, `admin-token.txt`, `admin-totp.txt`, `public-url.txt`, or `config.json`.

## License

MIT — see [LICENSE](LICENSE).