Paywall Mcp

io.github.llmops-pro由 GitHub 账号 llmops-pro 发布v0.1.2更新于 Oct 24, 2026

Lightning-paywall sidecar: wraps any stdio MCP server, requires paid invoices before tool calls.

已验证STDIO仅桌面金融开发者工具

概览

AI 生成的概览

一个本地边车,可包装任意 stdio MCP 服务器,并在转发调用前要求付费的 Lightning 发票。

可以做什么
列出上游工具,并在每个工具描述后附加按工具的 sats 价格,免费工具原样透传给被包装的服务器。对收费工具调用进行拦截:首次调用返回 bolt11 发票和 payment hash,携带已结算 hash 的第二次调用经核验后转发。通过 Nostr Wallet Connect 钱包核验结算,并做重放保护,每个 hash 只能兑换一次。将每个请求写入 NDJSON 审计日志,并可在只读模式下阻止所有付费调用。
适用场景
当你已有 stdio MCP 服务器,想在不改动其代码的情况下按工具调用收取 sats 时使用,例如转售第三方服务器或测试按工具定价的档位。
运行要求
需要 Node 20+ 以及一个要包装的现有 stdio MCP 服务器,通过 PAYWALL_UPSTREAM_COMMAND 和 PAYWALL_UPSTREAM_ARGS 设置。只要有工具价格非零,就需要在 NWC_CONNECTION_STRING 中提供卖家收款钱包的 NIP-47 NWC 连接字符串;具备 make_invoice 和 lookup_invoice 权限即可。价格通过 PAYWALL_PRICE_MAP 和 PAYWALL_DEFAULT_PRICE_SATS 设置。
安装前请注意
NWC_CONNECTION_STRING 是钱包凭据;建议使用仅收款连接,因为该服务器只开具和查询发票。付费调用会花费真实 sats,且买家每次调用都需支付新发票。服务器会将配置的上游命令作为子进程启动,因此只应包装你信任的服务器。它会把日志和审计文件写入磁盘。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Paywall Mcp,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

paywall-mcp

Paywall ANY stdio MCP server with Lightning, without modifying it. paywall-mcp is a generic sidecar: configure it with an upstream MCP server command and a per-tool price map, and it transparently:

  • Forwards tools/list from the upstream to the LLM client, with prices appended to each tool's description.
  • Intercepts tools/call: free tools pass through; priced tools require a paid Lightning invoice (via Nostr Wallet Connect / NIP-47) before the call is forwarded.

No code changes to the upstream server. Works with Anthropic's reference MCP servers, your own, or any third-party MCP server that speaks stdio.

v0.1 — proxy + payment gate complete. Spawns a stdio upstream as a child process; per-tool pricing via env; in-memory invoice cache + replay protection; audit log; read-only mode. Persistent cache + HTTP/SSE upstream transport deferred to v0.2.


Why this exists

Modern paid-API patterns (Lightning paywall, L402, micropayments) exist for HTTP but the MCP ecosystem has no standard for paid tool calls. Building it into each individual server is repetitive and error-prone. paywall-mcp is the missing sidecar: write your tools as a normal MCP server, then wrap it with paywall-mcp to charge sats per call.

How the dual-call pattern works

For any priced tool:

  1. First call — LLM calls priced_tool({...args}) without payment_hash. paywall-mcp issues a bolt11 invoice through your NWC wallet and returns:
    json
    {  "error": "payment_required",  "invoice": "lnbc...",  "payment_hash": "abc123...",  "amount_sats": 21,  "expires_in_seconds": 600,  "next_step": "Pay this bolt11 ..."}
  2. Payment — the LLM (or its operator) pays the invoice. Easiest path: use nwc-mcp — the same LLM can call nwc_pay_invoice to settle.
  3. Second call — LLM calls priced_tool({...args, payment_hash: "abc123..."}). paywall-mcp verifies settlement via NWC lookup_invoice, strips payment_hash from the args, forwards the original call to the upstream, returns the upstream's result.

Replay protection: the same payment_hash cannot be redeemed twice. Buyers pay a fresh invoice for each call.


What you can build with it

  • Charge sats for premium tools in an MCP server you already have, by adding one wrapper process.
  • Per-tool pricing tiers — free_lookup: 0, premium_analysis: 100, rare_alpha_signal: 5000. Buyers see prices in tool descriptions.
  • Bundle-and-resell third-party MCP servers — wrap someone else's open-source MCP server with your paywall and offer it as a managed paid service.
  • A/B test pricing — adjust PAYWALL_PRICE_MAP in env, restart, you're at the new price.
  • Time-limited promotional pricing — start at 21 sats, raise to 100 sats once usage proves the value.

Requirements

  • Node 20+
  • An existing stdio MCP server to wrap (paywall-mcp doesn't host tools itself; it gates an upstream's tools).
  • A NIP-47 NWC connection string for the seller's receive wallet. make_invoice + lookup_invoice are the only permissions paywall-mcp needs. A receive-only NWC connection is perfectly fine and recommended — paywall-mcp never spends.

Install

bash
# From npmnpx -y paywall-mcp
# From sourcegit clone <repo>cd paywall-mcpcorepack enable pnpmpnpm installpnpm build

Configure

bash
cp .env.example .env# edit .env: set PAYWALL_UPSTREAM_COMMAND/ARGS, NWC_CONNECTION_STRING, prices

