Trust-gated x402 buyer client — pay for machine-economy APIs safely (pre-payment trust gate, local spend policy, receipts ledger). Powered by Aegis (aegis.borisinc.com).
Project description
aegis-buy
Trust-gated buyer client for the x402 machine economy. Your agent wants to pay APIs with USDC over HTTP 402 — this package makes sure it never pays the wrong service, the wrong amount, or more than you allowed.
Powered by Aegis, the trusted agent-commerce hub.
probe (free) -> parse price -> Aegis trust gate -> local spend policy -> pay -> receipt
Every step before "pay" is free and local. Nothing settles unless the service passes the trust gate and your policy caps.
Install
pip install aegis-buy # library
pip install 'aegis-buy[mcp]' # + MCP server (aegis-buy-mcp)
Quickstart
from aegis_buy import BuyClient
client = BuyClient() # key from AEGIS_BUY_KEY env
r = client.get("https://api.example.com/price?symbol=ETH")
print(r["ok"], r["price_usd"], r["data"])
# Don't know a provider? Let the hub find a trusted one within budget:
r = client.procure("live ETH price", budget=0.01)
# Test everything without spending a cent:
client = BuyClient(dry_run=True)
Environment variables
| Var | Meaning | Default |
|---|---|---|
AEGIS_BUY_KEY |
EVM private key of the buyer wallet (funds USDC on Base) | — |
AEGIS_BUY_POLICY |
Path to spend policy JSON | ~/.aegis-buy/policy.json |
AEGIS_BUY_LEDGER |
Path to sqlite receipts ledger | ~/.aegis-buy/ledger.db |
AEGIS_HUB |
Aegis hub base URL | https://aegis.borisinc.com |
AEGIS_BUY_DRY_RUN |
1 = MCP server never actually pays |
off |
Spend policy (~/.aegis-buy/policy.json)
{
"max_per_call_usd": 0.05,
"max_per_day_usd": 1.00,
"max_total_usd": 10.00,
"min_tier": "provisional",
"allow_domains": [],
"deny_domains": ["sketchy.example"],
"trust_mode": "basic"
}
max_per_call_usd/max_per_day_usd/max_total_usd— hard USD caps. Day and total spend are computed from the local ledger.min_tier— minimum Aegis trust tier:unverified<provisional<trusted. Services flagged by Aegis are always blocked.allow_domains/deny_domains— domain allow/deny lists (subdomains match).trust_mode—basic(free Aegis signals),strict(paid $0.002 verification-backed trust check per service, itself policy-capped), oroff.
Missing file = safe defaults (5¢/call, $1/day, provisional+, basic gate).
MCP server
Give Claude Desktop (or any MCP client) a safe x402 wallet:
{
"mcpServers": {
"aegis-buy": {
"command": "aegis-buy-mcp",
"env": {
"AEGIS_BUY_KEY": "0xYOUR_BUYER_WALLET_PRIVATE_KEY",
"AEGIS_BUY_POLICY": "~/.aegis-buy/policy.json"
}
}
}
}
Tools: buy_get(url, params_json) · procure(need, budget) · trust_gate(url) · spend_stats().
Safety model
- Local spend policy — per-call, per-day, and lifetime USD caps enforced before any payment; domain allow/deny lists. The wallet's downside is bounded by config.
- Pre-payment trust gate — services are checked against Aegis's continuously
verified registry before money moves. Unknown services default to
unverified; flagged services are always blocked. - Receipts ledger — every attempt (paid, blocked, failed, dry-run) lands in a local sqlite ledger; caps are computed from it, so they survive restarts.
- No blind buys — if the price can't be parsed from the 402 challenge, the purchase is refused.
- Delivery protection via Aegis — routes purchased through the hub use auth-then-capture: your payment only settles after the upstream actually delivers, so you are never charged for non-delivery.
Use a dedicated buyer wallet funded with only what you're willing to spend — defense in depth on top of the policy caps.
Links
- Hub: https://aegis.borisinc.com — free discovery:
GET /discover?query=... - x402 protocol: HTTP 402 + USDC on Base (
eip155:8453)
MIT license.
LangChain
from aegis_buy.langchain_adapter import get_tools
tools = get_tools() # buy_get, procure, trust_gate, spend_stats
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aegis_buy-0.1.0.tar.gz.
File metadata
- Download URL: aegis_buy-0.1.0.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6639448ae47399e1d29f7365682ead9259851a0a3d7c7db7c1d0f415462122f
|
|
| MD5 |
1a1bb3b747cd06f818cc49e5afcda814
|
|
| BLAKE2b-256 |
9f4b85f44a2c6c17f2afdd3e3be3afe3c220af4977bd25a2c377d2ba5e7e4f90
|
File details
Details for the file aegis_buy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aegis_buy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddfefb3443195cba02517be037a1f96233b5a91ba87c0cee77853185e044dddb
|
|
| MD5 |
4295b6b2d50b722766f5cdd8635f6e67
|
|
| BLAKE2b-256 |
03da8ef77d2ae4ec2df16ec1045baa17ba0302aa55934858d3190c8e8b840e56
|