Mcp Approval Queue

io.github.Opafex由 GitHub 帳號 Opafex 發布v0.2.0更新於 Oct 26, 2026

Human approval gate for AI agents: risk-scored requests that only a person can approve

發布方自己的服務:Approval Studio

已驗證STDIO僅桌面效率與工作流安全與監控

概覽

AI 產生的概覽

本機的人為審批關卡,讓 AI 代理在執行高風險動作前請求許可,並等待真人決定。

可以做什麼
  • 為高風險動作送出審批請求,風險依動作名稱與預估費用評分
  • 查詢已送出請求的狀態,並讀取是否可繼續執行
  • 列出仍在等待真人處理的請求,最新優先,可依風險等級篩選
  • 列出真人設定的自動核准規則(唯讀)
  • 讀取伺服器中介資料,以及決策統計、規則與近期歷史等資源
適用情境
當代理可能刪除資料、寄送訊息、花錢或部署,而你希望每一步都由真人確認時使用。適合願意配合的代理,用來留下授權紀錄,最好同時搭配用戶端本身的工具權限設定。
執行需求
需要 Node.js 20 以上版本,透過 npx 以 stdio 在本機執行。選用環境變數 APPROVAL_QUEUE_STATE_DIR(與 CLI 共用的狀態目錄)與 APPROVAL_QUEUE_TTL_HOURS(預設 24)。審批透過 MCP 用戶端的徵詢表單或隨附的 CLI 完成。
安裝前請注意
它只約束代理主動請求並遵守結果的動作,並非沙箱。具備 shell 或檔案存取權限的代理可以觸及 CLI 與狀態檔,因此應在用戶端權限中禁止其執行 approve 與 rules 指令並禁止存取狀態目錄。高風險與嚴重風險一律需要真人決定;未處理的請求會過期。答案確實來自真人這一點取決於用戶端對表單的呈現。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Mcp Approval Queue,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

@opafex/mcp-approval-queue

A human-in-the-loop approval gate for AI agents, as an MCP server.

The agent calls request_approval before doing something risky. The action is risk-scored, and unless a rule you set covers it, you decide — in a form your MCP client shows you (MCP elicitation), or from a terminal. The agent gets a proceed: true|false it can act on.

The agent can ask; only a human can approve. There is no approve, reject or add-rule tool for the model to call. An approval gate the gated agent can open is not a gate.

Requires Node.js 20+.

Quick start

Add to your client's MCP config (for Claude Code, .mcp.json in your project root):

json
{  "mcpServers": {    "approval-queue": {      "command": "npx",      "args": ["-y", "@opafex/mcp-approval-queue"]    }  }}

Then tell the agent when to use it, for example in your project instructions:

Before deleting data, sending email, spending money or deploying, call request_approval and only continue if proceed is true.

How a request is decided

  1. Risk is scored from the action name — bulk_delete_users is a delete wherever the word sits — plus params.estimatedCost. The agent may pass a category, but it can only raise the score, never lower it.

  2. A rule may auto-approve it — only low or medium risk, only rules a human created. High and critical risk always go to a person.

  3. Otherwise a person decides:

    • In the client — if the client supports elicitation, the server asks you directly with the action, risk, parameters and the agent's reason, and waits for your answer. The answer goes to the server, not to the model. Approve, reject, or tick Always approve (low/medium risk only) to create a rule. Dismissing the form leaves the request pending.

    • In a terminal — otherwise the request waits, and the agent is told to poll check_status:

      bash
      npx @opafex/mcp-approval-queue pendingnpx @opafex/mcp-approval-queue approve appr_3f9c1a2b4d5e --reason "checked the recipient list"npx @opafex/mcp-approval-queue reject  appr_3f9c1a2b4d5e
  4. Unanswered requests expire after 24 hours (APPROVAL_QUEUE_TTL_HOURS) and can no longer be approved.

After five human approvals of the same action with no rejection, the next form suggests always approve. Auto-approvals do not count towards that — the system agreeing with itself is not evidence.

Tools (what the agent sees)

ToolDescription
request_approvalSubmit an action (action, optional params, context, category, wait). Returns status, proceed, risk, and what to do next.
check_statusRe-read a request by id.
list_pendingRequests still waiting for a human, newest first.
list_rulesThe auto-approval rules a human has set (read-only).

status is one of pending, approved, rejected, auto_approved, expired. Proceed only when proceed is true.

Resources

URIContents
approval://statsCounts by status and the average time a human took to decide
approval://rulesCurrent auto-approval rules
approval://historyLast 50 decisions

CLI

mcp-approval-queue                       start the MCP server (stdio)mcp-approval-queue pending               list requests waiting for a decisionmcp-approval-queue show <id>             one request in fullmcp-approval-queue approve <id> [--always] [--reason <text>]mcp-approval-queue reject <id> [--reason <text>]mcp-approval-queue rules                 list rulesmcp-approval-queue rules add <pattern> --max-risk <low|medium> [--description <text>]mcp-approval-queue rules remove <id>mcp-approval-queue history [limit]

Patterns are globs: * matches anything, ? one character, case-insensitive. A rule can never cover high or critical risk.

Configuration

VariableDefaultDescription
APPROVAL_QUEUE_STATE_DIR~/.opafex/approval-queueWhere state.json (requests, rules, history) lives. The server and the CLI must point at the same directory.
APPROVAL_QUEUE_TTL_HOURS24Hours before an undecided request expires

State is one JSON file, written atomically under a lock file, so the server and the CLI can run at the same time.

What it does not protect against

Be clear about this before relying on it:

  • An agent with a shell or file access can reach the terminal channel. The CLI and state.json are a human channel only if the agent cannot run the command or write the file. Coding agents such as Claude Code usually can. In that setup rely on the elicitation channel, and deny the agent the CLI and the state directory in your client's permission settings — for Claude Code, deny Bash(npx @opafex/mcp-approval-queue approve:*), Bash(npx @opafex/mcp-approval-queue rules:*), and edits under ~/.opafex/.
  • It only gates what the agent asks about. The agent has to call request_approval, and has to honour proceed: false. This is a protocol for a cooperative agent and a record of what was allowed, not a sandbox. Pair it with your client's own tool permissions for anything that must be enforced.
  • Elicitation is shown by the client. The guarantee that the answer came from a person is only as good as the client's rendering of the form.

Library use

ts
import { ApprovalQueueService, StateStore, assessRisk } from '@opafex/mcp-approval-queue';
const queue = new ApprovalQueueService(new StateStore('/var/lib/my-app/approvals'));const { request } = await queue.requestApproval({ action: 'refund_order', params: { estimatedCost: 40 } });

Development

bash
npm installnpm run buildnpm test

License

MIT — see LICENSE.

來源:packages/approval-queue/README.md,提交 f85607b

工具

5

request_approval

Ask a human for permission before doing something risky. Call this BEFORE the action, and only proceed when the result has proceed=true. The risk is scored from the action name (and your category, if it is riskier). A matching rule auto-approves low/medium risk actions; otherwise the human is asked directly in their client, or the request waits for them to decide with the CLI — then poll check_status.

輸入參數waitaction必填paramscontextcategory

check_status

Check whether an approval request has been decided. Proceed only when proceed=true.

輸入參數id必填

list_pending

List approval requests still waiting for a human, newest first, optionally filtered by risk level.

輸入參數limitriskLevel

list_rules

List the auto-approval rules a human has set. Read-only: rules are created by a human choosing "always approve" or with the CLI.

無需輸入參數。

server_info

Returns server metadata: name, version, registered tools, and registered resources. Useful for introspection and health checks.

無需輸入參數。

版本歷史

1
  1. v0.2.0最新Oct 25, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

其他 Approval 整合