Gemini Local Agent MCP
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Gemini Local Agent MCP
English | 简体中文
把你本地电脑变成一个安全可控的 MCP Agent 服务,通过 Cloudflare Tunnel 加密透传公网 HTTPS,并利用内置自托管 OAuth 2.1 (PKCE + DCR) 与 Gemini Web (gemini.google.com) 的自定义应用连接器对接——让你直接用 Gemini 网页版 / 手机端额度读写本地代码、执行命令和调试项目。
架构概览
Gemini Web / Mobile (gemini.google.com / devmode)
│
│ HTTPS POST /mcp (Streamable HTTP + OAuth 2.1 Bearer Token)
▼
Cloudflare Edge (*.trycloudflare.com 或自定义域名)
▲
│ 出站加密隧道 (cloudflared --protocol http2,无需公网 IP / 端口映射)
│
本机 cloudflared 进程
│
│ http://127.0.0.1:8787
▼
gemini-local-agent-mcp
├── OAuth 2.1 授权服务器 (PKCE S256 + RFC 7591 DCR + RFC 9728 Metadata)
├── 权限控制层 (PERMISSION_MODE: sandbox / readonly / developer)
├── 弹窗策略层 (TOOL_APPROVAL_MODE: auto_except_delete / auto_all / strict)
├── 14 个跨平台开发工具 (文件读写/原子多处编辑/搜索/Shell/后台任务)
└── Codex / Claude Code 风格实时终端 UI (同步输出无闪烁 + 纯文本日志落盘)Related MCP server: AKIMCP
核心特性
开箱即用,零第三方鉴权依赖:内置完整 OAuth 2.1 + PKCE (
S256) + 动态客户端注册 DCR (RFC 7591) + 资源元数据发现 (RFC 9728),无需注册 Auth0 或配置 Cloudflare Access,绑定时在浏览器输入本地口令即可。3 种权限隔离模式 (
PERMISSION_MODE):sandbox(默认推荐):通过realpath校验把读写与cwd锁定在ALLOWED_ROOTS白名单内,防../软链接越狱,并拦截高危破坏性系统命令。readonly:仅向 Gemini 注册 5 个只读/搜索工具,彻底不暴露文件写入与终端执行。developer:全盘文件与完整本地终端权限(适合个人完全信任的主力开发机)。
解决 Gemini Web「始终允许」反复弹窗卡死:支持
TOOL_APPROVAL_MODE=auto_except_delete(默认),让日常改代码与跑命令零弹窗顺畅连续执行,仅对delete_path保留高危二次确认。Codex / Claude Code 风格实时终端界面:启动后展示圆角状态面板、实时工具执行进度动画(
正在读取文件…/正在执行命令…)、树形历史记录(● Edit(...) / ⎿ ...),同时把完整纯文本日志写入mcp-server.stdout.log。支持 3 种隧道运行模式:Cloudflare Quick Tunnel(免账号临时域名)、Cloudflare Named Tunnel(固定自定义域名)、纯本地服务(配合外部反代或 Gemini CLI / MCP Inspector)。
环境要求
Node.js
>= 20.0.0Cloudflare Tunnel CLI (
cloudflared):Windows:
winget install --id Cloudflare.cloudflared -emacOS:
brew install cloudflaredLinux:参考 Cloudflare 官方下载页
3 分钟快速开始
1. 安装依赖
git clone https://github.com/SumitaRinku/gemini-local-agent-mcp.git
cd gemini-local-agent-mcp
npm install(可选)复制配置模板并按需修改工作目录与权限模式:
cp .env.example .env如果跳过这一步,首次启动时程序会自动生成一份安全的默认
.env(默认PERMISSION_MODE=sandbox,并自动生成高强度ADMIN_PASSWORD)。
2. 启动本地 MCP + Cloudflare Quick Tunnel
Windows (PowerShell):
powershell -ExecutionPolicy Bypass -File .\scripts\start-quick-tunnel.ps1macOS / Linux(或任意终端):
npm run tunnel启动后终端会展示一个圆角卡片,包含本次生成的:
MCP URL:
https://xxxx-xxxx.trycloudflare.com/mcpOAuth 口令 (
ADMIN_PASSWORD):首次绑定时在浏览器授权页输入
3. 在 Gemini Web 绑定
打开 https://gemini.google.com(或开发者调试台 https://gemini.google.com/devmode)。
进入 Settings → Connected Apps → Custom apps → Add a custom app(DevMode 下点击 + Create new)。
填入终端显示的 MCP URL(注意末尾必须带
/mcp),Client ID / Secret 留空,直接点下一步。浏览器弹出本机授权页后,输入终端里的 OAuth 口令 并点击「确认授权」即可开始使用!
详细图文与 Gem 系统提示词模板见:docs/GEMINI_SETUP.md
终端实时界面预览
╭──────────────────────────────────────────────────────────────────────────────────────╮
│ gemini-local-agent-mcp 已就绪 (Ready) │
├──────────────────────────────────────────────────────────────────────────────────────┤
│ MCP URL : https://xxxx-xxxx.trycloudflare.com/mcp │
│ OAuth 口令: <auto-generated-password> │
│ 权限/确认 : Quick Tunnel · sandbox · auto_except_delete · 14 tools │
╰──────────────────────────────────────────────────────────────────────────────────────╯
◆ OAuth 已自动注册客户端 (Google) [20:05:12]
◆ OAuth 授权完成 · Gemini 已连接就绪 [20:05:18]
◆ Gemini 已同步工具列表,待命中 [20:05:19]
● Read(src/app.js · lines 1-120) [20:05:24]
⎿ 已读取 120 行 (共 240 行) · 3ms
● MultiEdit(src/app.js · 2 edits) [20:05:29]
⎿ 已更新 2 处 · 2ms
⠹ 正在执行命令 npm test… (1.4s)
隧道: https://xxxx-xxxx.trycloudflare.com/mcp │ 权限: sandbox │ 已调用: 2 │ 后台任务: 0 │ Ctrl+C 退出模式矩阵速览
完整的配置说明与 4 套开箱即用 .env 预设请查阅:docs/MODES.md
维度 | 可选值 | 默认值 | 说明 |
权限模式 ( |
|
| 限制沙盒目录 / 仅暴露 5 个只读工具 / 全盘完整开发权限 |
弹窗策略 ( |
|
| 日常编辑与命令免弹窗 / 全部免弹窗 / 写与执行逐次弹窗 |
隧道模式 (启动方式) |
|
| 免账号随机域名 / 自有固定域名 / 纯本地 |
鉴权模式 ( |
|
| OAuth 2.1 + PKCE + DCR / 无鉴权(公网隧道默认禁止启用) |
内置工具清单(共 14 个)
在
PERMISSION_MODE=readonly下仅注册前 5 个只读工具。
类别 | 工具名 | 功能描述 |
系统信息 |
| 查看系统版本、CPU/内存、当前权限模式、白名单目录、磁盘及 CLI 版本 |
目录浏览 |
| 列出目录内容(支持递归深度与条目限制,自动跳过 |
文件读取 |
| 按 1-based 行号区间读取 UTF-8 文本文件(自动检测并拦截二进制文件) |
全文搜索 |
| 递归搜索文件内容(支持纯文本 / 正则 / 文件名通配过滤) |
文件查找 |
| 按文件名通配符或子串递归查找文件与目录 |
文件写入 |
| 创建、覆盖或追加写入 UTF-8 文本文件(自动创建父目录) |
单处编辑 |
| 精确匹配替换文本(自动兼容 CRLF/LF,防误替换) |
原子多处编辑 |
| 单次请求对同一文件顺序做多处精确替换,任意一处失败则原子回滚 |
删除路径 |
| 删除文件或目录(内置保护 OS 根目录防误删) |
同步命令 |
| 执行本地 Shell 命令(Windows PowerShell/CMD,Unix bash/sh),支持超时杀进程树 |
启动后台任务 |
| 启动 dev server、长编译等后台任务并立即返回 |
查询任务输出 |
| 获取后台任务实时日志尾部,支持最长 25 秒等待 |
任务列表 |
| 查看当前会话启动的所有后台任务状态 |
停止后台任务 |
| 强制结束指定后台任务及其完整子进程树 |
常见问题排查 (FAQ)
1. 开了代理/VPN(如 Clash / FlClash)后 Cloudflare Tunnel 连不上或超时?
很多代理工具会拦截或丢弃 QUIC(UDP 7844)流量。本项目已默认使用最稳定的 CLOUDFLARED_PROTOCOL=http2。如需手动切换,可在 .env 修改或启动时传入 --protocol quic / --protocol http2。
2. Gemini Web 每次调用工具都弹窗点「始终允许」,甚至卡死转圈?
这是 Gemini Web 对标有 destructiveHint: true 的自定义 MCP 工具的已知前端交互问题。请确保 .env 中 TOOL_APPROVAL_MODE=auto_except_delete(默认)或 auto_all,重启服务后在 Gemini 的 Connected Apps 中移除旧应用重新添加一次(或在 DevMode 点 Sync schema)即可。
3. Quick Tunnel 重启后域名变了怎么办?
Quick Tunnel 每次重启都会分配新的 *.trycloudflare.com 地址。如果希望长期使用固定域名(例如 https://mcp.yourdomain.com/mcp),请按 docs/MODES.md 中的 Named Tunnel 步骤绑定自己的 Cloudflare 域名,以后重启无需在 Gemini 里重新配置。
4. 如何运行自动化验证测试?
# 运行多权限模式、弹窗策略与 TUI 渲染测试
npm run test:modes
# 运行 12 步 OAuth 2.1 + Streamable HTTP 端到端冒烟测试(需先启动服务或传入隧道 URL)
npm run test:smoke -- http://127.0.0.1:8787安全与文档导航
模式详解与预设模板:docs/MODES.md
Gemini Web / DevMode / CLI 接入指南:docs/GEMINI_SETUP.md
安全架构与最佳实践:docs/SECURITY.md
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Use your own Windows, Mac or Linux computer from ChatGPT, Claude, Cursor or Gemini CLI: run commands, read, write and search files, run long processes. Your computer only makes an outgoing connection (no open ports or VPN). Read-only mode, allowed folders, blocked commands and an action log keep you in control. Free plan available.
Connect AI assistants to your approved computer for files, commands, browser and desktop tasks.
Secure tunneling, reverse proxy and remote access for local applications.
Give your AI hands on every computer you own. Remote control of your Windows, Mac and Linux machines from one ChatGPT, Claude or Cursor chat — even from your phone. Ask it to find out why the office server is crawling, update every PC in the house, sort out your mom's laptop from another city, or ship the site from your work machine while you're on a train. It runs commands and reads and writes files; screenshots are a beta you can request. You decide what each computer allows, and you can cut any of them off in a second.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables web-based AI agents such as claude.ai, ChatGPT and Grok to read and edit files and run allowlisted shell commands on your own machine, plus control Chromium, DevTools, ports, git, SQLite and background tasks. Access is exposed over HTTPS with OAuth 2.1 through a swappable public edge (Tailscale Funnel or a Cloudflare tunnel), with a loopback-only control panel for configuration.MIT
- FlicenseNot gradedqualityAmaintenanceConnects web-based AI chat clients such as Claude, ChatGPT, and Grok to a local machine through a single OAuth-gated MCP endpoint so they can browse, read, write, and edit files, run whitelisted shell commands, search content, use Git, query SQLite, drive browsers and DevTools, and manage background tasks, ports, and clipboard. It also exposes localhost and LAN services via a protected HTTP client, letting remote or mobile clients debug and operate local projects without granting unrestricted shell access.-
- AlicenseNot gradedqualityAmaintenanceExposes an OAuth-gated MCP endpoint that lets web-based AI clients work directly on a local machine through 38 governed tools covering files, shell commands, search, Git, SQLite, browser automation, DevTools, background tasks, localhost services, clipboard, notifications, ports, and Postman control. Local tools can connect straight to the loopback address for offline, low-latency use, while remote clients reach the same machine over an optional public ingress.MIT
- AlicenseNot gradedqualityCmaintenanceEnables ChatGPT Web and Google Gemini to securely connect to a Windows PC over OAuth 2.1-authenticated HTTPS, exposing sandboxed filesystem, Git, shared Chrome, and PowerShell command tools through Cloudflare Tunnel or a self-hosted Linux VPS.16MIT