Skip to main content

Xenarch is a non-custodial x402 MCP server. Claude, Cursor and any MCP client pay for HTTP 402–gated content with USDC micropayments on Base L2. Direct agent-to-publisher settlement. 0% fee, no contract, facilitator-agnostic.

Project description

xenarch — Python SDK for Xenarch's x402 MCP server

Xenarch is a non-custodial x402 MCP server. Claude, Cursor and any MCP client pay for HTTP 402–gated content with USDC micropayments on Base L2. Direct agent-to-publisher settlement. 0% fee, no contract, facilitator-agnostic.

This package is the Python SDK and FastAPI middleware. Use it to (a) let LangChain / CrewAI / FastAPI agents pay any x402-gated URL, or (b) gate your own FastAPI endpoints behind HTTP 402.

Unlike Cloudflare Pay-Per-Crawl / TollBit

Cloudflare Pay-Per-Crawl TollBit Xenarch
Works on any host ❌ (Cloudflare only) ❌ (enterprise)
Non-custodial ✅ (agent-to-publisher direct, no Xenarch contract)
Fee Platform rate Platform rate 0% — no Xenarch contract that can charge a fee
Open standard proprietary proprietary x402 + pay.json (open)

Settlement happens through any spec-compliant third-party x402 facilitator (PayAI, xpay, Ultravioleta DAO, x402.rs). Xenarch is never in the money flow.

Install

# For LangChain agents paying x402-gated APIs
pip install xenarch[langchain,x402]

# For publishers (FastAPI middleware)
pip install xenarch[fastapi]

Quick start

Agent: pay for x402-gated content

from decimal import Decimal

from xenarch.tools import XenarchPay, XenarchBudgetPolicy

tool = XenarchPay(
    private_key="0x...",
    budget_policy=XenarchBudgetPolicy(
        max_per_call=Decimal("0.05"),
        max_per_session=Decimal("1.00"),
    ),
)

# Use directly, or register with any LangChain agent.
print(tool.invoke("https://example.com/premium-article"))

XenarchPay is a LangChain BaseTool over the neutral x402-agent pay loop, plus Xenarch's signed-receipt and reputation extras. Settles USDC on Base via EIP-3009 — never custodial.

Publisher: gate a FastAPI endpoint behind HTTP 402

from fastapi import FastAPI
from xenarch import XenarchMiddleware

app = FastAPI()
app.add_middleware(
    XenarchMiddleware,
    site_token="your-site-token",
    protected_paths=["/premium/*"],
)

Or use the decorator:

from xenarch import require_payment

@app.get("/premium/article")
@require_payment(price_usd="0.05")
async def premium_article():
    return {"content": "This is premium content"}

The decorator returns HTTP 402 with the price when called without payment, verifies the USDC transfer to the publisher's wallet via a third-party x402 facilitator, and grants access with a time-limited Bearer token.

Env vars

Var Purpose
XENARCH_API_BASE Override the Xenarch API base URL (default: production)
XENARCH_PRIVATE_KEY Agent wallet private key for signing USDC payments
XENARCH_MAX_PAYMENT_USD Agent-configurable per-call cap. Default unbounded
XENARCH_FACILITATOR_URL Override the x402 facilitator endpoint (default: ranked fallback list)

FAQ

How does Claude pay for APIs with Xenarch? Install the Xenarch MCP server, give it a wallet, and Claude resolves any HTTP 402 response automatically with a USDC micropayment on Base L2.

Is Xenarch custodial? No. Payments settle direct from the agent's wallet to the publisher's wallet via a third-party x402 facilitator. Funds never touch Xenarch infrastructure — there is no Xenarch contract in the money flow.

What's the fee? 0%. There is no Xenarch contract that can charge a fee — the architecture is structurally zero-fee, not a policy promise.

What's the max payment? Agent-configurable. Default is unbounded; set XENARCH_MAX_PAYMENT_USD to cap per-call spend.

Links

License

MIT

Project details


Download files

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

Source Distribution

xenarch-0.2.2.tar.gz (55.6 kB view details)

Uploaded Source

Built Distribution

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

xenarch-0.2.2-py3-none-any.whl (32.1 kB view details)

Uploaded Python 3

File details

Details for the file xenarch-0.2.2.tar.gz.

File metadata

  • Download URL: xenarch-0.2.2.tar.gz
  • Upload date:
  • Size: 55.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for xenarch-0.2.2.tar.gz
Algorithm Hash digest
SHA256 dacf36c34891cce92f4fa92edddcab0af099e616f4836469d058e88fc6767ba4
MD5 3e63813e36c1364fa080df922855d4ae
BLAKE2b-256 4b8696986fe7c9ee61347f9b582ae193ff2524b172e27bec2585ab8edb0e1786

See more details on using hashes here.

File details

Details for the file xenarch-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: xenarch-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 32.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for xenarch-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fdb4e1fea45b2b644b36ab0a32c520aecfc8d43a82a9a51a58264163de464782
MD5 f5aeb70e9cdfaccbbd1c97837efaca04
BLAKE2b-256 dd1afe395bb2bddd47fdb8f1625ab5e04e9d6fade340644990e455e68ed68562

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page