Approval Gate Mcp

io.github.itcustomsolution由 GitHub 帳號 itcustomsolution 發布v0.4.1更新於 Oct 31, 2026

Fail-closed human approval gates for AI agent actions. Default-deny, TTL expiry, audit log.

發布方自己的服務:Approval Studio

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

概覽

AI 產生的概覽

本機 MCP 伺服器,為 AI 代理的重大動作登記人工核准請求,支援到期、一次性取用與稽核日誌。

可以做什麼
  • 登記待執行動作,可附原因、有效期限,以及綁定的操作名稱與 JSON 內容,並取得請求 id
  • 查詢狀態或封鎖等待人工決定,逾時與待處理清單本身都不構成授權
  • 在執行前一次性取用核准,僅在已核准、未過期且動作文字完全一致時成功
  • 由代理端拒絕或撤銷請求;核准本身必須由人在終端機 CLI 中完成
適用情境
適用於代理會執行寄送、發布、刪除、付費或部署等對外或破壞性動作的情境,並希望留下與具體動作綁定的人工決定紀錄。適合你能控制真正執行該動作的程式碼、並在那裡強制執行核准的部署方式。
執行需求
需要 Node.js 22 或更新版本,以本機 stdio 程序方式從 npm 安裝或透過 npx 執行。預設不需要帳號、API 金鑰或環境變數。人工需在終端機使用 approval-gate 命令列核准或拒絕。狀態保存在本機目錄,可用 APPROVAL_GATE_DIR 覆寫。
安裝前請注意
此閘門只記錄決定、從不執行動作,也不是安全邊界:以你的作業系統使用者身分擁有 shell、PTY 或檔案存取權限的代理可以繞過或修改它。狀態查詢結果與 MCP 回傳內容都不是核准憑證,只有受信任程式碼中的取用才構成授權。動作文字、原因與綁定內容以明文保存,不要寫入機密。設定 APPROVAL_GATE_ALLOW_MCP_APPROVE=1 會讓代理能核准自己的請求。

安裝

在 SourceWeft 中

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

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

其他 MCP 客戶端

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

README

approval-gate-mcp

An MCP server and library for requesting a human decision before a consequential agent action. Approvals expire, are single-use and can bind an operation to an exact payload.

The trusted executor must enforce the approval. Installing an MCP server does not prevent an agent from using another tool, and the gate is not a security boundary against processes with the same OS-user privileges. Read the trusted execution boundary and threat model before integration.

Release and verification

As of 31 October 2026, v0.4.1 on GitHub and 0.4.1 on npm are published. Source changes, GitHub releases and registry publication are separate states; these links identify the released version.

Requires Node.js 22+. See the MIT license, changelog and test suite. The 0.4.1 release notes describe the shipped changes. Tests apply to the revision and environment where they ran; they do not establish production certification. The quickstart below pins the published package; run npm test for your own checkout.

Why

Sending, deleting, publishing, spending and deploying need a decision tied to the actual operation. A general instruction to "ask first" leaves the executor to interpret an informal conversation. This project records a specific request, a human decision, an expiry and a single-use consume step that trusted execution code can enforce.

Use it when you control that execution boundary. If an agent can bypass it through a shell, another tool or direct file access, adding this server alone cannot enforce approval.

30-second quickstart

bash
claude mcp add approval-gate -- npx -y @itcustomsolution/[email protected]

Claude Desktop (claude_desktop_config.json):

json
{  "mcpServers": {    "approval-gate": {      "command": "npx",      "args": ["-y", "@itcustomsolution/[email protected]"]    }  }}

Approve or deny from your terminal with npx -p @itcustomsolution/[email protected] approval-gate list.

Example

  1. Your agent wants to email a customer. It calls request_approval with action: "send email to [email protected], subject: Invoice 1042" and gets back id a1b2c3d4e5f6.
  2. It calls wait_for_approval. Nothing is sent.
  3. In your own terminal: approval-gate list, then approval-gate approve a1b2c3d4e5f6 looks right.
  4. The agent can observe approved, but that status does not authorize sending. The trusted executor calls executeApproved for that id and the exact action (plus operation/payload binding, if present) immediately around its send function. See Trusted execution boundary. It must not accept an agent-supplied or MCP JSON result as proof. Denial, timeout or expiry prevents a successful consume.
  5. ~/.approval-gate/audit.jsonl now has the request and your decision.

