Metadata-Version: 2.4
Name: xenarch
Version: 0.2.2
Summary: 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-URL: Homepage, https://xenarch.com
Project-URL: Repository, https://github.com/xenarch-ai/xenarch-sdks
Project-URL: Documentation, https://github.com/xenarch-ai/xenarch-sdks/tree/main/python
Project-URL: Issues, https://github.com/xenarch-ai/xenarch-sdks/issues
Author-email: Xenarch <hello@xenarch.com>
License: MIT
Keywords: ai-agent-payments,base,base-l2,claude,crewai,cursor,http-402,langchain,machine-to-machine-payments,mcp,mcp-server,model-context-protocol,non-custodial,pay-json,pay-per-crawl,usdc,x402,xenarch
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Office/Business :: Financial :: Point-Of-Sale
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.12
Requires-Dist: cryptography>=42
Requires-Dist: httpx>=0.27
Requires-Dist: pydantic>=2.0
Provides-Extra: all
Requires-Dist: autogen-core>=0.4; extra == 'all'
Requires-Dist: crewai>=1.0; extra == 'all'
Requires-Dist: fastapi>=0.100; extra == 'all'
Requires-Dist: langchain-core>=0.2; extra == 'all'
Requires-Dist: pay-json<2,>=1.1; extra == 'all'
Requires-Dist: x402-agent<0.3,>=0.2; extra == 'all'
Provides-Extra: autogen
Requires-Dist: autogen-core>=0.4; extra == 'autogen'
Requires-Dist: pay-json<2,>=1.1; extra == 'autogen'
Requires-Dist: x402-agent<0.3,>=0.2; extra == 'autogen'
Provides-Extra: crewai
Requires-Dist: crewai>=1.0; extra == 'crewai'
Requires-Dist: pay-json<2,>=1.1; extra == 'crewai'
Requires-Dist: x402-agent<0.3,>=0.2; extra == 'crewai'
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.100; extra == 'fastapi'
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.2; extra == 'langchain'
Requires-Dist: pay-json<2,>=1.1; extra == 'langchain'
Requires-Dist: x402-agent<0.3,>=0.2; extra == 'langchain'
Provides-Extra: langgraph
Requires-Dist: pay-json<2,>=1.1; extra == 'langgraph'
Requires-Dist: x402-agent<0.3,>=0.2; extra == 'langgraph'
Provides-Extra: x402
Requires-Dist: pay-json<2,>=1.1; extra == 'x402'
Requires-Dist: x402-agent<0.3,>=0.2; extra == 'x402'
Description-Content-Type: text/markdown

# 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

```bash
# 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

```python
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

```python
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:

```python
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

- Learn more: https://xenarch.com
- GitHub: https://github.com/xenarch-ai/xenarch-sdks

## License

MIT
