Skip to main content

MCPとは?

Model Context Protocol は、LLMが外部ツールにアクセスできるようにするAnthropicのオープン標準です。l402-kit には2つのカテゴリのツールを備えた既製のMCPサーバーが付属しています:

汎用 L402 ツール

ツール説明
l402_fetch任意のURLを取得 — 402が返された場合は自動的に支払い
l402_balanceLightning の残余予算を確認
l402_spending_reportセッション中の支払いの完全な内訳

VERITY ツール — 有料サービス、自動支払い対応

ツール価格説明
verity_btc_price10 satsUSD、EUR、BRL でのリアルタイム BTC 価格
verity_worldstate80 satsUTC 時刻 + ジオロケーション + 現地の天気
verity_search100 satsウェブ検索、上位10件のオーガニック結果
verity_summarize50 sats最大50,000文字のAI要約
verity_sentiment30 satsセンチメントスコア + キーワード
verity_scrape200 satsウェブスクレイピングによるクリーンなmarkdown生成
verity_domain_intel500 satsWHOIS + DNS + SSL証明書
verity_translate50 sats11ロケール対応のAI翻訳、MDX対応
verity_integration10,000 sats任意のGitHubリポジトリへの完全なl402-kit統合
VERITY ツールは自律的に支払いを行います — 手動でのインボイス処理は不要です。

Claude Desktop でのセットアップ

1. Node.js ≥ 18 をインストール

2. ウォレットを設定する

設定ファイルの場所:
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

3. Claude Desktop を再起動する

l402_fetchl402_balancel402_spending_report のツールがClaudeのツール一覧に表示されます。

環境変数

変数必須説明
BLINK_API_KEYBlink のみBlink APIキー
BLINK_WALLET_IDBlink のみBlink ウォレットID
ALBY_TOKENAlby のみAlby アクセストークン
ALBY_HUB_URL任意カスタム Alby Hub のベースURL
BUDGET_SATS任意セッションあたりの最大支出額(デフォルト:2000

ツールの使い方

サーバーが起動すると、ClaudeはVERITYおよびL402で保護された任意のAPIを自律的に呼び出せます:
You: What's the BTC price right now?

Claude: [calls verity_btc_price]
        [Paid 10 sats] {"bitcoin":{"usd":97500,"eur":89800,"brl":548000}}

        Bitcoin is currently $97,500 USD (Cost: 10 sats)
You: Summarize this article: <pastes 5,000 words>

Claude: [calls verity_summarize with text="..."]
        [Paid 50 sats] {"summary":"..."}
You: Search for "lightning network adoption 2026"

Claude: [calls verity_search with q="lightning network adoption 2026"]
        [Paid 100 sats] {"results":[...]}
You: How much have I spent so far?

Claude: [calls l402_spending_report]
        === L402 Spending Report ===
        Total spent:  160 sats
        Remaining:    1840 sats

        By domain:
          l402kit.com: 160 sats

HTTP MCP エンドポイント

stdioパッケージに加えて、VERITYはライブの HTTP MCP サーバー を公開しています — インストール不要です:
POST https://l402kit.com/api/mcp
Content-Type: application/json
ストリーム可能なHTTPトランスポートをサポートする任意のMCPクライアントが直接接続できます。Blinkの認証情報をヘッダーとして渡してください:
X-BLINK-API-KEY: your-blink-api-key
X-BLINK-WALLET-ID: your-wallet-id
初期化:
{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"my-agent","version":"1.0"}},"id":1}
ツール一覧の取得:
{"jsonrpc":"2.0","method":"tools/list","params":{},"id":2}
ツールの呼び出し:
{"jsonrpc":"2.0","method":"tools/call","params":{"name":"verity_btc_price","arguments":{}},"id":3}
このエンドポイントはウォレットの認証情報を使って Lightning インボイスを自動的に支払い、VERITY の結果を直接返します。

MCP レジストリ

l402-kit は主要なMCPレジストリすべてに登録されています:
レジストリリンク
Anthropic MCP Registry(公式)io.github.ThiagoDataEngineer/l402-kit
Glamaglama.ai/mcp/servers/@ShinyDapps/l402-kit
Smitherysmithery.ai/servers/shinydapps/l402-kit
mcp.sol402-kit で検索
マシンリーダブルなマニフェスト:GET https://l402kit.com/.well-known/mcp.json

Cursor でのセットアップ

Settings → MCP Servers にある Cursor のMCP設定に同じ設定ブロックを追加してください。

任意のMCPクライアントでのセットアップ

サーバーは stdin から読み取り、stdout に書き込みます(stdioトランスポート):
BLINK_API_KEY=xxx BLINK_WALLET_ID=yyy BUDGET_SATS=500 npx l402-kit-mcp
MCP対応の任意のクライアントがstdioトランスポートを使って接続できます。

カスタムMCPサーバーの構築

L402Client を独自のMCPサーバーに直接組み込むこともできます:
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { L402Client, BlinkWallet } from "l402-kit";
import { z } from "zod";

const client = new L402Client({
  wallet: new BlinkWallet(process.env.BLINK_API_KEY!, process.env.BLINK_WALLET_ID!),
  budgetSats: 1000,
});

const server = new McpServer({ name: "my-agent", version: "1.0.0" });

server.tool(
  "fetch_weather",
  "Get current weather for a city — pays automatically",
  { city: z.string() },
  async ({ city }) => {
    const res = await client.fetch(`https://api.weather.com/current?city=${city}`);
    const text = await res.text();
    return { content: [{ type: "text", text }] };
  },
);

const transport = new StdioServerTransport();
await server.connect(transport);

セキュリティに関する注意事項

  • 予算の上限(BUDGET_SATS)が主要な安全策です — 保守的な値を設定してください
  • npx l402-kit-mcp プロセスは独自のインメモリ予算を持ちます;再起動するとリセットされます
  • プロダクション環境のエージェントでは、onSpend コールバックを通じて支払いログを外部ストアに永続化してください