Design principles

  • Fail closed. The only thing that authorizes an action is a successful consume: consume_approval returning ok: true (once, for the exact approved action), or executeApproved in trusted code. Pending, approved-but-not-consumed, denied, expired, timeout, error: none of those is an authorization; all of them mean no.
  • The gate never executes anything. It records intent and decisions. Your agent asks first, then acts only on approval. Separation of decision and execution keeps the gate simple and auditable.
  • Decisions are out-of-band. A human approves or denies with a CLI in their own terminal, not inside the agent's context. The MCP tools cannot approve. The CLI asks for an interactive terminal and a re-typed confirmation, which is a speed bump, not authentication: anything running as your OS user (a shell, a PTY, or file access) can still get past it. See Threat model.
  • Only a consume authorizes. status: "approved" is informational. Status responses carry authorizesExecution: false and an effectiveStatus (approved_unconsumed, approved_expired, consumed, revoked, ...). Trusted code that performs the side effect should call executeApproved (see Trusted execution boundary), which consumes the approval itself. A consume result that arrived over MCP, from a file or from an agent is never proof of approval, however well-formed.
  • Everything is audited. Every request, decision, expiry, and consumption is appended to ~/.approval-gate/audit.jsonl (an append-only convention, not a tamper-proof log).
  • Requests expire. Default TTL is 1 hour; a stale approval is not an approval.
  • Approvals are single-use and bound to the action. consume_approval succeeds once, only for the exact action text that was approved (and, if the request carried them, the same operation name and the same canonical JSON payload), and only if the clock read after all of its persistence is still at or before the request's expiry.

Install

Requires Node.js 22 or later (Node 18 and 20 are past end of life; the MCP SDK's @hono/node-server dependency needs Node 20+).

From npm:

bash
npm install -g @itcustomsolution/[email protected]   # installs `approval-gate` and `approval-gate-mcp`

From source:

bash
git clone --branch v0.4.1 --depth 1 https://github.com/itcustomsolution/approval-gate-mcp.gitcd approval-gate-mcpnpm ci --ignore-scriptsnpm test        # builds the source and runs the testsnode dist/cli.js list

Wire it into an MCP client

Claude Code:

bash
claude mcp add approval-gate -- node /path/to/approval-gate-mcp/dist/index.js

Or in any MCP client config:

json
{  "mcpServers": {    "approval-gate": {      "command": "node",      "args": ["/path/to/approval-gate-mcp/dist/index.js"]    }  }}

Tools

ToolPurpose
request_approvalRegister an intended action (action, reason, optional ttl_seconds, optional operation and JSON payload to bind). Returns an id (and payloadDigest).
check_approvalPoll a request's status: pending / approved / denied / expired.
wait_for_approvalBlock up to timeout_seconds for a decision. Timeout = still pending = not approved.
list_pendingList requests awaiting a human, oldest first, one page at a time (limit 1-100, default 50; pass nextCursor back as cursor).
consume_approvalCall right before acting. Succeeds once, only if approved, unexpired, and action (plus operation/payload, if the request had them) matches exactly. Anything else: do not proceed. Its JSON result is not a transferable credential.
decide_approvalDeny a pending request, or revoke an approved one that has not been consumed. Approving through MCP is refused by default, so an agent cannot approve its own request; approvals come from the CLI. Operators can opt in with APPROVAL_GATE_ALLOW_MCP_APPROVE=1 (not recommended).

The human side

bash
approval-gate list                # pending requestsapproval-gate show a1b2c3d4e5f6approval-gate approve a1b2c3d4e5f6 looks right, ship itapproval-gate deny a1b2c3d4e5f6 wrong recipientapproval-gate revoke a1b2c3d4e5f6 changed my mind   # approved but not yet consumedapproval-gate list approved --limit 20 --after a1b2c3d4e5f6   # page through historyapproval-gate archive --older-than-days 30          # retention: move finished requests aside

show and the approve confirmation print the operation and the full canonical payload (escaped) when a request binds one: that is exactly what an executor will be allowed to run.

Suggested agent policy

Put something like this in your agent's system prompt or policy file:

Before any outbound or destructive action (send, publish, delete, purchase, deploy), call request_approval and then wait_for_approval. When it returns approved, call consume_approval with the same id and exact action text, and proceed only if it returns ok: true. Never call decide_approval for your own requests.

Trusted execution boundary

When your own code (not the agent) performs the side effect, let the gate consume the approval at that boundary and run exactly the approved payload:

js
import { executeApproved } from "@itcustomsolution/approval-gate-mcp/dist/store.js";
// id comes from the agent; the action, operation and payload are what your code is about to run.await executeApproved(id, { action, operation: "smtp.send", payload: { to, subject, body } }, async (ctx) => {  ctx.assertActive();          // re-check expiry immediately before the side effect  await smtp.send(ctx.payload); // ctx.payload is a frozen copy of what the human approved});

executeApproved accepts no receipt. It performs the single-use consume itself (binding to the action text, and to the operation and payload if the request carried them), writes an execution_started audit line (fsync), checks expiry again, and only then calls your function. If the start record cannot be written, or the approval expired during that write, nothing runs. Call ctx.assertActive() again after any await that precedes the side effect.

assertConsumed(result, id, action, binding?) remains for code that calls consumeApproval itself: it accepts only a grant object issued by consumeApproval in the same process, once, for the same id/action/binding, before expiry. A copy, a JSON round trip (an MCP response, a file, an agent message) or a hand-built object is always refused. 0.3.0 accepted any well-shaped object; see the changelog.

Crash and replay semantics. Consumption is at-most-once: once .used is claimed the approval is spent, whatever happens next, including refusals after the claim (expired during persistence, audit failure). A crash after execution_started and before execution_finished means the outcome is unknown: inspect the external system and, if needed, create and approve a new request. Nothing is retried automatically, and there is no atomic guarantee between this gate's files and the external system your callback touches. Details: docs/authorization-states.md.

Limits

LimitValue
action, reason, decision reason8192 UTF-8 bytes each
requested_by256 bytes (self-reported, never authenticated)
operation1-128 of A-Z a-z 0-9 . _ : / -
payloadJSON only; 32 KiB canonical (RFC 8785), depth 32, 10000 values; no "__proto__" key
TTLMCP: integer 10 s to 7 days; library: any finite number up to 7 days (zero or negative gives an already-expired request)
Requests awaiting a decisionAPPROVAL_GATE_MAX_PENDING, default 100, 1 to 10000. Concurrent creators can overshoot by at most their own number. Invalid values fail closed.
List page1-100 (default 50)
State directoryNew requests are refused at 100,000 entries in requests/; listing refuses above 200,000. Reading, deciding, consuming and archive work at any size.

When the queue is full, request_approval fails with approval queue full until a human decides requests or they expire. Finished requests stay on disk until you run approval-gate archive, which moves only finished requests that were created and expired at least 8 days ago, so nothing archived can still be used. An MCP client can create and deny its own requests without a human, so it can fill requests/ up to the creation limit; that blocks new requests (an availability limit, like the queue cap), never a human's decisions. Each listing page reads every request file, so listing slows down as history grows until you archive. Paginated listing streams directory entries and retains at most the requested page plus one continuation summary, without payload text. The legacy listRequests API intentionally returns all matching full records and is not memory-bounded by page size.

State

Everything lives in ~/.approval-gate/ (override with APPROVAL_GATE_DIR): requests/*.json for current state, requests/*.final / *.used one-time decision and consumption markers, audit.jsonl for the history and archive/ for archived requests. The directory is created 0700 and files 0600.

Privacy: action text, reasons, requested_by and any bound payload are stored in plain text in these files, and action text and reasons are copied into audit.jsonl. Do not put credentials or secrets in them.

Threat model

What the gate does protect against:

  • An agent that can only reach this server over MCP approving its own request (MCP cannot approve).
  • An agent driving the CLI from a non-interactive shell (approve requires a TTY plus a typed confirmation).
  • Reusing one approval for a second or different action (consume_approval is single-use and action-bound).
  • Using an approval after the request's expiry, races between approve/deny/expiry, guessed ids (128-bit random), malformed or hand-edited state files without a matching decision record, and terminal escape sequences, bidirectional overrides and invisible characters in request text that try to disguise what you are approving (the CLI shows them as \u escapes). Ordinary look-alike letters from other scripts (a Cyrillic "а" in a hostname) are shown as they are: read request text, do not skim it.

What it does not protect against:

  • Trust limitation, not a bug that has been fixed: an agent with a shell, a PTY, or file access as your OS user. It can drive a pseudo-terminal, edit ~/.approval-gate/, or simply skip the gate and perform the action. The gate is a cooperation protocol plus an audit trail, not a sandbox. For hard enforcement, run the agent as a separate OS user (or in a container) that cannot read or write the gate directory, and keep the gate's CLI for yourself.
  • The actual payload. consume_approval matches the action text. It cannot prove that the email, SQL, or deploy the agent then runs equals what you read. That binding is cooperative. See docs/design-trusted-executor.md for an enforced design (proposal only).
  • Unattended, consequential use. Without OS-level separation (see above), do not treat this gate as the only control for unattended agents doing irreversible things. Keep those paths fail-closed, with no automatic execution.
  • An agent that never calls the gate. Enforcement of asking is up to your agent's policy and tooling.
  • Tampering with audit.jsonl by anyone with write access to it.

executeApproved and payload binding are local safeguards: they make the executed payload equal the approved one when your trusted code uses them. They do not authenticate the human or stop a same-user agent from bypassing the gate. A separately trusted authority/executor would still need:

  1. The executor running as a different OS user, container or service account that the agent cannot control, holding the only credential for the side effect.
  2. A gate state directory the agent's user cannot read or write.
  3. Human approval made with a credential the agent does not have (for example a hardware-key signature or an OS prompt for another user), not a TTY.
  4. The agent asking the executor to run an approved id by reference, never sending the payload again.
  5. A tamper-evident (hash-chained or off-host) audit log.

None of that is created by this package; it needs an owner decision and new credentials. See docs/design-trusted-executor.md.

Setting APPROVAL_GATE_ALLOW_MCP_APPROVE=1 re-enables approval over MCP and removes the main protection. Only use it when a human is the only one driving the MCP client.

State transitions, revocation, and crash behavior are specified in docs/authorization-states.md. approval-gate revoke <id> (or deny on an approved request) cancels an approval that has not been consumed yet.

Why so small?

The package concentrates on requests, decisions, expiry, consumption and local records. Your integration supplies the actual operation and decides where to enforce it. Keeping that responsibility explicit makes the boundary easier to review and the limitations easier to test.

Applying the gate to a workflow

This is an inspectable approval component. A working integration still needs a trusted executor, access controls, failure handling and end-to-end acceptance checks for the actual operation. A package install or passing test suite does not establish that a live workflow enforces approval or meets a compliance requirement.

For help defining owners, exceptions and evidence around one IT workflow, see ITC's IT Operations Workflow Review. Implementation and operation are separately scoped; the review does not supply an enforcement boundary or certify an integration.

Contributing

Issues and pull requests are welcome. Keep changes small and fail-closed: anything that could turn a "no" into a "yes" needs a test. Run npm test before opening a PR. See CHANGELOG.md for release history.

License

MIT, see LICENSE.


Built by Olufela "Lu" Fagbure · itcustomsolution.com · MIT license

來源:README.md,提交 c63feb3

工具

6

request_approval

Register a consequential action for human approval BEFORE performing it. Returns a request id. The action is NOT executed by this server; status 'approved' does NOT authorize anything by itself. Right before acting, call consume_approval with the same id, the exact action text and the same operation/payload if you supplied them; proceed only on ok:true. Anything else means no (fail closed).

輸入參數action必填reason必填payloadoperationttl_secondsrequested_by

check_approval

Check the current status of an approval request. Informational only: no status here authorizes execution (authorizesExecution is always false). See effectiveStatus (approved_unconsumed, approved_expired, consumed, revoked, ...). Only consume_approval ok:true authorizes.

輸入參數id必填

wait_for_approval

Block until a human decides the request, it expires, or the timeout elapses. Returns the final (or still-pending) request. Informational only; it never authorizes execution. A timeout returns 'pending' (not approved). After 'approved', call consume_approval and proceed only on ok:true.

輸入參數id必填poll_secondstimeout_seconds

list_pending

List approval requests awaiting a human decision, oldest first, one page at a time. Returns {items, nextCursor}; nextCursor is present only when more requests exist (pass it back as cursor). Items omit payload text; use check_approval for one full request.

輸入參數limitcursor

decide_approval

Deny a pending request, or revoke an approved-but-unconsumed one. Approvals are not possible through MCP; a human must run `approval-gate approve <id>` in their own terminal.

輸入參數id必填reasonapprove必填

consume_approval

Call this IMMEDIATELY before performing an approved action. Succeeds exactly once per request, only if the request is approved, not past its expiry, `action` is byte-for-byte the text that was approved, and operation/payload (if the request had them) are identical. ok:false for any reason means do NOT proceed. An approval cannot be reused for a second or different action. The returned JSON is not a transferable credential: no other component may accept it as proof of approval.

輸入參數id必填action必填payloadoperation

版本歷史

2
  1. v0.4.1最新Oct 30, 2026
  2. v0.3.0Oct 15, 2026

評分

已滿足適用檢查項的 90%

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

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

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

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

其他 Approval 整合