How to lock your AI with a human gate

~5 min · Claude Desktop / Cline

如何给你的 AI 装一把「人闸」

约 5 分钟 · Claude Desktop / Cline

After this, your AI will stop before destructive actions (delete, transfer, reset) and ask for a fresh 6-digit code from the memory-lock mini program. You approve — it acts.

One-liner: “When my AI wants to delete data, it must ask me first.”

1 · Get your API key (~20 s)

  1. Open the WeChat memory-lock mini program (register if new).
  2. Open the Interface Info tab at the bottom.
  3. Copy the API key. Don't close it — you'll need the 6-digit code in a moment.

2 · Connect verify-code to your AI client (~1 min)

Any MCP-capable client starts a stdio process and injects two variables (first required):

node /abs/path/verify-code-mcp/src/index.js
MEMLOCK_API_KEY=YOUR_KEY            # from the mini program
MEMLOCK_API_BASE=https://api.memlock.cn  # optional, default

Install dependencies once: cd verify-code-mcp && npm install.

▶ Claude Desktop

Settings → Developer → Edit Config. Merge mcpServers into claude_desktop_config.json, save, then fully quit & reopen.

{ "mcpServers": {
    "verify-code": {
      "command": "node",
      "args": ["/abs/path/verify-code-mcp/src/index.js"],
      "env": { "MEMLOCK_API_KEY": "YOUR_KEY", "MEMLOCK_API_BASE": "https://api.memlock.cn" }
    } } }
Windows: escape backslashes in JSON (\\), or use forward slashes like E:/.../index.js.

▶ Cline (VS Code)

Cline panel → MCP Server → Configure, add verify-code with type: stdio. Save and refresh.

{ "mcpServers": { "verify-code": { "type": "stdio", "command": "node",
      "args": ["/abs/path/verify-code-mcp/src/index.js"],
      "env": { "MEMLOCK_API_KEY": "YOUR_KEY" } } } }

3 · Verify it works (~30 s)

Ask your AI: “List any MCP tools related to memory-lock / verify-code.” It should answer two tools:

verify_dynamic_code    — verify a 6-digit code
detect_high_risk_action — is this instruction risky?

A healthy MCP server prints on startup:

node src/index.js
[verify-code] MCP Server started, backend=https://api.memlock.cn, api_key=set
# api_key=MISSING → env not set; 'set' = ready
Backend is live: GET api.memlock.cn/v1/info returns service + ICP; POST /v1/verify without a key → HTTP 401.

4 · Have your agent use the lock (~1 min)

Add this to the session or project rules:

Before irreversible/wide-impact actions (delete/rm/overwrite/reset/transfer/pay/bulk/permission change):
 1) run verify-code detect_high_risk_action;
 2) if high/medium: STOP, show me the exact command, ask for the current
    6-digit code from the mini program, and call verify_dynamic_code;
 3) act only if it verifies; otherwise refuse and explain.

装完后:你的 AI 在删除、转账、重置等高危操作前会先停下,请你在手机上输入来自「记忆之锁」小程序的 6 位动态口令 —— 你点头它才动手。

一句话:「我的 AI 想删数据时,必须先问我。」

第 1 步 · 拿 API Key(约 20 秒)

  1. 微信打开「记忆之锁」小程序(没有就先注册)。
  2. 切到底部「接口信息」。
  3. 复制 API Key 备用。先别关小程序 —— 取 6 位口令还要用。

第 2 步 · 把 verify-code 接进你的 AI 客户端(约 1 分钟)

任何支持 MCP 的客户端都只是拉起一个 stdio 进程并注入两个变量(第一个必填):

node /绝对路径/verify-code-mcp/src/index.js
MEMLOCK_API_KEY=你的Key            # 从小程序「接口信息」拿
MEMLOCK_API_BASE=https://api.memlock.cn  # 可选,默认

先装一次依赖:cd verify-code-mcp && npm install

▶ Claude Desktop

Settings → Developer → Edit Config。把 mcpServers 合并进 claude_desktop_config.json,保存后完全退出并重启

{ "mcpServers": {
    "verify-code": {
      "command": "node",
      "args": ["/绝对路径/verify-code-mcp/src/index.js"],
      "env": { "MEMLOCK_API_KEY": "你的Key", "MEMLOCK_API_BASE": "https://api.memlock.cn" }
    } } }
Windows 反斜杠在 JSON 里要转义(\\);或直接写正斜杠,如 E:/.../index.js

▶ Cline(VS Code 插件)

Cline 面板 → MCP Server → Configure,加一个 verify-codetypestdio,保存后点刷新。

{ "mcpServers": { "verify-code": { "type": "stdio", "command": "node",
      "args": ["/绝对路径/verify-code-mcp/src/index.js"],
      "env": { "MEMLOCK_API_KEY": "你的Key" } } } }

第 3 步 · 验证真的装好了(约 30 秒)

问 AI:“列出你可用 MCP 工具里和『记忆之锁 / verify-code』有关的。” 它应回两个工具:

verify_dynamic_code    — 校验 6 位动态口令
detect_high_risk_action — 判断指令是否高危

server 正常启动会打印:

node src/index.js
[verify-code] MCP Server started, backend=https://api.memlock.cn, api_key=set
# 若报 api_key=MISSING → env 没导入;set 才表示配好
后端真在线:GET api.memlock.cn/v1/info 返回服务信息与备案号;POST /v1/verify 不带 key → HTTP 401

第 4 步 · 让 Agent 高危操作前“用起来”(约 1 分钟)

给它设一条安全边界(粘进会话 / 项目规则):

在执行 删除/覆盖/转账/批量/改权限 这类不可逆或影响面大的操作前:
 1) 先调 verify-code 的 detect_high_risk_action 判断风险;
 2) 若 high/medium,先停下,把要执行的命令列给我看,
    让我用「记忆之锁」小程序当前 6 位口令做 verify_dynamic_code;
 3) 口令通过才执行;拿不到/过不了就拒绝并说明原因。