
Drain Mcp
io.github.kimbo128由 GitHub 账号 kimbo128 发布v0.1.3更新于 Oct 24, 2026
Pay for AI inference with USDC micropayments on Polygon. No API keys needed.
概览
一个本地 MCP 服务器,让助手发现 AI 服务市场中的提供方,并用 Polygon 上的 USDC 小额支付调用其服务,无需 API 密钥。
- 可以做什么
- 发现服务提供方并阅读其使用文档,可按模型、类别或在线状态筛选,涵盖 LLM、图像、音频、代码、抓取和 VPN 等服务。查询钱包的 USDC 与 gas 余额,并为支付合约授权 USDC 额度。开设、列出和查看支付通道,包括押金、已花费金额和到期时间。通过通道向任意类型的提供方发送付费请求,或对 MPP 提供方按次付费进行对话和 REST 调用。协作关闭通道以获得即时退款,或在到期后关闭通道取回资金,并反馈提供方的成功或失败。
- 适用场景
- 当助手需要调用 LLM 推理、搜索、抓取或图像生成等外部服务,但不想持有 API 密钥,且可以接受用 USDC 按次付费时适用。若你已有目标服务的 API 密钥,或任务不需要外部服务,则无需使用。
- 运行要求
- 以本地 npm 包(drain-mcp)通过 stdio 运行,仅限桌面端。需要 Polygon 钱包私钥,通过环境变量 DRAIN_PRIVATE_KEY 提供,并在 Polygon 主网上持有 USDC;可选变量可设置链 ID、RPC 地址和 MPP 单次最大押金。需要访问 handshake58.com、各提供方端点以及 Polygon RPC 的网络连接。
安装
在 SourceWeft 中
- 打开 控制台中的 Drain Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
DRAIN MCP Server
Payments for AI Agents — No API keys, no credit cards, no subscriptions.
MCP server for the Handshake58 AI Marketplace. Agents discover service providers, pay automatically, and call any service — LLM inference, web scraping, image generation, search, and more.
Supports two payment protocols:
- DRAIN — Payment channels on Polygon. Open once, send many requests, close when done.
- MPP — Per-request payments via Tempo. Each request is paid individually. No channel needed.
When to Use
Use drain-mcp when you need to:
- Call any service (LLM, search, scraping, image gen, etc.) without API keys
- Pay per-request with USDC — no subscriptions, no credit cards
- Access 30+ providers through one unified interface
Do NOT use drain-mcp when:
- You already have API keys for the service you need
- The task doesn't require external services
TL;DR - Minimum Viable Workflow
MPP Providers (per-request, no channel)
DRAIN Providers (payment channels)
When to Close a Channel
-
Done with your task? → Use
drain_cooperative_close(channelId). Instant refund of unspent deposit. Always do this when finished. -
Planning more requests soon? → Keep the channel open. No need to close and reopen — saves $0.04 in gas fees.
-
Channel expired? → Use
drain_close_channel(channelId). Reclaims unspent USDC after the expiry timestamp. Funds do NOT return automatically.
Rule of thumb: Close when the task is done. Keep open while working.
Already Hit a 402?
MPP providers: drain-mcp handles 402 automatically via mppx/Tempo. Just use mpp_chat or mpp_request — payment is resolved transparently.
DRAIN providers return 402 Payment Required with headers when no payment voucher is sent:
DRAIN Flow:
- Call a provider endpoint (no voucher) → get
402with headers - Install
drain-mcpor use the signing API at theX-Payment-SigningURL - Open a channel to the
X-Payment-Provideraddress - Retry the request with an
X-DRAIN-Voucherheader
Everything you need is in the 402 response. No prior registration required.
Tools Reference
Discovery
drain_providers
Find service providers. Filter by model name, category, or online status.
Categories: llm, image, audio, code, scraping, vpn, multi-modal, other
drain_provider_info
Get details about a provider including usage instructions (docs). The docs explain how to format requests for that provider.
Wallet
drain_balance
Check wallet USDC balance, POL for gas, and DRAIN contract allowance.
drain_approve
Approve USDC spending for the DRAIN contract. Required once before opening channels.
Channels
drain_open_channel
Open a payment channel. Locks USDC for the specified duration.
Returns channelId, expiry time, and provider usage docs.
drain_channel_status
Check a channel's deposit, spending, remaining balance, and expiry.
drain_channels
List all known channels with status (active/expired/closed). Find expired channels that need closing.
Usage (DRAIN)
drain_chat
Send a paid request through a DRAIN channel. Works for ALL DRAIN provider types:
- LLM providers: Standard chat messages
- Non-LLM providers: JSON payload in the user message content (check provider docs)
Usage (MPP)
mpp_chat
Send a chat request to an MPP LLM provider. Payment is automatic via Tempo — no channel, no setup.
mpp_request
Send a request to an MPP REST API service (Tavily, Brave, Wolfram, etc.). Payment is automatic via Tempo.
Read the provider's docs first (drain_provider_info) to find the correct endpoint paths and request format.
Quality Feedback
drain_feedback
Report success or failure after using any provider (DRAIN or MPP). Feeds the marketplace quality scoring system.
Settlement
drain_cooperative_close
Close a channel early with provider consent. Use this when your task is done — instant refund of unspent deposit. No need to wait for expiry.
drain_close_channel
Close an expired channel and reclaim unspent USDC. Use when the channel has passed its expiry timestamp.
Economics Example
Opening a GPT-4o channel:
- Protocol fee: 2% on provider claims (on-chain)
- Session fee: none
- Live pricing:
GET https://handshake58.com/api/mcp/providers
Provider Categories
Providers are not limited to LLM chat. Each provider has a category field and a docs endpoint explaining how to format requests.
Rule: For any category other than llm, call drain_provider_info first to read the docs.
Decision Trees
Choosing a Protocol
Starting a DRAIN Session
Ending a DRAIN Session
Choosing Amount and Duration
Handling Errors
Setup
1. Install
2. Create a Wallet (locally)
Generate a key on your own machine — nothing is sent over the network:
3. Fund the Wallet
Send $1–5 USDC on Polygon Mainnet to your wallet address. Use a dedicated low-value wallet — never your main wallet.
No POL needed — if your wallet holds $5+ USDC, free gas is provided:
Returns 0.1 POL (~10K transactions). Sends only your public address.
4. Configure MCP Client
Environment Variables
Security & Privacy
Key Handling
DRAIN_PRIVATE_KEY is loaded into memory by the local MCP process. It is used for:
- EIP-712 voucher signing for DRAIN channels (off-chain, no network call)
- On-chain transaction signing (signed locally, only the signature is broadcast)
- Tempo payment signing for MPP requests (handled by mppx, signed locally)
The key is never transmitted to any server. Providers verify signatures against on-chain state.
Spending Limits
DRAIN: Exposure is capped by the smart contract:
- Maximum spend = channel deposit (you choose the amount)
- Channel has a fixed duration (you choose)
- After expiry, unspent funds are reclaimable via
drain_close_channel
MPP: Each request is paid individually at the provider's advertised price. No pre-deposit required.
Both protocols: No recurring charges, no stored payment methods.
What Leaves Your Machine
- Public API queries to handshake58.com (provider list, config, channel status)
- Request messages to providers (sent to the provider's apiUrl, NOT to Handshake58)
- Signed payment vouchers (contain a cryptographic signature, not the key)
- Signed on-chain transactions (broadcast to Polygon RPC)
What Stays Local
- Private key (never transmitted)
- All cryptographic operations (signing happens in-process)
External Endpoints
Every network request the MCP server makes:
Safeguards
- Use a dedicated wallet with $1–5 USDC. Never reuse your main wallet.
- Always generate keys locally. The key stays on your machine.
- Open source: github.com/kimbo128/DRAIN (MIT licensed)
- Open channels with small deposits. Close promptly when done.
Links
- NPM: https://www.npmjs.com/package/drain-mcp
- GitHub: https://github.com/kimbo128/DRAIN
- Marketplace: https://handshake58.com
- Provider Directory: https://handshake58.com/directory
- Contract:
0x0C2B3aA1e80629D572b1f200e6DF3586B3946A8A(Polygon Mainnet)
来源:mcp/README.md,提交 50b3a11
工具
0版本历史
1- v0.1.3最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分