echo tool costs 5,000 microALGO per call, a Python client that pays for it, and a JavaScript client that pays an HTTP endpoint. Everything runs on LocalNet, a private Algorand network on your machine, so no real money is involved.
Prerequisites
- Python 3.10 or newer
- Node.js 20 or newer (for the JavaScript step)
- AlgoKit and Docker, to run LocalNet
1
Start LocalNet
http://localhost:4001 and the indexer on http://localhost:8980. The examples fund new accounts from LocalNet’s built-in dispenser, so you need no keys.2
Get the examples
ai-economy-sdk 0.5.1, x402-algorand 0.3.0 and x402-avm-js 0.4.1 with their dependencies.3
Run the paid MCP server
localnet/quickstart_server.py
http://127.0.0.1:9201/mcp.4
Pay for a call from Python
In a second terminal:Source: examples/localnet/quickstart_client.pyThe buyer paid exactly the price. The server paid the 2,000 microALGO network fee.
localnet/quickstart_client.py
5
Pay from JavaScript
x402-avm-js pays any x402 endpoint on Algorand. Start a small FastAPI paywall (GET /paid on port 9221, 5,000 microALGO), then run the client:localnet/js_pay.mjs
What just happened
Your client calledecho, the server answered 402 Payment Required with a price, the client signed a payment for exactly that price and retried, and the server ran the tool and then settled the payment on chain. How it works walks through each step.
Next
Sell your own MCP tools
Price tools by input, serve them, and test with a paying client.
Paywall an HTTP API
Charge per request on FastAPI or Flask.
Let your agent pay
A budget wallet, spend limits and price checks.
Move to TestNet
Real transactions with free TestNet ALGO.