Skip to main content
Glama
Local Work MCP
by QAQTam

Local Work MCP

基于 Rust(axum + rustls + cpui + QAQHarness + oxc + rquickjs)构建的轻量级本地工作区 MCP 服务。内置 Streamable HTTP 协议、OAuth 2.1(PKCE) 鉴权、原生 TLS HTTPS 双栈监听、代码编排模式(Code Mode / PTC) 与 桌面实时监控面板,适用于 Gemini、Claude、ChatGPT 等支持远程 MCP 与 OAuth 2.1 的客户端。

核心特性

  • 安全可靠的 OAuth 2.1(PKCE)鉴权:自动提供受保护资源与授权服务器元数据端点,支持浏览器本地授权密码确认与令牌签发。

  • 原生 Rustls HTTPS 支持:无需额外反向代理即可加载 PEM 证书与私钥,未指定绑定地址时自动同时监听 IPv4 与 IPv6。

  • 代码编排模式(Code Mode / PTC):基于 oxc(TypeScript 类型剥除)与 rquickjs(异步 QuickJS 沙箱)实现单次调用编排多工具执行,支持 Promise.all 并发、跨轮持久化 state 与结构化 ToolCallError 异常处理,大幅减少 MCP 往返次数。

  • 桌面监控与热切换界面:内置基于 cpui 的轻量桌面监控窗口,实时查看客户端请求与工具调用日志、一键复制连接信息,并支持在运行中热切换本地工作区目录与代码编排模式;同时也支持 --headless 无界面模式运行。

  • 按需裁剪的工具集:基于 QAQHarness 工具引擎,默认暴露精简实用的 11 项核心工具,可通过参数切换纯代码编排模式、关闭命令执行或开放全部工具。

Related MCP server: AKIMCP

默认暴露工具

工具名

说明

get_workspace

获取当前工作区根目录、操作系统平台、默认 Shell(bash)及顶层目录列表

run_code

代码编排沙箱执行器,单次调用即可组合多个 tools.*、并发读写与处理异常

read

按行号读取本地文本文件内容

read_image

读取本地图片(.png / .jpg / .jpeg / .webp / .gif),自动缩放压缩后以 MCP 图片内容返回

edit

精确字符串替换编辑文件内容

write

创建或覆盖写入本地文件

apply_patch

应用结构化补丁对多个文件进行原子修改

glob

按通配符模式匹配工作区内的文件

grep

使用正则表达式检索工作区内的文件内容

exec_command

在工作区内执行命令行指令(默认 Shell 为 bash)

write_stdin

向运行中的交互式命令会话发送输入或轮询输出

代码编排模式(Code Mode)说明

可通过命令行参数 --code-mode、环境变量 CODE_MODE 或配置文件中的 codeMode 字段控制工具暴露方式:

  • hybrid(默认):同时暴露 run_code 与核心工具集。

  • only(等价于 --code-mode-only):纯代码编排模式,仅暴露 get_workspace 与 run_code,进一步压缩上下文占用。

  • off:关闭 run_code,仅暴露常规工具。

快速开始

环境要求

  • Rust 工具链(建议 1.85+,支持 Edition 2021)

  • Git(用于拉取 QAQHarness 与 cpui 依赖仓库)

  • (可选)Windows 下推荐安装 Git Bash,服务会自动探测常见 Bash 路径

编译与启动

# 克隆仓库
git clone https://github.com/QAQTam/local-work-mcp.git
cd local-work-mcp

# 编译发布版本
cargo build --release

# 启动服务(自动查找当前目录或上级目录中的 .mcp-config.json,不存在则自动生成)
./target/release/local-work

Windows PowerShell 示例:

cargo build --release

# 直接启动(打开桌面监控窗口)
.\target\release\local-work.exe

# 临时指定任意项目目录作为工作区
.\target\release\local-work.exe --workspace D:\Projects\my-app

# 无界面后台模式 + 纯代码编排模式
.\target\release\local-work.exe --headless --code-mode-only