The server auto-loads .env from its own directory (next to dist/) — deliberately NOT from cwd, to avoid env collisions when running multiple MCP servers in the same Claude Code session.

Required

VarPurpose
PAYWALL_UPSTREAM_COMMANDExecutable to spawn as the upstream MCP server (e.g., node).
PAYWALL_UPSTREAM_ARGSJSON array of args passed to the upstream command (e.g., ["/path/to/upstream/dist/index.js"]).

Required when any tool has a non-zero price

VarPurpose
NWC_CONNECTION_STRINGNIP-47 NWC URI for the seller's RECEIVE wallet. make_invoice + lookup_invoice permissions sufficient. paywall-mcp never spends.

Pricing

VarDefaultPurpose
PAYWALL_DEFAULT_PRICE_SATS0Default price for any tool not in the price map. 0 = free passthrough.
PAYWALL_PRICE_MAP{}JSON object mapping tool names to sat prices. Per-tool 0 = free; missing = use default. Example: {"premium_compliment":21,"rare_alpha_signal":5000}.

Optional

VarDefaultPurpose
PAYWALL_UPSTREAM_CWD(parent cwd)Working directory for the upstream child process.
PAYWALL_UPSTREAM_ENV(inherits)JSON object of env-var overrides for the upstream.
PAYWALL_READ_ONLYfalseDisables all paid tool calls (tools/list still works). Useful for maintenance.
PAYWALL_INVOICE_TTL_SECONDS600Invoice TTL. Past this, payment_hash is forgotten from cache and the buyer must re-issue.
PAYWALL_PRICE_LABEL_TEMPLATE"(💰 {price} sats)"Label appended to each priced tool's description in tools/list. {price} is substituted with the sat amount.
PAYWALL_LOG_PATH./paywall-mcp.logServer log.
PAYWALL_AUDIT_PATH./paywall-mcp-audit.logNDJSON audit log (one line per call).

End-to-end example: paywall the bundled paywall-mcp-test server

The companion paywall-mcp-test package exposes a single tool — premium_compliment. It already implements its own paywall pattern internally, but it's also a convenient stand-in for "any upstream MCP server" to demonstrate paywall-mcp itself.

.env:

PAYWALL_UPSTREAM_COMMAND=nodePAYWALL_UPSTREAM_ARGS=["/abs/path/to/paywall-mcp-test/dist/index.js"]
NWC_CONNECTION_STRING=nostr+walletconnect://...
PAYWALL_DEFAULT_PRICE_SATS=21PAYWALL_PRICE_MAP={"premium_compliment":21}

Wire paywall-mcp (not the upstream directly) into your MCP client:

json
{  "mcpServers": {    "paywall": {      "command": "npx",      "args": ["-y", "paywall-mcp"],      "env": {}    }  }}

Now from your agent:

1. tools/list  → premium_compliment ... (💰 21 sats) This tool requires ...2. premium_compliment({})  → returns invoice + payment_hash3. nwc_pay_invoice(invoice)  → buyer pays4. premium_compliment({ payment_hash: "..." })  → upstream's result returned

Safety model

tools/list      → upstream.listTools() → augment descriptions with prices → returntools/call:  if price == 0           → upstream.callTool(args)                  (passthrough)  elif PAYWALL_READ_ONLY  → refuse with paywall_read_only            (block)  elif no payment_hash    → gate.issue() → return bolt11 + hash      (issue)  elif bad hash format    → refuse with invalid_payment_hash         (block)  else (have hash):      gate.verify() ──┬─ unknown_payment_hash         → block                      ├─ payment_hash_already_redeemed → block (replay)                      ├─ payment_hash_tool_mismatch    → block                      ├─ payment_not_settled           → block                      └─ ok → strip hash → upstream.callTool()      (paid passthrough)

Audit log entries (NDJSON, one per request):

  • outcome: "ok" — invoice issued, free passthrough, or paid passthrough completed
  • outcome: "blocked" — read-only refusal, invalid hash, replay, mismatch, not-settled
  • outcome: "error" — upstream call failed, NWC lookup_invoice failed, etc.

Tail the audit log for ground truth — independent of whatever the LLM tells you.

bash
tail -f paywall-mcp-audit.log | jq .

Wire into Claude Desktop / Claude Code / Cursor

json
{  "mcpServers": {    "paywall": {      "command": "npx",      "args": ["-y", "paywall-mcp"],      "env": {}    }  }}

Same .env-via-binary-dir pattern as the rest of the substrate — leave env empty in the client config; secrets stay in paywall-mcp/.env.


Testing

bash
pnpm typecheckpnpm test        # 13 vitest cases (config resolution + payment-gate state machine)pnpm build       # ~18 KB ESM bundle

Companion servers

  • nwc-mcp — Lightning wallet for the buyer. Lets the agent pay the invoices paywall-mcp issues. The matching half of the agent-pays-a-paid-tool loop.
  • nostr-ops-mcp — NOSTR identity, publishing, encrypted DMs.
  • marketplace-mcp — Run a NIP-15 / Shopstr storefront from an agent.
  • albyhub-admin-mcp — Alby Hub node-admin via HTTP API.

License

MIT — see LICENSE.

Contact / Issues

Built by LLMOps.Pro.

来源:README.md,提交 bc54c1d

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.2最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分