x402 Agent Tollbooth

io.github.ak10082247-max由 GitHub 帳號 ak10082247-max 發布v2.1.0更新於 Oct 26, 2026

On-chain DeFi smart contract auditor, arbitrage scanner, and agent tollbooth via x402 on Base.

已驗證Streamable HTTP可網頁執行金融安全與監控AI 與機器學習

概覽

AI 產生的概覽

以 Base 為基礎的付費 Web3 情報 MCP 伺服器:智慧合約 AI 稽核、跨 DEX 套利掃描、路由計算與代理記憶,依次以 USDC 透過 x402 計費。

可以做什麼
  • 稽核並掃描 Base 智慧合約與程式碼中的漏洞,付費深度稽核前可先取得免費摘要
  • 分析 Uniswap、Aerodrome、BaseSwap 池子的跨 DEX 套利與流動性機會
  • 為代理與自動執行器計算最佳化 gas 與滑價的執行路徑
  • 儲存與擷取代理的持久記憶,並可直接查詢此服務底層的 LLM
  • 每個付費工具都需要在 Base 或 Solana 上完成 USDC 付款授權,可選推薦錢包用於分潤
適用情境
當代理需要 Base 鏈上的合約安全審查、套利或路由情報,且願意為每次呼叫支付少量 USDC 時適用。一般程式碼審查或非 Web3 任務則不需要。
執行需求
遠端 streamable HTTP 端點,未宣告帳號或 API 金鑰。付費工具需要能簽署 USDC 付款授權(x402)的 Base 或 Solana 錢包;README 中的自架方式需要 Docker 或 Python,以及 GEMINI_API_KEY。
安裝前請注意
每個付費工具都會實際花費 USDC,工具清單為每次 0.001 至 0.02 USDC,README 中其他服務最高達 10 USDC。隨附的 FastPass SDK 要求提供代理錢包私鑰,README 範例程式碼也用它簽署付款授權,建議使用專用的低餘額錢包。請求內容與錢包地址會傳送給第三方託管服務。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 x402 Agent Tollbooth,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Web executable,透過 Streamable HTTP。 遠端服務在工作區中設定後即可從網頁執行環境執行。

交給代理程式安裝

把這段提示詞貼上到 Claude Code、Codex、Cursor 等代理程式,或 SourceWeft 對話中。代理程式會讀取該伺服器的安裝指南,先向你展示發布者、端點和登入方式,經你同意後再把它新增到你的客戶端。金鑰不會寫進任何命令。

閱讀 https://sourceweft.com/mcp/io.github.ak10082247-max%2Fx402-agent-tollbooth/install.md,並按其中說明把這個 MCP 伺服器接入我的客戶端。修改任何設定之前,先告訴我它的發布者、端點和登入方式,等我確認。不要把 API 金鑰寫進命令或我會提交的檔案;問我金鑰應從哪裡取得。

檢視代理程式所依據的安裝指南

其他 MCP 客戶端

把它新增到你客戶端的 mcpServers 設定中。

{
  "mcpServers": {
    "x402-agent-tollbooth": {
      "type": "http",
      "url": "https://x402-agent-tollbooth.onrender.com/mcp"
    }
  }
}

README

🛣️ x402 Agent Tollbooth

The x402 Agent Tollbooth is an enterprise-grade Model Context Protocol (MCP) server that demonstrates machine-to-machine (M2M) micro-transactions on the Base network.

This project provides an infrastructure layer allowing AI agents to programmatically access specialized Web3 intelligence and smart contract analysis tools by fulfilling automated HTTP 402 (Payment Required) workflows via the x402 protocol standard. Agents pay per tool execution directly in USDC, enabling a seamless, trustless API monetization model.

[Smithery Quality Score: 100/100] [Network] [Currency] [Glama]


💻 Open Source Implementation & Self-Hosting

This repository contains the full, open-source Python implementation of the MCP server. The server is built using the official mcp SDK and sse-starlette to handle Server-Sent Events (SSE) and JSON-RPC tool calling.

The core implementation is located in tollbooth_agent.py.

Running from Source (Local Execution)

