Skip to main content

AgentPay MCP Server

Agent-to-Agent micropayments via x402 + MCP — let AI agents autonomously pay for API access with USDC on Base.

Install

Option A — Remote MCP(推荐,无需本地安装)

在 Cursor / Claude / 任意支持 Streamable HTTP 的客户端添加:

https://agentpay-xhs-production.up.railway.app/mcp

官方 Registry 条目:io.github.yyxqqq777/agentpay

Option B — 本地 stdio(uvx / PyPI)

{
  "mcpServers": {
    "agentpay": {
      "command": "uvx",
      "args": ["mcp-server-agentpay"],
      "env": {
        "GATEWAY_BASE_URL": "https://agentpay-xhs-production.up.railway.app",
        "AGENT_PRIVATE_KEY": "0xYourAgentPrivateKey",
        "MAX_SPEND_PER_CALL": "0.10",
        "PYTHONUNBUFFERED": "1"
      }
    }
  }
}

或永久安装:

pip install mcp-server-agentpay
# or
uv tool install mcp-server-agentpay

Tools

Tool Description Cost
xhs_get_note_detail Xiaohongshu note detail 0.01 USDC/call
xhs_get_user_notes Xiaohongshu user posted notes list 0.01 USDC/call
china_wholesale_pricing_query Factory-direct wholesale pricing (1688/Yiwu) 0.01 USDC/call
agentpay_payment_status View payment config, wallet, and spending limits Free

Example prompts

  • "帮我看看这条小红书笔记写了什么:https://www.xiaohongshu.com/explore/..."
  • "拉一下这个博主最近发的笔记,user_id=..."
  • "Search wholesale prices for wireless earbuds under $3"
  • "What's my AgentPay wallet and spending limit?"

Agent Skill(可发布 · agentskills.io)

符合 Agent Skills。对外只暴露 AgentPay 付费小红书接口,Agent 不知道、也不应调用任何上游爬虫:

Agent / MCP  --(x402 0.01 USDC)-->  AgentPay Gateway  -->  笔记 JSON
                                   收款: 你的 Base 钱包
npx skills-ref validate ./skills/xhs-note-fetch

# 本地:Gateway 持有上游密钥;Agent 侧只配 GATEWAY_BASE_URL
PYTHONPATH=src python -m agentpay.gateway.app
GATEWAY_BASE_URL=http://127.0.0.1:8402 \
  python skills/xhs-note-fetch/scripts/fetch_note.py "<笔记链接>"

发布 skills/xhs-note-fetch 即可。上游密钥只写在 Gateway 部署环境。

Environment Variables

Variable Required Description
GATEWAY_BASE_URL MCP / Skill AgentPay 网关地址
AGENT_PRIVATE_KEY Production 付款钱包私钥
MAX_SPEND_PER_CALL No 单次上限(默认 0.10
PAYMENT_MODE Gateway demoproduction
DATAFLOW_API_TOKEN / TIKHUB_API_KEY 仅 Gateway 部署 上游数据源(不对 Agent 暴露)

How it works

MCP Client  →  mcp-server-agentpay  →  x402 Gateway  →  Paid API
              (auto 402 → sign → retry)   (verify USDC)
  1. Tool call hits a paid API endpoint
  2. Gateway returns 402 Payment Required with USDC payment details
  3. MCP server signs payment and retries automatically
  4. JSON data flows back to the LLM

Self-host the Gateway

If you operate the paid API, deploy the gateway separately:

pip install "mcp-server-agentpay[gateway]"
# .env: PAYMENT_MODE=production + upstream keys + your receive wallet
agentpay-gateway

Real USDC settlement (x402)

Mode Behavior
PAYMENT_MODE=demo Local fake pay (dev only)
PAYMENT_MODE=production Official Facilitator verify + settle on-chain

Testnet (Base Sepolia) — use https://x402.org/facilitator, network eip155:84532.

# Fund a test agent with Sepolia USDC, then:
PYTHONPATH=src python scripts/test_x402_settlement.py

Mainnet — set PAYMENT_NETWORK=eip155:8453 and a mainnet facilitator (https://api.cdp.coinbase.com/platform/v2/x402 or PayAI). USDC goes to WALLET_RECIPIENT_ADDRESS.

See .env.example.

Publish to MCP Registry

This package is designed for the official MCP Registry.

# 1. Publish to PyPI
pip install build twine
python -m build && twine upload dist/*

# 2. Publish to MCP Registry (packages + remotes)
./scripts/publish_all.sh

Or create a GitHub Release (v0.1.0) — Actions uses Trusted Publishing to PyPI then updates the Registry.

Before publishing, update server.json and README mcp-name with your GitHub namespace (io.github.<username>/agentpay).

Development

git clone https://github.com/yyxqqq777/mcp-server-agentpay
cd mcp-server-agentpay
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest tests/ -v

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_server_agentpay-0.1.1.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_server_agentpay-0.1.1-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

Details for the file mcp_server_agentpay-0.1.1.tar.gz.

File metadata

  • Download URL: mcp_server_agentpay-0.1.1.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for mcp_server_agentpay-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1486cb34fc8dd68f60009b90051aaca129d45f364c10c1d6ddec030fb274fe3c
MD5 c97c7d74b2da57d058a226f4d6e9aa87
BLAKE2b-256 16d75afed189382af193bf5d81c844e794ebf2544b8f5383c55b99d3b5f8e56d

See more details on using hashes here.

File details

Details for the file mcp_server_agentpay-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_server_agentpay-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6ddbdd7680b6bd6addc449b770183f36e503bfa46ea09c6d7f295af5d2e7dbe2
MD5 fb6dc1698dd5aa40bd64833aef01e55c
BLAKE2b-256 ba51868d6d24e7c3283beb7077c796faed7bf01c3592a76a4007b860ffb8ad52

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.3

2 files

0.1.2

2 files

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page