{
  "markdown": "# tryx402 — the OpenRouter for agent payments\n\n<!-- mcp-name: io.github.crypto-yannso/tryx402 -->\n\n**MIT licensed. Built in France. The first open-source payment governance layer for AI agents.**\n\nA safe, **provider-agnostic** wrapper over AgentCash / x402. Not limited to\nprospecting — it drives *any* endpoint, and adds what AgentCash itself lacks and\nwe learned we need the hard way:\n\n- **hard budget caps** — stop before overspending\n- **idempotency** — never pay twice for the same call (the $0.83 double-charge lesson)\n- **cost ledger** — USD spent, reconciled, grouped by origin / account\n- **plan estimation** — price a multi-call workflow before spending a single cent\n- **signed receipts** — Ed25519 offline-verifiable proof of every payment\n- **session tokens + circuit breaker** — per-task spend caps with half-open cooldown\n- **transparent 402→pay→retry** — native httpx transport, exactly one retry, no loops\n- **discovery pipeline** — live x402 bazaar indexing (Onyx Bazaar, gold-402)\n\n## Open source, no fear\n\nThis repo is the **open-source SDK**: the safe caller, budget guard, idempotency,\nledger, CLI and MCP server. MIT licensed.\n\nWe don't hide features behind paywalls. We don't split the SDK into \"core\" and \"pro\".\nEverything is here. Use it, fork it, build on it.\n\nThe **hosted service** (https://www.tryx402.app) is the commercial engine:\nmulti-currency fiat billing, margins, FX, Stripe funding, the verified-tools\ncatalogue and the provider portal. Pricing is decided **server-side** via\n`/v1/quote` — a client-side margin is a margin nobody pays.\n\n**Revenue model**: commission on every pay-per-call transaction routed through\nthe hosted service. The SDK is free. The service takes a cut. That's it.\n\n## Positionnement\n\ntryx402 est le **premier SDK open source de gouvernance de paiements pour agents IA** \ndans l'écosystème x402. Conçu en France, distribué sous MIT, adopté par la communauté.\n\nFace aux agrégateurs propriétaires (treg.to et consorts), tryx402 défend une position \ndifférente : pas de lock-in, pas de licence restrictive, pas de \"commercial use only\". \nLe code est libre. La confiance vient du service, pas de la licence.\n\n| Face | Who | Where |\\n|---|---|---|\\n| **Power-tool** | you / an agent drive paid endpoints safely | this SDK (`gateway.cli`, `gateway.client`) |\\n| **Fiat gateway** | end users pay in their currency, you resell x402 with margin | hosted service (closed) |\n\n## Embed it (for agents)\n\n**Python — one import:**\n\n```python\nfrom gateway import Gateway\ngw = Gateway(max_budget_usd=1.0)               # safe by default\ndata = gw.call(\"https://stable-deepline.dev/api/email/validate\",\n               body={\"email\": \"x@y.com\"}, price=0.03)\nprint(gw.spent_usd)                            # 0.03\n```\n\n**Terminal — one command** (like `agentcash`), after `pip install tryx402`:\n\n```bash\ngateway call https://stable-deepline.dev/api/email/validate \\\n  --body '{\"email\":\"x@y.com\"}' --price 0.03 --max-budget 0.10\n```\n\n**MCP — two modes (pick the one you need):**\n\n### SDK MCP (pip install) — 6 tools, safe caller only\n\n```json\n{\n  \"command\": \"python3\",\n  \"args\": [\"-m\", \"tryx402.mcp_server\"],\n  \"env\": { \"TRYX402_MAX_BUDGET_USD\": \"1.00\" }\n}\n```\n\n6 tools: `gateway_search`, `gateway_discover`, `gateway_call`, `gateway_spent`,\n`gateway_plan`, `gateway_receipt`. Works directly with your x402/AgentCash\ncrypto wallet — no hosted account needed.\n\n> **You will NOT see** `gateway_check_balance`, `gateway_recharge`,\n> `gateway_lookup`, or `gateway_proxy_call` from `pip install tryx402`.\n> This is deliberate, not a bug. These tools manage your **hosted account\n> credits** (funded via Stripe, separate from your crypto wallet). The SDK\n> MCP is a safe x402 caller; the hosted gateway handles the fiat credit\n> layer. For the full 10-tool MCP, see Option B below or connect to\n> `https://www.tryx402.app/api/mcp`.\n\n### Gateway MCP (clone repo) — 10 tools, hosted account management\n\n```json\n{\n  \"mcpServers\": {\n    \"tryx402\": {\n      \"command\": \"python3\",\n      \"args\": [\"-m\", \"gateway.mcp_server\"],\n      \"env\": {\n        \"GATEWAY_MAX_BUDGET_USD\": \"1.00\"\n      }\n    }\n  }\n}\n```\n\nAll 6 SDK tools **plus** `gateway_session`, `gateway_check_balance`,\n`gateway_recharge`, `gateway_proxy_call`. No API key needed — anonymous\nsession auth throughout. `check_balance` / `recharge` manage your\n**hosted account credits** (funded via Stripe in EUR/USD — not crypto).\n\n## Layout\n\n```\ngateway/\n├── client.py    # SafeClient: any endpoint + budget + idempotency + timeout + ledger\n├── ledger.py    # cost events, USD/EUR totals, by-origin\n├── catalog.py   # search(intent) / discover(origin) over the AgentCash catalogue\n├── api.py       # Gateway facade: one-import embed + quote() for server pricing\n├── cli.py       # search / discover / call / quote\n└── tests/       # offline: budget, idempotency, on_paid hook, quote client\n```\n\n## Use\n\nDiscover (free — no payment):\n\n```bash\npython3 -m gateway.cli search \"find work email\"\npython3 -m gateway.cli discover https://stable-deepline.dev\n```\n\nCall any endpoint safely (spends USDC — budget-capped, idempotent):\n\n```bash\npython3 -m gateway.cli call https://stable-deepline.dev/api/email/validate \\\n  --body '{\"email\":\"foo@bar.com\"}' --price 0.03 --max-budget 0.10\n```\n\nAsk the hosted service what a call costs your account (server-side FX + margin):\n\n```bash\nexport TRYX402_API_KEY=\"gw_...\"        # from https://www.tryx402.app\ngateway quote 0.04\n#  -> {\"account\":\"acme\",\"currency\":\"EUR\",\"charge_minor\":5,\"charge\":\"0.05 EUR\"}\n```\n\n## What's real vs hosted\n\n- **Real (this SDK):** the safe caller, budget cap, idempotency, cost ledger, catalogue search/discover.\n- **Hosted:** accounts, balances, fiat funding (Stripe), FX conversion, margins — all decided by the server; the SDK only asks with `quote()`.\n- **Deliberately off:** auto-retry of paid calls (default `max_retries=0`) — retrying a possibly-paid call is what double-charged us; opt in only if the server honors the `Idempotency-Key` header.\n\n## Telemetry (optional)\n\ntryx402 sends **one anonymous ping on first import** to help us understand usage:\ninstall-id (random, persisted locally), package version, Python version, platform.\n\nNo PII. No tracking across sites. No personal data.\n\n**Disable it anytime:**\n```bash\nexport TRYX402_NO_TELEMETRY=1\n```\n\nOr set an empty URL to disable:\n```bash\nexport TRYX402_TELEMETRY_URL=\"\"\n```\n",
  "bytes": 6384,
  "sha": "7f76edb0a524f55ef2067050c98422a8aed34e5bd05eb039108f0ba31376e636",
  "repo_slug": "crypto-yannso/tryx402",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_crypto_yannso_tryx402_c16d7d66/readme"
}