gemini-local-coder-mcp
by KlLLHunter
README.md
# gemini-local-coder-mcp
Local Streamable HTTP MCP server in TypeScript that exposes sandboxed filesystem, search, git, and shell tools to remote MCP clients (such as Google Gemini Custom Connectors) over a Cloudflare Tunnel.
```text
Remote MCP client (e.g. Gemini Custom Connector)
-> HTTPS (OAuth 2.1 + PIN, or path-token)
-> Cloudflare Tunnel (quick tunnel or named tunnel)
-> Local server (127.0.0.1:3847, Streamable HTTP)
-> allowedRoots[]
```
## What it includes
- Streamable HTTP transport built on `@modelcontextprotocol/sdk` (`^1.25.0`) and `zod`
- Loopback-only binding (`127.0.0.1`) with path and symlink checks restricted to `allowedRoots`
- Auth modes (`authMode: "oauth" | "path-token" | "both"`):
- OAuth 2.1 + RFC 7591 Dynamic Client Registration with a local Approval PIN and `allowedRedirectHosts` whitelist
- Static secret URL (`/mcp/<pathToken>`) for clients that do not use OAuth
- Cloudflare Tunnel wrappers for local `cloudflared` and reverse-SSH relay (`ssh -R`)
- 12 MCP tools:
- Files: `list_roots`, `list_directory`, `read_file`, `write_file`, `edit_file`, `delete_file`, `search_files`
- Shell & git: `run_command`, `git_status_diff`
- Optional local session bridge: `antigravity_new_session`, `antigravity_session_status`, `antigravity_send_message`
## Agent setup
To let a coding agent handle installation and config:
```text
Fetch https://raw.githubusercontent.com/KlLLHunter/gemini-local-coder-mcp/main/docs/agent-setup.md and follow it to set up gemini-local-coder-mcp.
```
See [`docs/agent-setup.md`](docs/agent-setup.md).
## Manual setup
### Requirements
- Node.js 20+
- `cloudflared` (locally, or on an SSH host if using reverse-SSH)
- Optional: a domain on Cloudflare DNS if you want a fixed URL
### 1. Build and configure
```bash
git clone https://github.com/KlLLHunter/gemini-local-coder-mcp.git
cd gemini-local-coder-mcp
npm install
cp config.example.json config.json
npm run build
npm test
```
Edit `config.json` and list the folders the server may access in `allowedRoots`:
```json
{
"host": "127.0.0.1",
"port": 3847,
"publicBaseUrl": "",
"authMode": "both",
"allowedRoots": [
"C:\\path\\to\\your\\project"
],
"tunnel": {
"mode": "local-cloudflared",
"sshHost": "my-vps",
"remoteCloudflaredPath": "$HOME/bin/cloudflared"
}
}
```
On first start, the server writes `.secrets.json` (`approvalPin`, `pathToken`, and OAuth client credentials). Both `config.json` and `.secrets.json` are gitignored.
### 2. Expose over HTTPS
#### Quick tunnel (no domain)
Creates a temporary `https://<random>.trycloudflare.com` URL per session:
```powershell
powershell -ExecutionPolicy Bypass -File .\scripts\start-with-cloudflared.ps1
```
#### Named Cloudflare Tunnel (fixed domain)
1. In Cloudflare Zero Trust, go to **Networks -> Tunnels -> Create a tunnel (`Cloudflared`)** and copy the tunnel token.
2. Under **Public Hostname**, route a subdomain (for example `mcp.example.com`) to `HTTP` -> `127.0.0.1:3847`.
3. Save the URL and token locally (stored in `config.json` and `.secrets.json`; the token is passed over stdin/env, not CLI args):
```bash
node dist/cli.js tunnel-configure --url=https://mcp.example.com --token="<cloudflared_token>"
```
4. Start the server and tunnel:
```bash
node dist/cli.js mcp-start
node dist/cli.js mcp-status
```
If direct `cloudflared` connections are blocked on your network, set `"mode": "vps-cloudflared"` and your SSH host alias in `config.json`, then run `scripts/start-vps-tunnel.ps1` or `node dist/cli.js mcp-start` to forward `127.0.0.1:3847` via `ssh -R`.
### 3. Add as a Gemini Custom Connector
1. Open [gemini.google.com/customize/connectors](https://gemini.google.com/customize/connectors) (or type `@` -> **All Connectors** -> **+**).
2. Run `node dist/cli.js mcp-status` to see the active URLs and Approval PIN:
- For OAuth (`authMode: "oauth"` or `"both"`): enter `https://<your-domain>/mcp` and leave Client ID / Client Secret blank (registered via RFC 7591). Confirm account linking and enter the local Approval PIN.
- For path-token (`authMode: "path-token"` or `"both"`): enter `https://<your-domain>/mcp/<pathToken>`.
3. Save and connect.
### 4. CLI and Windows autostart
```bash
node dist/cli.js mcp-start [--no-tunnel] [--json]
node dist/cli.js mcp-status [--json]
node dist/cli.js mcp-stop
```
Register or remove Windows Task Scheduler logon startup:
```powershell
powershell -ExecutionPolicy Bypass -File .\scripts\install-autostart.ps1
powershell -ExecutionPolicy Bypass -File .\scripts\uninstall-autostart.ps1
```
## Security
- `.secrets.json`, `.oauth-state.json`, `config.json`, `runtime-state.json`, and `*.log` are excluded in `.gitignore`.
- Keep `host` set to `127.0.0.1`. Do not expose the port directly without HTTPS and OAuth or a path token.
- Review `allowedRoots` and `shell.enabled` before connecting a remote client.
## License
MIT
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues