Skip to main content
Glama
@powforge/captcha-mcp

@powforge/captcha-mcp

@powforge/captcha-mcp

当智能体重击你的 MCP 服务器时,它返回 429。captcha-mcp 让它们为下一次调用付出代价。 给智能体一个工作量证明谜题(免费,约 5 秒 CPU)或一张 3 sats 的 Lightning 发票——两者都是自主调用者无需账户、邮箱或 API 密钥即可满足的机器可读退避信号。

三个工具,支持 stdio 或 HTTP。仅使用标准库。无需注册、免费回退、可自托管、无收入分成。

为什么不是 429?

429 Too Many Requests 在智能体时代是错误的形态。MCP 服务器报告中反复出现三种模式:

  • 智能体框架将 429 视为连接失败。 它们会立即重试,通常采用指数退避,但仍然过于激进,并放大了最初触发限制的过载。

  • 没有按调用者区分的信号。 429 是针对整个桶(bucket)而非某个智能体触发的。一个吵闹的调用者会让所有其他调用者都被限流,服务器无法要求那个吵闹的调用者特别减速。

  • Retry-After 只是建议性的,经常被忽略。 智能体不会一致地解析它,也不会一致地尊重它,而且没有等待的动机——重试的成本为零。

captcha-mcp 用 402 风格的挑战(challenge)取代 429。下一次调用需要调用者付出代价(CPU 秒或 3 sats)。这种代价是按调用者计算的、机器可读的,并且会自动限流——无法解决谜题的智能体就无法淹没端点。

Related MCP server: @bitcoinbenji/mcp

快速开始

npx -y @powforge/captcha-mcp

无需安装、无需配置、无需 API 密钥。服务器在 stdio 上启动,等待 MCP 客户端。

要将其接入 Claude Code、Cursor 或任何兼容 MCP 的主机,请在你的配置中添加:

{
  "mcpServers": {
    "powforge-captcha": {
      "command": "npx",
      "args": ["-y", "@powforge/captcha-mcp"]
    }
  }
}

或者运行 npx @powforge/captcha-mcp --install 来打印配置块。

功能

将 PowForge 的 pow-captcha 服务(captcha.powforge.dev)封装为三个 MCP 工具:

工具

用途

challenge

请求一个新的工作量证明谜题。返回 {id, salt, difficulty, signature}。

verify

提交已求解的 nonce。返回一个有效期为 5 分钟的 HMAC 签名访问令牌。

status

服务器健康状态、生命周期统计信息、L402 端点元数据。

免费层级需要智能体约 5-10 秒的 CPU 时间(SHA-256,默认 14 个前导零位)。付费层级通过 L402 在 Lightning 上花费 3 sats(RFC 7235 + WWW-Authenticate 中的 bolt11 发票)。

为什么选择它而不是 OAuth、API 密钥或 Stripe?

方法

每次调用成本

需要账户

可自托管

智能体友好

API 密钥

$0

是

n/a

否

OAuth

$0

是

n/a

否

Stripe 计量

高开销

是

n/a

否

托管式 MCP 认证平台

100–2000 sats

否

否

是

PoW + L402(本项目)

数秒或 3 sats

否

是

是

智能体没有电子邮件地址。它们不会点击确认链接。它们不会输入信用卡。PoW + Lightning 是唯一适用于完全自主调用者的认证原语。

托管式 MCP 认证平台是可行的,但它们会在供应商基础设施上按每次调用收取 100–2000 sats——你的收入流经他们的管道。这个包运行在你自己的服务器上,使用你自己的 Lightning 节点和密钥。sats 归你所有。

配置

设置 CAPTCHA_URL 以指向不同的验证码后端。默认值为 http://localhost:3077,因此你可以在本地运行全栈进行开发。生产环境可将其指向 https://captcha.powforge.dev。

CAPTCHA_URL=https://captcha.powforge.dev npx @powforge/captcha-mcp

HTTP 流式传输

托管式 MCP 客户端(Smithery、基于浏览器的宿主)需要 HTTP,而不是 stdio。传入 --http 或设置 HTTP_MODE=1:

HTTP_MODE=1 PORT=3200 npx @powforge/captcha-mcp
# or
npx @powforge/captcha-mcp --http

然后服务器监听:

端点

方法

用途

/mcp

POST

单个 JSON-RPC 请求,单个 JSON-RPC 响应。通知返回 202。

/mcp

GET

用于服务器推送通知的 SSE 流(通过 25 秒心跳保持打开)。

/health

GET

存活探针——返回 {ok, server, transport}。不属于 MCP。

无状态。没有会话 ID。CORS 开放(Access-Control-Allow-Origin: *),因此浏览器客户端可以工作。Stdio 模式保持不变,且仍然是默认模式——不带任何标志的 npx @powforge/captcha-mcp 仍通过 stdin/stdout 进行 JSON-RPC 通信。

对 HTTP 传输进行冒烟测试:

HTTP_MODE=1 PORT=3200 node src/server.js &
curl -X POST http://localhost:3200/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1"}}}'

返回 {jsonrpc:"2.0", id:1, result:{protocolVersion:"2024-11-05", capabilities:{tools:{}}, serverInfo:{...}}}。

本地开发

克隆 captcha widget 仓库 或运行公共服务。MCP 服务器只需要 HTTP 访问 status 下列出的验证码端点。

git clone https://github.com/zekebuilds-lab/captcha-mcp
cd captcha-mcp
node src/server.js

它会向 stderr 打印 ready,并在 stdin 上等待 JSON-RPC。

手动对协议进行冒烟测试:

echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1"}}}' | node src/server.js

你应该会看到带有 serverInfo: { name: "@powforge/captcha-mcp", version: "0.2.5" } 的 JSON 响应。

从你自己的后端验证令牌

当智能体向你的服务提交令牌时,在不必信任该智能体的情况下验证它:

curl -X POST https://captcha.powforge.dev/api/token/verify \
  -H "Content-Type: application/json" \
  -d '{"token":"<token-from-verify-tool>"}'

返回 {valid: true, method, issued_at, expires_at} 或 {valid: false, reason}。

相关包

与其他 MCP 智能体认证原语的比较

门控 MCP 服务器的领域正在变得拥挤。以下是真实的格局,按每个工具与 captcha-mcp 的功能重叠程度排序。

工具

支付轨道

认证模型

可自托管

免费 PoW 层级

无需账户付款

PayGated

Stri

Available Tools

3 tools
challengeA

Request a fresh PoW challenge from the PowForge captcha service. Returns {id, salt, difficulty, signature, instructions}. The agent must find a nonce such that SHA-256(salt + nonce) has at least difficulty leading zero bits, then call the verify tool. Free tier — no payment required.

Inputs: no named parameters.

statusA

Return PowForge captcha server health, lifetime stats (pow_solves, ln_skips, challenges_issued), and L402 endpoint metadata (scope, price_sats, paid endpoint URL). Use this to discover the Lightning skip price before paying, or as a liveness check.

Inputs: no named parameters.

verifyA

Verify a PoW solution. Input: {salt, nonce, id, signature, algo?, difficulty?} from a prior challenge call plus the nonce the agent computed. Returns a 5-minute HMAC-signed token on success, or {valid: false, reason} on failure. Tokens can be re-verified server-side via POST /api/token/verify.

Inputs: salt (required), nonce (required), id (required), signature (required), +2 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.5/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a distinct purpose: challenge initiates a PoW challenge, status checks server health and metadata, and verify submits the solution. No overlap in functionality.

    Naming Consistency5/5

    All tool names are single-word imperative verbs (challenge, status, verify), following a consistent naming pattern.

    Tool Count5/5

    Three tools are appropriate for a captcha service, covering the core workflow (challenge, verify) and a status check. Not excessive or insufficient.

    Completeness4/5

    The core PoW challenge-verify cycle is complete. However, the status tool mentions a Lightning skip option, but no tool to execute it, which is a minor gap.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers