npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

hitl-gate-mcp

v0.8.2

Published

Human-in-the-Loop approval gate MCP for Cursor and VS Code (elicitation + init hooks)

Readme

hitl-gate-mcp

给 AI Agent 用的 Human-in-the-Loop 审批门 MCP:危险操作先评估、再在 IDE 里点选批准/拒绝,并可在对话中查看审批记录。

  • 运行时:Node.js ≥ 18
  • 传输:stdio MCP
  • 默认审批:IDE 内建表单(MCP elicitation);不可用时走聊天文案 / 可选网页面板
  • 客户端:CursorVS Code(GitHub Copilot) 同一套接入步骤

推荐接入(两步,双端相同)

① 配置 MCP(让工具连上)

两边最终都跑:npx -y hitl-gate-mcp。差异只在配置文件路径。

Cursor(macOS 推荐,复制即用).cursor/mcp.json

{
  "mcpServers": {
    "hitl_mcp": {
      "command": "/bin/zsh",
      "args": ["-lic", "npx -y hitl-gate-mcp"],
      "env": {
        "HITL_ELICIT": "1",
        "HITL_ENABLE_PANEL": "0"
      }
    }
  }
}

用登录 shell 启动,自动带上 nvm / Homebrew 的 Node,不必写绝对路径
若写裸 "command": "npx",Cursor 从图标启动时经常报 spawn npx ENOENT

VS Code.vscode/mcp.json

{
  "servers": {
    "hitl_mcp": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "hitl-gate-mcp"],
      "env": {
        "HITL_ELICIT": "1",
        "HITL_ENABLE_PANEL": "0"
      }
    }
  }
}

VS Code 若同样 ENOENT,把 command/args 改成与上面 Cursor 相同的 /bin/zsh + -lic 写法即可。

init 也会生成示例:.cursor/mcp.json.example.vscode/mcp.json.example

保存后在 MCP 面板确认 hitl_mcp 已连接。

② 手动 init(装上硬约束,提高遵从率)

目标项目根目录

hitl-gate-mcp init
# 或
npx hitl-gate-mcp init

默认 --client all,一次写入 Cursor + VS Code 钩子:

| 客户端 | 写入内容 | |--------|----------| | Cursor | .cursor/rules/hitl-auto-gate.mdc.cursor/skills/hitl-gate/SKILL.md | | VS Code / Copilot | .github/instructions/hitl-gate.instructions.md |

只要其中一个客户端:

hitl-gate-mcp init --client cursor
hitl-gate-mcp init --client vscode

已存在则跳过;覆盖加 --force。预览 --dry-run

npm install -g hitl-gate-mcp   # 一次
hitl-gate-mcp init             # 任意项目

诚实边界:只配 MCP、不跑 init → 依赖模型遵从 instructions不保证每次都调闸门。
MCP 不能拦截 IDE 原生 Delete/Terminal。


审批弹窗不可用时(VS Code 更常见)

  1. Agent 应把返回的 user_prompt_zh 贴到对话里,停止执行
  2. 可选:MCP env 设 HITL_ENABLE_PANEL=1,浏览器打开 http://127.0.0.1:8787 批/拒
  3. 再调 get_approval_status,仅 approved 后继续

方式二:源码本地运行

git clone <本仓库地址>
cd <克隆下来的目录名>
npm install
npm run build

把 MCP 的 command/args 改成:

node /绝对路径/到/本项目/dist/index.js

HITL_DATA_DIR 建议用绝对路径。示例见 mcp.local.example.json


怎么用

危险操作审批

  1. Agent 在副作用前调用 assess_and_gate(带 code_context
  2. 五档风险;仅 高/致命 开审批
  3. 表单批准 / 拒绝;聊天「可以」不算批准
  4. 高/致命附带 爆炸半径;执行后 submit_execution_report

查看审批记录

说:「看审批记录」list_approval_history → 展示 summary_zh 表格。

可用工具

| 工具 | 作用 | |------|------| | assess_and_gate | 五档风险 + 爆炸半径;仅高/致命开单 | | submit_execution_report | 批后计划 vs 实际对照 | | list_dangerous_ops | 内置危险操作表 | | request_approval | 手动开单 | | get_approval_status | 查工单 | | list_pending | 待审列表 | | list_approval_history | 审批历史 |


环境变量

| 变量 | 默认 | 说明 | |------|------|------| | HITL_ELICIT | 1 | 是否使用 IDE 内审批表单 | | HITL_ENABLE_PANEL | 0 | 本机网页备用面板 | | HITL_DATA_DIR | ./data | 审批数据目录(建议绝对路径) | | HITL_PANEL_PORT | 8787 | 面板端口 | | HITL_OPEN_BROWSER | 0 | 面板是否自动开浏览器 |


本地自检

npm run smoke

License

MIT