Remote PC MCP Gateway
by dqIndieGames
README.md
# Remote PC MCP Gateway (ChatGPT & Google Gemini)
English | **[简体中文文档 (README.zh-CN.md)](./README.zh-CN.md)**
Connect **ChatGPT Web** and **Google Gemini Web** to files and commands on your **Windows 10/11 PC** through an OAuth 2.1 authenticated **Model Context Protocol (MCP)** gateway. A native bilingual wizard guides setup. Choose **Cloudflare Tunnel** for a first try, or a **Linux VPS** for a stable public endpoint. This project's execution host is Windows; a Mac is not required.
**Start here:** Check [Gemini account requirements](#visual-guide-1-connecting-google-gemini-web-geminigooglecom), then follow the [Windows quick start](#windows-quick-start). Choose one ingress mode and run one gateway instance. Keep the target Windows PC awake with the gateway running; it does not automatically open, sign in to, or connect Gemini.

---
## Key Highlights
- **Dual-Client Concurrent Access (`ChatGPT` + `Google Gemini`)**: Connect both ChatGPT Web and Google Gemini Web to the exact same HTTPS MCP URL at the same time. Full **OAuth 2.1 + PKCE (`S256`) + Dynamic Client Registration (`/oauth/register`)** + MCP tool safety annotations (`readOnlyHint` / `destructiveHint`) work out of the box with **zero manual Client IDs or Client Secrets**.
- **Three Flexible Public HTTPS Ingress Options (Switchable Anytime)**:
- **Mode A1 — Cloudflare Quick Tunnel (No VPS or Account)**: Starts `cloudflared`, captures a temporary `https://*.trycloudflare.com` origin, and aligns `OAUTH_ISSUER`. Detects `198.18.0.0/15` Clash/Mihomo/Sing-box TUN Fake-IP to select QUIC + Cloudflare Anycast Edge IPs. Other network failures can still cause `Error 1033`.
- **Mode A2 — Cloudflare Named Tunnel (No VPS)**: Enter an existing Cloudflare tunnel's hostname and token in Step 1. The URL stays the same while that hostname and tunnel configuration are retained.
- **Mode B — Linux VPS (`Ubuntu/Debian`)**: Automates provisioning through `deploy/deploy-to-vps.ps1` and `deploy/install-vps.sh`. Standard installation changes shared server configuration; an existing production VPS needs the isolated setup described below. Supports your own domain or `mcp.<ip>.sslip.io` HTTPS, subject to DNS reachability and certificate issuance.
- **Zero-Port Native Windows Client + System Tray**: Double-click `Start-GUI.bat` for a clean bilingual (`EN / 中文`) Setup Wizard, live 5-service health strip, auto-generated persistent credentials (masked by default for screen sharing), folder list management, arrow-key wraparound navigation, and a right-click **System Tray (`NotifyIcon`)** menu.
- **Access Controls and Process Supervision**:
- **Strict `allowedRoots` Path Sandbox**: Every `fs_*` (with cross-platform `..` traversal normalization and fast `rg --files` pruning) and read-only `git_*` call is strictly confined to your approved workspace folders.
- **Per-Tab Shared Chrome Isolation (`pageId`)**: Reuses your existing `--remote-debugging-port=9222` Chrome while patching `chrome-devtools-mcp@1.5.0` so cloud sessions must target explicit `pageId` tabs without touching your personal tabs.
- **Native Job Object Process-Tree Supervision (`WorkbenchJob.exe`) & Auto-Review**: PowerShell 7 commands (`run_command`) execute inside a Win32 Job Object (`KILL_ON_JOB_CLOSE`) with zero orphan child processes on timeout, and cleanly exiting commands auto-review (`review_required: false`).
- **Mandatory Two-Step Delete Guard Hook (Default ON)**: Built-in `windows/ai-workbench/delete-guard.ps1` pauses destructive commands (`rm -rf`, `Remove-Item -Recurse`, `git reset --hard`, etc.) on the first attempt for verification, allowing a single exact resend within 10 minutes.
- **Gemini Web Image Bridge Protection & Pluggable `inspect_image`**: Protects Google Gemini Web from stripped `{}` media blocks by requiring `filePath` on screenshots and offering an opt-in `inspect_image` multimodal verifier (`gemini-api`, `openai-api`, or `cli-auto`).
**Permission boundary:** `allowedRoots` restricts filesystem tools and command working directories. PowerShell commands still run with the Windows account's permissions and can access paths outside that list. Job Objects supervise processes; they are not a filesystem sandbox. Review command requests and keep MCP URLs and Approval Keys private.
---
## Which Public HTTPS Ingress Mode Should You Pick?
| Feature | Mode A1: Cloudflare Quick Tunnel (Default) | Mode A2: Cloudflare Named Tunnel | Mode B: Self-Hosted Linux VPS |
| :--- | :--- | :--- | :--- |
| **VPS or Domain Needed?** | **None** (100% free, no account) | No VPS (uses free Cloudflare Tunnel + domain) | Ubuntu/Debian VPS (**No domain needed** — auto `sslip.io` TLS) |
| **Setup Work** | First run downloads and builds dependencies; duration depends on network | Also create a Cloudflare tunnel and configure its hostname | Also prepare SSH access, ports and HTTPS; certificate issuance takes time |
| **Same URL Across Restarts?** | New random `*.trycloudflare.com` when the tunnel restarts; reconnect the app | Yes, while hostname and tunnel settings are retained | Yes, while hostname/IP, port and gateway configuration are retained |
| **TUN / Fake-IP Proxy Support** | Auto-detects `198.18.0.0/15` & bypasses Fake-IP | Auto-detects `198.18.0.0/15` & bypasses Fake-IP | Auto-reconnecting SSH `-R` reverse tunnel |
| **Best For** | First test and temporary demos | Stable URL without a Linux server | Ongoing use with a server you administer |
---
## Architecture Overview
```text
OpenAI ChatGPT Web ──┐
├──► HTTPS + OAuth 2.1 (PKCE S256 + Dynamic Client Registration)
Google Gemini Web ──┘ │
┌───────────────────────────┴───────────────────────────┐
▼ Mode A: Serverless Cloudflare Tunnel ▼ Mode B: 1-Click Linux VPS
[Quick *.trycloudflare.com / Named Fixed Domain] [Ubuntu/Debian VPS: Caddy HTTPS ingress]
│ Encrypted QUIC Tunnel (TUN Fake-IP Safe) │ Gateway (:8787) + SSH -R Tunnel
▼ ▼
┌─────────────────────────────────────────────────────────────────────────────────────┐
│ Your Windows 10 / 11 Workstation │
│ Start-GUI.bat (Native WinForms Wizard + Dashboard + System Tray · 0 Admin Ports) │
│ ├── Filesystem MCP Supervisor + Bearer Proxy (fs_* / git_* · allowedRoots) │
│ ├── Shared Chrome MCP Gateway (1.5.0 Patched) (chrome_* · strict pageId routing) │
│ └── AI Workbench + Native WorkbenchJob.exe (run_command · Win32 Job Object) │
└─────────────────────────────────────────────────────────────────────────────────────┘
```
---
## Prerequisites (Windows 10 / 11)
| Component | Requirement | Notes |
| :--- | :--- | :--- |
| **Node.js** | `>= 20.0` (22 LTS recommended) | Install from [nodejs.org](https://nodejs.org/en/download); include npm and add to PATH |
| **PowerShell 7** | `pwsh.exe` | Install using [Microsoft's Windows instructions](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows); enable PATH integration. Windows PowerShell 5.1 alone is insufficient |
| **.NET SDK** | `.NET 8.0` | Setup reuses an installed 8.x SDK or installs it in project-local `tools/dotnet`, then builds `WorkbenchJob.exe`; system PATH is unchanged |
| **OpenSSH Client** | `ssh.exe`, `scp.exe`, `ssh-keygen.exe` | Mode B only; install the Windows Optional Feature if absent, and prepare a key already authorized on the VPS |
| **Cloudflared** | Downloaded during setup | `npm run setup` downloads it to project-local `tools/cloudflared.exe` for Cloudflare mode |
| **Google Chrome** | Optional (`chrome_*` tools) | Launch Chrome with `--remote-debugging-port=9222` to share browser access |
---
## Windows Quick Start
### Step 1 — Download and Extract
Install Node.js and PowerShell 7 from the links above. On the [GitHub repository](https://github.com/dqIndieGames/remote-pc-mcp-gateway), click **Code → Download ZIP**, then **Extract All** in Explorer. Open the extracted folder containing `Start-GUI.bat`; do not launch from inside the ZIP. Git is not required for this route.
If you already use Git, this is an alternative:
```powershell
git clone https://github.com/dqIndieGames/remote-pc-mcp-gateway.git
cd remote-pc-mcp-gateway
npm run setup
```
> **Automatic setup:** Clicking **Start** or **⚙ Install & Build** runs setup when dependencies are missing. Setup downloads packages, a project-local .NET 8 SDK if needed, and Cloudflared, then builds the command helper. Wait for completion in the log. First installation has no fixed completion time.
### Step 2 — Double-Click `Start-GUI.bat`
Double-click `Start-GUI.bat` in Explorer. On first launch, the **Setup Wizard** opens automatically:

*The wizard and dashboard images use an isolated example configuration in the real Windows app. They illustrate the controls, not a live connection. Enter your own values and verify the file read below.*
1. **1. Ingress & Server**:
- **Recommended first test — Cloudflare Quick**: Keep **Serverless Cloudflare Tunnel** selected and leave Named Tunnel Hostname and Token empty. No VPS is required.
- **VPS alternative**: Use **Self-Hosted Linux VPS Mode** only after preparing SSH key access. Enter host, SSH port and user, then select the authorized private key. A blank domain uses `mcp.<ip>.sslip.io`. Read the Mode B section before deploying to a server with existing services.
2. **2. Folders, Guard & Alerts**: Create a new empty `MCP-Demo` folder in your Windows Documents folder. Add its full path with **`+ Add Folder`**, removing sample paths you do not use. Keep the Delete Guard enabled. Leave Chrome automation, notifications and vision disabled for the first file/command test; these are optional features.
3. **3. Check & One-Click Start**:
- Click **⚡ One-Click Initialize & Start** for Cloudflare mode, **or**
- Click **🚀 One-Click Deploy to VPS & Start** to provision your Linux VPS, issue TLS certificates, sync generated secrets back to `config/config.local.json`, and start the enabled local services.
### Step 3 — Copy Your Masked Credentials from the Dashboard
Once the status pill turns green (**`● Running · Public HTTPS Ready`**) and all enabled service cards are green (the Chrome card stays gray when disabled), use **Copy MCP URL** and **Copy Approval Key** when the web setup asks for each value. The key persists in local configuration; a Quick Tunnel's hostname changes when the tunnel restarts.
Continue with the Gemini guide below. The control panel is the gateway, not the Gemini browser. Open Gemini yourself on the computer where you want to chat; tools run on the Windows PC hosting this gateway. For a complete test on that same PC, open its browser there and leave the tested conversation available for review. Keep Windows and the gateway running. Closing the panel sends it to the tray; use **Stop** to stop services.
---
## Visual Guide 1: Connecting Google Gemini Web (`gemini.google.com`)
**Scope and prerequisites (checked on November 14, 2026)**
The local execution stack targets Windows 10/11. Linux VPS mode hosts the public gateway. In the [LINUX DO discussion](https://linux.do/t/topic/3177742/4), “Mac-only” replies to the preceding claim that the Gemini desktop app can operate local files and includes Antigravity. Google documents [native Mac file tasks](https://support.google.com/gemini/answer/17208717) and [Antigravity integrated into the Mac app](https://support.google.com/gemini/answer/18755601) separately from [Gemini for Windows](https://support.google.com/gemini/answer/18263854). This project's Windows tools connect through **Gemini Web → custom app → HTTPS MCP**. They do not provide the native Mac interface or replace all Antigravity features.
Before installing, check whether your Gemini account shows **Settings → Connected Apps → Custom apps**. Google's published requirements include being in the US, age 18+, a personal account, Keep Activity enabled and English availability. Tasks require Pro or Ultra; the current model table lists Carbon under Ultra. Missing entries can reflect account or feature eligibility, and installing the gateway does not unlock them. Check the official [custom app requirements](https://support.google.com/gemini/answer/17209137), [Task requirements](https://support.google.com/gemini/answer/17094507), and [model table](https://support.google.com/gemini/answer/18648722).
This gateway does not increase subscription limits. Gemini remains subject to [usage limits](https://support.google.com/gemini/answer/16275805), including applicable five-hour and weekly allowances. Optional `inspect_image` uses the configured API or local CLI and returns a textual inspection; it does not deliver the original image directly to the web model. Check that backend's separate usage limits and charges.
Button labels can vary by account and interface version; use the steps below with your live page.

*Actual form captured on November 14, 2026. Only the form is shown; account details and connection secrets are excluded. Additional settings is expanded to show the Client ID/Secret fields that this gateway can leave empty. The disabled Next button reflects an empty form, not a successful connection.*
1. **Open Connected Apps**: In Gemini Web, open **Settings → Connected Apps**, or **Personal Intelligence → Connected Apps** if shown. Use Connected Apps for normal setup. `https://gemini.google.com/devmode` is a separate developer workspace for inspecting requests and schemas.
2. **Add a custom app**: Under **Custom apps**, use the add-link field or **Add a custom app / Create custom app** button. Some layouts label it **`+ Custom`**; follow the form shown in your account.
3. **Paste MCP Server URL (This Project Supports DCR)**: Paste your full **MCP Server URL** (`https://<your-tunnel-or-domain>/<secret>/mcp`), leave manual OAuth Client ID and Client Secret blank, and click **Next** to use Dynamic Client Registration. Google also supports manual registration; DCR is not the platform's only registration option.
4. **Approve with Owner Approval Key**: On your gateway's OAuth 2.1 consent card, paste your **Owner Approval Key** and click **Approve & Connect Google Gemini**:

5. **Select the app and verify a tool call**: After connecting, type `@` and select your custom app. Prefer **Task** for multi-step execution; Google also supports custom apps in **Chat**. Start by reading a test file inside an allowed folder and confirm the returned content matches the tool log. If the app is connected but unused, check account eligibility, app selection, OAuth, and tool logs.
### Verify That It Operates the Intended Windows PC
1. In the allowed `MCP-Demo` folder, use Notepad to save `input.txt` containing a unique line of your choice. Enable **View → Show → File name extensions** in Explorer to check the exact filename. Do not paste that line into Gemini.
2. Select your custom app with `@`, replace `<TEST_FOLDER>` below with its full Windows path, and send this in **Chat**:
```text
Use the selected custom app to read <TEST_FOLDER>\input.txt from the Windows PC. Return its exact contents and the tool result. Do not write or delete anything. If the tool is unavailable, report that instead of guessing.
```
3. For the command/write test, switch to **Task** if available, select the same app, and send this after replacing `<TEST_FOLDER>`:
```text
Use only the selected custom app. Read <TEST_FOLDER>\input.txt. Run hostname and $PSVersionTable.PSVersion.ToString() on the connected Windows PC, with <TEST_FOLDER> as cwd. Create result.txt in that folder containing the input text, hostname and PowerShell version, then read it back. If result.txt already exists, stop without overwriting it. Do not change other files, settings or services. Report the actual tool results and any failed step.
```
4. On the target Windows PC, open `result.txt` and compare it with the tool output. Check the hostname against **Settings → System → About → Device name**, and confirm PowerShell reports major version 7. A green panel or an “I completed it” message alone is insufficient. Keep the conversation and test files for review, then delete only those test files when finished.
**Verification scope:** Deployment/API checks, Gemini Web tool calls, and a Gemini browser session on the target PC are separate checks. Testing from another computer proves remote access; it does not prove the target PC's browser flow was tested.
---
## Guide 2: Connecting OpenAI ChatGPT Web (`chatgpt.com`)
The current [official connection guide](https://developers.openai.com/plugins/deploy/connect-chatgpt) uses **Plugins → Add custom MCP server**, replacing the old Connectors/Developer Mode instructions. Account and workspace policies still apply. The entry and form were opened in the real website on November 14, 2026; this form screenshot does not establish end-to-end ChatGPT tool execution.

*Actual empty form, with OAuth selected. Account details and connection secrets are excluded. Follow the numbered steps below to enter your own values and complete authorization.*
1. **Open Plugins**: Sign in at [ChatGPT Plugins](https://chatgpt.com/plugins), select the **plus** button, then **Add custom MCP server**.
2. **Fill in the connection**:
- **Name**: `My Windows PC`
- **Connection / Server URL**: Paste the full HTTPS MCP URL from the Windows panel, including the secret path and `/mcp`.
- **Authentication**: Select **OAuth**. This project provides Dynamic Client Registration (DCR); leave manual Client ID/Secret empty and choose DCR if the form asks for a registration method.
3. **Create and authorize**: Review the displayed warning, select **I understand and want to continue**, then **Create as a plugin**. When the gateway consent page appears, enter its **Approval Key** and authorize. Check the discovered tools.
4. **Install and select**: Install the resulting plugin. In a new conversation, type `@` and select **My Windows PC**.
5. **Verify a file read**: Use the read-only `input.txt` prompt above and compare the actual tool output with the file on Windows. Missing creation/install controls can reflect workspace restrictions; gateway installation does not override them.
---
## Mode B: CLI One-Click Linux VPS Deployment & Management
For a fresh or dedicated Ubuntu/Debian VPS, the standard deployment command is:
```powershell
pwsh -File .\deploy\deploy-to-vps.ps1 `
-VpsHost 203.0.113.10 `
-VpsUser root `
-AllowedRoot "D:\Workspace\MyWebApp"
```
- **SSH access must already work**: Select a private key authorized for the VPS user. With no configured key, the script checks `~/.ssh/id_ed25519` and `~/.ssh/id_rsa`; if neither exists, it generates a key under `~/.ssh/remote-pc-mcp/` and stops with instructions to install its public key in the VPS user's `authorized_keys`. A missing explicitly configured key is an error. Deployment uses noninteractive SSH (`BatchMode=yes`); key generation alone does not grant server access.
- **Shared versus isolated installation**: Standard deployment changes shared Caddy configuration and may adjust SSH, systemd and ufw. For a VPS with existing services, first set distinct `destRoot`, `gatewayPort`, `httpPort`, `httpsPort`, `remoteFsPort`, `remoteChromeMcpPort` and `remoteWorkbenchPort` values under `vps` in `config/config.local.json`, then use the wizard deployment button. Isolated mode requires existing Node.js, npm and Caddy, and uses its own configuration, state and processes without modifying shared services. Set `tlsCertPath` and `tlsKeyPath` to reuse an existing certificate read-only. Isolated helpers live under `<destRoot>/usr/local/sbin/`; its uninstall helper stops only this instance and retains files.
- **Built-In Remote Server Helpers** (run on your VPS via SSH):
- Check gateway & TLS health: `sudo mcp-gateway-status`
- Cleanly uninstall gateway while keeping existing Caddy sites intact: `sudo mcp-gateway-uninstall`
---
## Shared Chrome Tab Mover Extension (Optional)
To allow `chrome_move_pages_to_new_window` to move AI-created test tabs into an unfocused background Chrome window without stealing focus:
1. Open `chrome://extensions` in your `--remote-debugging-port=9222` Chrome.
2. Enable **Developer mode** → click **Load unpacked** → select `windows/chrome-mcp/chrome-tab-mover-extension`.
---
## Troubleshooting & FAQ
| Symptom / Question | Root Cause | 1-Step Fix |
| :--- | :--- | :--- |
| **Gemini is connected but does not call my tools?** | Check account eligibility, app selection, authorization, and tool discovery; mode alone does not identify the cause | Select the app with `@` and read a test file. Use Task for multi-step work, then inspect OAuth, tools/list, and tools/call logs if needed |
| **Clash / Mihomo / Sing-box TUN mode causes Cloudflare `Error 1033`?** | TUN Fake-IP (`198.18.0.0/15`) intercepts default UDP/HTTP2 tunnel DNS | Launch via `Start-GUI.bat` or `stack-manager.mjs` — it auto-detects Fake-IP and forces QUIC + Cloudflare Anycast Edge IPs |
| **Quick Tunnel URL stopped working after restarting my PC?** | A new tunnel run gets a new random `*.trycloudflare.com` hostname | Copy the new full MCP URL and reconnect the custom app (remove/recreate it if URL editing is unavailable). Named Tunnel or VPS can retain a stable address |
| **Why is Gemini not open, or why are there two gateway panels?** | The panel does not launch Gemini; separate gateway copies can each have a panel | Open Gemini in your intended browser. A normal setup needs one ingress mode and one instance; two instances are not required to use ChatGPT and Gemini together |
| **Why did `rm -rf` or `Remove-Item -Recurse` pause on the first try?** | The built-in 2-Step Delete Guard (`delete-guard.ps1`) paused a destructive command | Verify the command is safe, then resend the exact same command within 10 minutes to approve once |
| **How does `inspect_image` inspect local screenshots?** | The configured multimodal backend reads the image and returns a textual analysis | Select `gemini-api`, `openai-api`, or `cli-auto` in Wizard Step 2 and check its credentials, limits, and charges. The web model receives the analysis text |
---
## Automated Tests & Secret Scanning
```powershell
# Run OAuth 2.1 dual-platform, tool annotations, Fake-IP tunnel, Workbench & VPS dry-run unit tests
npm test
# Scan the entire repository for leaked IPs, private keys, emails, tokens, or personal paths (0 hits)
npm run scan:secrets
```
---
## Community & Acknowledgments
Thanks to the [LINUX DO](https://linux.do/) community for feedback and open-source support.
---
## License
Released under the [MIT License](./LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues