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 集成