payclaw
Drop-in x402 payment middleware for MCP servers. Charge AI agents per tool call using USDC on Base chain — Python and JavaScript SDKs, no payment processor, no KYC.
README
payclaw
<a name="english"></a>
Drop-in x402 payment middleware for MCP servers. Charge AI agents per tool call using USDC on Base chain — 10 lines of code, no payment processor, no KYC.
Money flows directly: agent wallet → your wallet. payclaw never holds funds.
Quick Start
Python
pip install payclaw
from fastapi import FastAPI, Request
from payclaw import require_payment, PayclawConfig
app = FastAPI()
config = PayclawConfig(price_usdc=0.001, wallet_address="0xYourWallet")
@app.post("/tool")
@require_payment(config)
async def my_tool(request: Request):
return {"result": "tool output"}
JavaScript / TypeScript
npm install @teapper/payclaw-x402
import { requirePayment } from "@teapper/payclaw-x402";
const gate = requirePayment({ priceUsdc: 0.001, walletAddress: "0xYourWallet" });
export default { fetch: gate.wrapFetch(async (req) => {
return Response.json({ result: "tool output" });
})};
How it works
- Agent calls your tool endpoint
- No valid payment → server returns HTTP 402 with price and wallet address
- Agent pays USDC on Base chain, gets tx hash
- Agent retries with
X-Payment: <tx_hash>header - payclaw verifies on-chain → executes your tool
Packages
| Package | Install | Docs |
|---|---|---|
| Python SDK | pip install payclaw |
sdk/python |
| JavaScript SDK | npm install @teapper/payclaw-x402 |
sdk/js |
| payclaw Search MCP | Live at payclaw-mcp.vercel.app |
demo-mcp-server |
payclaw Search MCP is a production MCP server that charges agents per search query using x402. Use it as a reference implementation or connect directly.
Live endpoint: https://payclaw-mcp.vercel.app/api/mcp
Connect with Claude Desktop:
{
"mcpServers": {
"payclaw": {
"command": "npx",
"args": ["mcp-remote", "https://payclaw-mcp.vercel.app/api/mcp"]
}
}
}
Base Mainnet
from payclaw import mainnet_config
config = mainnet_config(price_usdc=0.001, wallet_address="0xYourWallet")
const gate = requirePayment({
priceUsdc: 0.001, walletAddress: "0xYourWallet",
network: "base", chainId: 8453,
usdcAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
rpcUrl: "https://mainnet.base.org",
});
Security
- Replay protection via SQLite (Python) or Redis/KV (JS)
- ERC-20 Transfer event verification (not
tx.value) - Chain ID verification (prevents testnet replay attacks)
- Receipt status check (rejects reverted transactions)
- Integer math for USDC amounts (no floating point)
Legal
MIT License. payclaw is infrastructure software only. It is not a payment processor, money transmitter, or financial service. It does not custody funds. IP addresses may be temporarily stored for rate limiting purposes only. Use at your own risk. Compliance with sanctions (OFAC) and applicable regulations is the responsibility of the deploying party.
<a name="繁體中文"></a>
payclaw(繁體中文)
適用於 MCP 伺服器的 x402 支付中介軟體。讓 AI 代理每次工具呼叫使用 Base 鏈上的 USDC 付款 — 10 行程式碼,無需支付處理器,無需 KYC。
資金直接流轉:Agent 錢包 → 你的錢包。payclaw 從不持有資金。
快速開始
Python
pip install payclaw
from fastapi import FastAPI, Request
from payclaw import require_payment, PayclawConfig
app = FastAPI()
config = PayclawConfig(price_usdc=0.001, wallet_address="0x你的錢包")
@app.post("/tool")
@require_payment(config)
async def my_tool(request: Request):
return {"result": "工具輸出"}
JavaScript / TypeScript
npm install @teapper/payclaw-x402
import { requirePayment } from "@teapper/payclaw-x402";
const gate = requirePayment({ priceUsdc: 0.001, walletAddress: "0x你的錢包" });
export default { fetch: gate.wrapFetch(async (req) => {
return Response.json({ result: "工具輸出" });
})};
運作原理
- Agent 呼叫你的工具端點
- 無有效付款 → 伺服器返回 HTTP 402,附上價格和錢包地址
- Agent 在 Base 鏈支付 USDC,取得 tx hash
- Agent 帶上
X-Payment: <tx_hash>header 重試 - payclaw 在鏈上驗證 → 執行工具
套件
| 套件 | 安裝 | 文件 |
|---|---|---|
| Python SDK | pip install payclaw |
sdk/python |
| JavaScript SDK | npm install @teapper/payclaw-x402 |
sdk/js |
| payclaw Search MCP | 線上於 payclaw-mcp.vercel.app |
demo-mcp-server |
payclaw Search MCP 係一個生產環境 MCP server,每次搜尋查詢向 agent 收取 x402 費用。可作為參考實作或直接連接使用。
線上端點: https://payclaw-mcp.vercel.app/api/mcp
以 Claude Desktop 連接:
{
"mcpServers": {
"payclaw": {
"command": "npx",
"args": ["mcp-remote", "https://payclaw-mcp.vercel.app/api/mcp"]
}
}
}
法律聲明
MIT 授權。payclaw 僅為基礎設施軟體,並非支付處理器、貨幣傳輸業者或金融服務。本軟體不持有任何資金。使用風險由使用者自行承擔。遵守制裁(OFAC)及相關法規是部署方的責任。
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.