仓库中同时保留了早期的 Node.js 基线实现(src/*.js 与 package.json),如有需要可使用 npm install && npm start 启动。

命令行参数

参数

环境变量

说明

-c, --config <路径>

-

指定配置文件路径(默认 .mcp-config.json)

-w, --workspace <目录>

WORKSPACE_ROOT

覆盖配置文件中的本地工作区根目录

-p, --port <端口>

PORT

覆盖服务监听端口(默认 3000)

--code-mode <模式>

CODE_MODE

设置代码编排模式:hybrid / only / off

--code-mode-only

-

--code-mode only 的简写,仅暴露 get_workspace 与 run_code

--no-bash

-

禁用 exec_command 与 write_stdin 命令执行工具

--all-tools

-

开放 QAQHarness 全部工具,而非默认核心工具集

--headless

-

无桌面窗口模式,仅在终端运行服务

配置文件说明(.mcp-config.json)

首次启动若未找到 .mcp-config.json,程序会自动生成默认配置并随机创建 OAuth 凭证与本地授权密码。完整配置示例如下:

{
  "port": 11871,
  "host": "",
  "workspaceRoot": "D:\\Projects\\my-app",
  "clientId": "local-work-xxxxxxxx",
  "clientSecret": "your-generated-client-secret",
  "approvalPassword": "your-approval-password",
  "enableBash": true,
  "execTimeoutMs": 30000,
  "publicOrigin": "https://example.com:11871",
  "tlsCertPath": "certs/fullchain.pem",
  "tlsKeyPath": "certs/privkey.pem",
  "bashPath": "",
  "defaultShell": "bash",
  "defaultPty": false,
  "allowedTools": [],
  "codeMode": "hybrid"
}

主要字段说明:

  • port / host:监听端口与绑定地址;配置 TLS 证书且 host 为空时,默认同时监听 0.0.0.0 与 [::]。

  • workspaceRoot:本地工作区根目录,支持在桌面界面中热切换并自动写回配置。

  • clientId / clientSecret / approvalPassword:OAuth 2.1 客户端凭证及浏览器授权页确认密码。

  • publicOrigin:对外公开访问的根地址(例如 https://example.com:11871),用于生成 OAuth 元数据与 MCP 端点地址。

  • tlsCertPath / tlsKeyPath:PEM 格式 TLS 证书与私钥路径(支持相对配置文件目录的路径)。

  • enableBash / execTimeoutMs / bashPath / defaultShell / defaultPty:命令执行开关、超时时间(毫秒)、指定 Bash 可执行文件路径、默认 Shell 与默认 PTY 模式。

  • allowedTools:自定义工具白名单数组,留空则使用默认核心工具集。

  • codeMode:代码编排模式("hybrid" / "only" / "off")。

注意:.mcp-config.json、.mcp-tokens.json 与 certs/ 均已加入 .gitignore,请勿将私钥、令牌或个人配置提交到公开仓库。

接入远程 MCP 客户端

方式一:自有域名 + 原生 HTTPS

  1. 准备域名解析(如 DDNS)及有效 SSL 证书(PEM 格式)。

  2. 在 .mcp-config.json 中填写 port、publicOrigin、tlsCertPath 与 tlsKeyPath。

  3. 启动服务,确保路由器或防火墙已放行对应端口。

方式二:使用 Cloudflare Tunnel 临时穿透

如果没有公网 IP 或 SSL 证书,可直接通过 cloudflared 将本地端口映射为公网 HTTPS:

winget install Cloudflare.cloudflared
cloudflared tunnel --url http://127.0.0.1:3000

将隧道生成的 https://*.trycloudflare.com 地址填入配置中的 publicOrigin 后重启服务即可。

在客户端中完成配置

启动服务后,可直接在桌面界面顶部的「连接到 MCP 客户端」卡片(或终端启动日志)复制以下四项信息填入客户端:

  1. MCP 服务器网址:https://<你的域名或隧道地址>/mcp

  2. OAuth 客户端 ID:clientId

  3. OAuth 客户端密钥:clientSecret

  4. 本地授权密码:首次 OAuth 跳转至浏览器授权确认页时输入 approvalPassword 完成授权

目录结构

.
├── Cargo.toml           # Rust 项目与依赖配置
├── src/
│   ├── main.rs          # 服务入口、HTTP/HTTPS 路由与桌面/无头模式调度
│   ├── config.rs        # 命令行参数、配置文件加载与运行期热状态
│   ├── oauth.rs         # OAuth 2.1 (PKCE) 元数据、授权页与令牌管理
│   ├── mcp.rs           # MCP Streamable HTTP 协议处理
│   ├── qaqh_bridge.rs   # QAQHarness 工具引擎桥接与图片读取
│   ├── ptc/             # Code Mode (oxc + rquickjs) 沙箱与工具桥接
│   ├── events.rs        # 实时事件总线与状态汇总
│   ├── gui.rs           # 基于 cpui 的桌面实时监控界面
│   └── *.js             # 保留的 Node.js 基线版本实现
├── assets/              # 应用图标与界面字体资源
├── LICENSE-MIT          # MIT 开源协议文本
└── LICENSE-APACHE       # Apache-2.0 开源协议文本

开源协议

本项目采用双开源协议发布,你可以任选其一遵守:

assets/fonts/ 目录下的 Google Sans 与 Google Sans Code 字体文件遵循 SIL Open Font License 1.1(详见对应 OFL-*.txt 文件)。

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      An OAuth-protected MCP server exposing a coding-tool harness over Streamable HTTP, enabling remote MCP clients like ChatGPT to securely access a local development environment.
      22
      MIT
    • F
      license
      Not graded
      quality
      A
      maintenance
      Exposes a governed suite of 38 OAuth-gated MCP tools that let web-based AI chats and other clients read and edit files, run whitelisted shell commands, search, use Git, SQLite, browser automation, DevTools, background tasks, localhost services, clipboard, notifications, and ports on a user's own machine. It runs locally with folder scoping and a strict command whitelist, so remote clients gain a large operating surface without unrestricted shell access.
      -
    • A
      license
      Not graded
      quality
      A
      maintenance
      Publishes an OAuth-gated MCP endpoint with 38 governed tools that let web-based AI clients read and edit local files, run whitelisted shell commands, search code, use read-only Git and SQLite, drive browser and DevTools automation, manage background tasks, ports, clipboard, and localhost services. It keeps that broad control safe by default through a strict command whitelist and configurable allowed folders instead of unrestricted shell access.
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables web AI clients and local IDEs to securely operate a local machine through an OAuth-gated MCP endpoint, with governed tools for files, shell, search, Git, SQLite, browser automation, DevTools, background tasks, localhost services, clipboard, notifications, ports, Postman, and AIObox windows.
      MIT