l402-kit-mcp

l402-kit-mcp

MCP server for l402-kit — enables AI agents (Claude, Cursor, etc.) to autonomously pay Bitcoin Lightning-protected APIs. Tools: l402_fetch, l402_balance, l402_spending_report. Run with: npx l402-kit-mcp

Category
访问服务器

README

<div align="center">

<picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ShinyDapps/l402-kit/main/docs/logo-dark.svg" height="72"> <img src="https://raw.githubusercontent.com/ShinyDapps/l402-kit/main/docs/logo-light.svg" height="72" alt="l402-kit"> </picture>

l402-kit

Add Bitcoin Lightning pay-per-call to any API. 3 lines of code.

License: MIT Live Demo Tests

<br/>

<a href="https://marketplace.visualstudio.com/items?itemName=ShinyDapps.shinydapps-l402" title="VS Code Extension — real-time Lightning payment dashboard"> <img src="https://vsmarketplacebadges.dev/version/ShinyDapps.shinydapps-l402.svg" alt="VS Code Marketplace" /> <img src="https://vsmarketplacebadges.dev/installs-short/ShinyDapps.shinydapps-l402.svg" alt="Installs" /> </a>

<br/>

▶ Watch end-to-end demo — install → 402 → pay → 200 OK

<br/>


Live traction

SDK Version Downloads
📦 TypeScript · npmjs.com/package/l402-kit npm npm total
🐍 Python · pypi.org/project/l402kit pypi pypi total
🦀 Rust · crates.io/crates/l402kit crates crates dls
🔌 VS Code Extension · marketplace vscode ver marketplace
🦫 Go · pkg.go.dev go go report

</div>


<details> <summary>🌍 Available in 11 languages — click to expand</summary>

<br/>

🇺🇸 Charge for your API in Bitcoin Lightning. 3 lines of code. 🇧🇷 Monetize sua API com Bitcoin Lightning. 3 linhas de código. 🇪🇸 Monetiza tu API con Bitcoin Lightning. 3 líneas de código. 🇨🇳 用 3 行代码,通过比特币闪电网络收费。 🇮🇳 अपने API को Bitcoin Lightning से 3 लाइनों में मोनेटाइज़ करें। 🇸🇦 اكسب من API الخاص بك عبر Bitcoin Lightning. 3 أسطر فقط. 🇫🇷 Monétisez votre API en Bitcoin Lightning. 3 lignes de code. 🇩🇪 Monetarisiere deine API mit Bitcoin Lightning. 3 Zeilen Code. 🇷🇺 Монетизируй свой API через Bitcoin Lightning. 3 строки кода. 🇯🇵 Bitcoin LightningでAPIを3行で収益化。 🇮🇹 Monetizza la tua API con Bitcoin Lightning. 3 righe di codice.

📖 Official docs: 🇺🇸 · 🇧🇷 · 🇪🇸 · 🇨🇳 · 🇮🇳 · 🇸🇦 · 🇫🇷 · 🇩🇪 · 🇷🇺 · 🇯🇵 · 🇮🇹

</details>


Install

npm install l402-kit        # TypeScript / Node.js / Express
pip install l402kit         # Python / FastAPI / Flask
go get github.com/shinydapps/l402-kit/go@v1.8.0   # Go / net/http / Chi / Gin
cargo add l402kit           # Rust / axum

AI Agents / LLMs: See llms.txt for machine-readable instructions. Agent discovery: /.well-known/agent.json · /.well-known/l402.json


For AI Agents

l402-kit is the payment layer for autonomous agents. Agents can pay for APIs without human intervention.

System prompt snippet — add this to any agent to enable L402 payments:

You have access to paid APIs via the L402 protocol.
When you call an API that returns HTTP 402, use the L402Client from l402-kit
to pay automatically with Bitcoin Lightning.
Budget limit: {BUDGET_SATS} sats per session. Never exceed this limit.

Agent SDK quickstart:

import { l402Client, buildWallet } from "l402-kit/agent";

const client = l402Client({
  wallet: buildWallet(process.env), // auto-detects BLINK_API_KEY or ALBY_TOKEN
  budgetSats: 1000,
});

const data = await client.fetch("https://api.example.com/paid-endpoint");

MCP Server (for Claude Desktop, Cursor, and any MCP-compatible agent):

{
  "mcpServers": {
    "l402-kit": {
      "command": "npx",
      "args": ["l402-kit-mcp"],
      "env": { "BLINK_API_KEY": "your-key" }
    }
  }
}

Compatible with: LangChain · OpenAI Agents · CrewAI · Vercel AI SDK · AutoGPT · Any MCP client

Protocol support: L402 (Bitcoin Lightning) · x402 (USDC/Coinbase) compatible

Powered by L402-Kit


How it works

1. Client calls your API
       ↓
2. API returns  HTTP 402 + BOLT11 invoice + macaroon
       ↓
3. Client pays  (any Lightning wallet, < 1 second, any country)
       ↓
4. Client sends Authorization: L402 <macaroon>:<preimage>
       ↓
5. API verifies SHA256(preimage) == paymentHash  ✓
       ↓
6. HTTP 200 OK + your data

── Fee flow (managed mode) ─────────────────────────────────
   Payment → 99.7% → your Lightning Address  (instant)
           →  0.3% → ShinyDapps

Quickstart

TypeScript

import express from "express";
import { l402, AlbyProvider } from "l402-kit";

const app = express();

