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": {
        "AGENT_PRIVATE_KEY": "0xYourAgentPrivateKey"
      }
    }
  }
}

只需填付款钱包私钥(需有 USDC)。网关地址已内置,一般不用改。

或永久安装:

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?"

Environment Variables

Variable Required Description
AGENT_PRIVATE_KEY Yes(付费工具) 付款钱包私钥
MAX_SPEND_PER_CALL No 单次上限(默认 0.10)
GATEWAY_BASE_URL No 网关地址(默认已指向公网 Gateway)
PAYMENT_MODE Gateway demo 或 production
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

Metadata

Release files for mcp-server-agentpay 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-server-agentpay 0.1.3
File Size Uploaded Provenance
mcp_server_agentpay-0.1.3.tar.gz 22.6 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-server-agentpay 0.1.3
File Interpreter ABI Platform
mcp_server_agentpay-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 52.8 kB

Release files / mcp_server_agentpay-0.1.3.tar.gz

Download URL mcp_server_agentpay-0.1.3.tar.gz
Size 22.6 kB
Tags Source
SHA-256 checksum
How to use checksums
398171f406445dc62055970f3a1cf56e0beb5ba66f99da4661a412cd0d62882e
BLAKE2b-256 checksum
How to use checksums
2f49bfda11ae4d03b03bbe31279f859e499e833884afa3d0ac8556980d190a52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / mcp_server_agentpay-0.1.3-py3-none-any.whl

Download URL mcp_server_agentpay-0.1.3-py3-none-any.whl
Size 30.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c732429c7b00d911698a2e65ed522551beca51bf3747a1d3f989aed4daea2cc
BLAKE2b-256 checksum
How to use checksums
1109044cbdc48ad83111d8df5c5898c92df80152c366186c87d1e8c0a32dd9e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Security for mcp-server-agentpay 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mcp_server_agentpay-0.1.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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