In five minutes you will have an MCP server whose 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

algod listens on 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

This installs 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
Source: examples/localnet/quickstart_server.py
That address receives the payments; it is new on every run. The server answers MCP calls at http://127.0.0.1:9201/mcp.
4

Pay for a call from Python

In a second terminal:
localnet/quickstart_client.py
Source: examples/localnet/quickstart_client.py
The buyer paid exactly the price. The server paid the 2,000 microALGO network fee.
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
Source: examples/localnet/js_pay.mjs
The last line is a spend limit at work: the script caps payments at 10,000 microALGO, so a 50,000 microALGO demand is refused before the wallet signs anything.
To run every LocalNet example in order, with the servers they need started and stopped for you:

What just happened

Your client called echo, 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.