You can easily self-host this MCP server or run it locally for your own agents.

Using Docker:

bash
docker build -t x402-tollbooth .docker run -p 8000:8000 -e GEMINI_API_KEY="your_api_key" x402-tollbooth

Using Python:

bash
pip install -r requirements.txtuvicorn tollbooth_agent:mcp_app --host 0.0.0.0 --port 8000

🛠️ Server Capabilities

This server exposes a navigable tree of specialized Web3 tools. AI agents must provide a valid Base network paymentHash (transaction receipt) for the exact USDC amount required to execute the paid tools.

🤝 Referral Revenue Sharing Protocol: The server implements an optional referralWallet parameter. AI agents acting as intermediaries can append their wallet address to receive a 20% protocol fee distribution.

🆓 Infrastructure & Discovery

  • contract.auditTeaser (FREE): Scans a Base smart contract for vulnerabilities and returns a high-level summary. Designed to allow agents to assess necessity before authorizing paid deep-dives.

📊 Token Data & Intelligence

  • token.analyze (0.50 USDC): Real-time liquidity, volume, and analytics for any Base token. Aggregates data for high-frequency algorithmic usage.

🔐 Smart Contract Security

  • contract.audit (1.00 USDC): Full AI-driven smart contract vulnerability audit. Returns exact lines of code, risk severity, and attack vectors.
  • contract.patch (5.00 USDC): Premium service. Audits the contract and generates production-ready, secure Solidity code to patch the vulnerabilities.

🧠 Market Intelligence

  • market.alpha (10.00 USDC): High-level metadata brokering. Aggregates metadata to reveal which smart contracts are currently experiencing high automated analysis volume on the network.
  • wallet.profile (2.00 USDC): Behavioral finance AI analysis of a specific wallet address. Generates risk profiles and portfolio strategies based on public on-chain actions.

💾 Agent Persistence

  • memory.store (0.01 USDC): Persistent memory bank for agents to store context across sessions.
  • memory.retrieve (0.01 USDC): Retrieve stored contextual memory.
  • llm.query (0.10 USDC): Query the Tollbooth's underlying LLM directly for complex reasoning tasks.

⚡ The X402 FastPass SDK (Seamless Agent Integration)

If you are building custom AI agents in LangChain, AutoGen, or CrewAI, you do not need to teach your LLMs how to write Web3 transactions to use this server.

We have included the X402 FastPass SDK (x402_fastpass.py) directly in this repository. It acts as a wrapper around the MCP client and automatically handles the USDC crypto payments natively in Python.

How to give your agent seamless access:

python
from x402_fastpass import X402FastPassimport asyncio
# 1. Give the FastPass Client your agent's Base wallet private keyclient = X402FastPass(private_key="0xYOUR_PRIVATE_KEY")
# 2. Give this Python function to your agent as a standard tool.# The SDK automatically handles the on-chain USDC transfer and passes the payment hash to the MCP server!async def run_audit():    result = await client.audit_contract("0xTargetSmartContractAddress")    print(result)
asyncio.run(run_audit())

Note: The FastPass SDK automatically injects your agent's wallet address as the referralWallet, meaning your agent automatically earns a 20% cashback on all tools it calls!


⚙️ How it Works: Modern x402 V2 Header Handshake (100% Gasless)

The server supports the official x402 V2 specification with 100% gasless settlement on Base Mainnet (eip155:8453) and Solana Mainnet (solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp):

  1. Unpaid Probe: Agent calls endpoint (e.g. POST /toll/cross-dex-arbitrage). Server immediately returns HTTP 402 Payment Required with a 50% Free Teaser Preview and PAYMENT-REQUIRED header challenge.
  2. Auto-Sign (Zero Gas): Agent signs an EIP-712 TransferWithAuthorization (on Base) or partially-signs an SPL TransferChecked (on Solana). The relayer facilitator sponsors all gas fees ($0 ETH / $0 SOL required).
  3. Replay & Unlock: Agent attaches Base64 PAYMENT-SIGNATURE header. Server verifies via facilitator in <10ms and returns HTTP 200 OK with full unredacted intel and PAYMENT-RESPONSE cryptographic receipt.

