Import
Signature
PAYMENT-REQUIRED, the client verifies requirements,
constructs an Algorand transaction or 2-txn atomic group (where the server sponsors
transaction fees as fee payer), signs it, and resubmits under PAYMENT-SIGNATURE.
Funds are only deducted from the buyer’s account if the tool execution succeeds.
Parameters
URL of the server’s MCP endpoint:
"http://localhost:8000/mcp" for Streamable
HTTP or "http://localhost:8000/sse" for SSE. (The parameter keeps its 0.4
name for compatibility; it accepts either kind of URL.)Base64-encoded 32-byte Algorand private key used by the buyer to sign payments
and identity proofs.
Target Algorand network name (
"mainnet", "testnet", "localnet"),
canonical CAIP-2 identifier ("algorand:<32-char-prefix>"), or legacy long ID.Custom URL for the algod node. If None, defaults to the standard endpoint
for the given network (AlgoNode for public networks, localhost for localnet).
Whether to attach cryptographic identity headers (
x-sender-*) proving
account ownership on every request to enable vendor discounts and passes.HTTP request timeout in seconds for normal requests. Stream reads allow up
to 300 seconds.
Client-side spending limits enforced by x402Client before payment authorization:
- None (default): official x402 defaults apply — only default assets (native ALGO and USDC) are allowed, capped at 1,000,000 base atomic units (1 ALGO / 1 USDC) per payment.
- False: disables all spend controls (any asset, unlimited amount).
- dict: custom spend controls following the x402 SpendControls schema, e.g.:
{"max_amount_per_payment": False}removes the amount cap while keeping default assets,{"allowed_assets": True}allows any asset while keeping default payment cap, or{"allowed_assets": [{"network": network, "asset": "12345", "max_amount_per_payment": "5000000"}]}whitelists a specific ASA.
MCP transport to use. When omitted, Streamable HTTP is used if the URL path ends
in
/mcp and SSE otherwise, which keeps 0.4 behaviour for SSE URLs.Yields
Active, initialized MCP client session capable of invoking tools via
session.call_tool(tool_name, arguments).Raises
ConfigurationError: Iftransportis not"streamable-http"or"sse".SpendLimitExceededError: If a tool call needs a payment thatspend_controlsforbid (amount above the cap, or an asset that is not allowed). Nothing is signed and no funds move. The x402 error is its__cause__. Other errors propagate unchanged.
Examples
See also
PaymentGate: Server-side payment middleware.AIEconomySDK: High-level server framework.