const lightning = new AlbyProvider(process.env.ALBY_TOKEN!);

app.get("/premium", l402({ priceSats: 100, lightning }), (_req, res) => {
  res.json({ data: "Payment confirmed." });
});

app.listen(3000);

Python

from fastapi import FastAPI, Request
from l402kit import l402_required

app = FastAPI()

@app.get("/premium")
@l402_required(price_sats=100, owner_lightning_address="you@yourdomain.com")
async def premium(request: Request):
    return {"data": "Payment confirmed."}

Go

package main

import (
    "fmt"
    "net/http"
    l402kit "github.com/shinydapps/l402-kit/go"
)

func main() {
    http.Handle("/premium", l402kit.Middleware(l402kit.Options{
        PriceSats:             100,
        OwnerLightningAddress: "you@yourdomain.com",
    }, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintln(w, `{"data": "Payment confirmed."}`)
    })))
    http.ListenAndServe(":8080", nil)
}

Rust

use axum::{middleware, routing::get, Router};
use l402kit::{l402_middleware, Options};
use std::sync::Arc;

#[tokio::main]
async fn main() {
    let opts = Arc::new(Options::new(100).with_address("you@yourdomain.com"));

    let app = Router::new()
        .route("/premium", get(|| async { "Payment confirmed." }))
        .route_layer(middleware::from_fn_with_state(opts, l402_middleware));

    let listener = tokio::net::TcpListener::bind("0.0.0.0:8080").await.unwrap();
    axum::serve(listener, app).await.unwrap();
}

Test it live

# Step 1 — triggers 402 + returns invoice
curl http://localhost:3000/premium
# ← { "error": "Payment Required", "invoice": "lnbc1u...", "macaroon": "eyJ..." }

# Step 2 — pay the invoice with any Lightning wallet, then:
curl http://localhost:3000/premium \
  -H "Authorization: L402 <macaroon>:<preimage>"
# ← { "data": "Payment confirmed." }

▶ Try the interactive demo


Why not Stripe?

Stripe l402-kit
Minimum fee $0.30 < 1 sat (~$0.001)
Settlement time 2–7 days < 1 second
Chargebacks Yes Impossible — cryptographic proof
Requires account Yes No — any Lightning wallet
AI agent support No Yes — 4 SDKs, native
Countries blocked ~50 0 — global by default
Reversible Yes No — final on receipt
Open source No Yes — MIT

Providers

import { BlinkProvider, OpenNodeProvider, LNbitsProvider } from "l402-kit";

// Blink (recommended — free, instant setup)
const provider = new BlinkProvider(process.env.BLINK_API_KEY!, process.env.BLINK_WALLET_ID!);

// OpenNode (production, custodial)
const provider = new OpenNodeProvider(process.env.OPENNODE_KEY!);

// LNbits (self-hosted)
const provider = new LNbitsProvider(process.env.LNBITS_KEY!, "https://your.lnbits.host");

Bring your own node — implement the LightningProvider interface in 5 lines:

import type { LightningProvider } from "l402-kit";

class MyNode implements LightningProvider {
  async createInvoice(amountSats: number) { /* return Invoice */ }
  async checkPayment(paymentHash: string) { /* return boolean */ }
}

Security model

Invoice creation:  paymentHash = SHA256(preimage)
Client payment:    Lightning Network releases preimage to payer
API verification:  SHA256(preimage) == paymentHash  ✓
Replay protection: each preimage is marked used — works exactly once
Token expiry:      macaroons expire after 1 hour
  • Unforgeable — SHA256 is a one-way function; you cannot fake a preimage
  • No chargebacks — cryptographic settlement, not reversible card auth
  • Replay-safe — MemoryReplayAdapter (dev) or RedisReplayAdapter (production, multi-instance)
  • 392 automated tests across 5 runtimes (TS, Python, Go, Rust, Cloudflare Workers) — production-grade reliability for autonomous agent workflows
  • Fully auditable — MIT, every line open source

VS Code Extension

Monitor every sat in real-time without leaving your editor.

VS Code Marketplace

  • ⚡ Live payment feed per endpoint
  • 📊 Bar chart — 1D / 7D (free) · 30D / 1Y / ALL (Pro)
  • 🌍 11 languages built-in
  • 🎨 Light / dark / auto theme
  • 🔧 Zero config — just set your Lightning Address

Get a Lightning Address (free)

Sign up at dashboard.blink.sv — free, no credit card, instant. Your address: yourname@yourdomain.com

Other wallets: Wallet of Satoshi · Phoenix · Zeus · Alby


Links

Resource URL
📖 Docs (11 languages) l402kit.com/docs
📦 npm npmjs.com/package/l402-kit
🐍 PyPI pypi.org/project/l402kit
🦫 Go pkg.go.dev/github.com/shinydapps/l402-kit/go
🦀 Rust crates.io/crates/l402kit
🔌 VS Code marketplace.visualstudio.com
⚡ Lightning shinydapps@blink.sv
🐙 GitHub github.com/ShinyDapps/l402-kit

<div align="center">

MIT — use freely, build freely.

Bitcoin has no borders.

<br/>

Built with ⚡ by ShinyDapps

<br/>

<a href="https://l402kit.com/docs">Docs</a> · <a href="https://l402kit.com/demo">Demo</a> · <a href="https://marketplace.visualstudio.com/items?itemName=ShinyDapps.shinydapps-l402">VS Code</a> · <a href="https://npmjs.com/package/l402-kit">npm</a>

</div>

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选