Autonomous Agent Auto-Pay (Python)

python
import base64, json, secrets, time, requestsfrom eth_account import Accountfrom eth_account.messages import encode_typed_data
def paid_toll_call(endpoint: str, payload: dict, private_key: str):    account = Account.from_key(private_key)    url = f"https://x402-agent-tollbooth.onrender.com{endpoint}"
    # 1. Probe endpoint    res = requests.post(url, json=payload)    if res.status_code == 200:        return res.json()
    # 2. Decode 402 challenge & sign EIP-712 authorization    raw_pr = res.headers.get("PAYMENT-REQUIRED") or res.headers.get("X-Payment-Required")    pr_json = json.loads(base64.b64decode(raw_pr).decode("utf-8"))    accepted = next(a for a in pr_json["accepts"] if "8453" in str(a.get("network", "")))
    now = int(time.time())    nonce = secrets.token_bytes(32)    types = {"TransferWithAuthorization": [        {"name": "from", "type": "address"}, {"name": "to", "type": "address"},        {"name": "value", "type": "uint256"}, {"name": "validAfter", "type": "uint256"},        {"name": "validBefore", "type": "uint256"}, {"name": "nonce", "type": "bytes32"},    ]}    domain = {"name": "USD Coin", "version": "2", "chainId": 8453, "verifyingContract": accepted["asset"]}    msg = {"from": account.address, "to": accepted["payTo"], "value": int(accepted["amount"]), "validAfter": 0, "validBefore": now + 300, "nonce": nonce}    sig = account.sign_message(encode_typed_data(domain_data=domain, message_types=types, message_data=msg)).signature.hex()
    payment_b64 = base64.b64encode(json.dumps({        "x402Version": 2, "resource": pr_json.get("resource"), "accepted": accepted,        "payload": {"signature": "0x" + sig.lstrip("0x"), "authorization": {            "from": account.address, "to": accepted["payTo"], "value": str(accepted["amount"]),            "validAfter": "0", "validBefore": str(now + 300), "nonce": "0x" + nonce.hex()        }}    }).encode()).decode()
    # 3. Settle & unlock premium response    paid_res = requests.post(url, json=payload, headers={"PAYMENT-SIGNATURE": payment_b64})    return paid_res.json()

🚀 Connecting to the Hosted Endpoint

If you do not want to run the server from source, connect directly to our public hosted endpoint:

  • Remote MCP URL: https://x402-agent-tollbooth.onrender.com/mcp
  • Discovery Manifest: https://x402-agent-tollbooth.onrender.com/.well-known/mcp/server-card.json
  • x402 Manifest: https://x402-agent-tollbooth.onrender.com/.well-known/x402.json
  • Smithery CLI Install:
bash
npx @smithery/cli mcp install x402-agent-tollbooth

來源:README.md,提交 e6a12a5

工具

4

ai_intel

Deep AI Vulnerability & Intelligence Engine. Scans contracts and code for logic vulnerabilities and exploits on Base. Cost: 0.001 USDC on Base & Solana (100% gasless).

輸入參數promptcontractAddress

arbitrage_scan

Cross-DEX Arbitrage & Liquidity Scanner. Analyzes Uniswap, Aerodrome, and BaseSwap pools for profitable routing opportunities. Cost: 0.002 USDC on Base & Solana (100% gasless).

輸入參數pairmin_spread_bps

smart_router

Optimal Execution Smart Router. Computes optimal gas and slippage routing paths for Base AI agents and automated executors. Cost: 0.001 USDC on Base & Solana (100% gasless).

輸入參數amounttokenIntokenOut

contract_audit

Live Smart Contract AI Auditor. Analyzes Base contracts for vulnerabilities. Cost: 0.02 USDC via x402 protocol. Cost: 0.02 USDC on Base & Solana (100% gasless).

輸入參數isPatchcontractAddress

版本歷史

1
  1. v2.1.0最新Oct 15, 2026

評分

已滿足適用檢查項的 100%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通必需25 分
  • 已宣告認證方式必需10 分
  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分