Skip to main content
This guide shows you how to connect an AI agent (Claude Desktop, Cursor, or any MCP client) as an autonomous buyer that discovers merchants on-chain and pays for their services — all without human intervention.

What You’re Building

An AI agent that can:
  • Discover merchants from the decentralized on-chain registry
  • Read their service manifests and pricing
  • Check their reputation and trust scores
  • Pay for services with USDC on Solana
  • Return the purchased data to you

Option A: MCP Client (Zero Code)

Connect Claude Desktop to the MCP server and let it handle everything.
1

Clone & Build

git clone https://github.com/xavierScript/agent-economy-wallet.git
cd agent-economy-wallet
pnpm install && pnpm build
2

Configure MCP Client

Add the server to your MCP client config:
// ~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "agent-economy-wallet": {
      "command": "node",
      "args": ["/absolute/path/to/packages/mcp-server/dist/index.js"]
    }
  }
}
Restart Claude Desktop.
3

Create & Fund a Wallet

Open Claude and ask: “Create a new wallet for me”Claude will create an agent wallet and display the public key. Fund it with:
  • Devnet SOL (for gas) — use faucet.solana.com or solana airdrop 2 <PUBLIC_KEY> --url devnet
  • Devnet USDC — transfer from your existing wallet
4

Run the Autonomous Purchase

Paste this prompt into Claude:
Query the on-chain agent registry to discover available merchants. Pick a merchant, check their reputation, read their manifest, then buy the cheapest service they offer. Show me the result and the Solana explorer link.

What Claude Does Autonomously

StepMCP ToolWhat happens
1discover_registryScans Solana for registered merchants
2read_manifestReads merchant’s services + pricing
3check_reputationChecks trust score (success rate, total transactions)
4probe_x402Confirms on-chain payment requirements
5Policy checkWallet policy engine approves the spend
6pay_x402_invoiceSends USDC → Solana tx confirmed
7Data receivedReturns the purchased data to you
No human touched steps 1–7. The agent discovered, evaluated, paid, and received data completely autonomously.

Option B: SDK Integration (Programmatic)

If you want to build a buyer agent programmatically:
import {
  AgentWallet,
  discoverRegistry,
  X402Client,
} from "agent-economy-wallet";

// 1. Initialize wallet
const wallet = new AgentWallet({ cluster: "devnet" });
await wallet.initialize();

// 2. Discover merchants from on-chain registry
const conn = wallet.services.connection.getConnection();
const agents = await discoverRegistry(conn, 100);

// 3. Pay for a service
const response = await wallet.services.x402Client.fetchWithPayment(
  "http://merchant.com/api/premium-data",
  { method: "GET" }
);

const data = await response.json();
console.log(data);

Available MCP Tools

Discovery (free, read-only)

ToolInputDescription
discover_registry(none)Scan the on-chain registry for all registered merchants
read_manifestmanifest_urlRead a merchant’s services, pricing, and capabilities
check_reputationreputation_urlCheck merchant trust score and success rate

Payment

ToolInputDescription
probe_x402urlCheck the price of an x402 endpoint without paying
pay_x402_invoiceurl, wallet_idPay for an endpoint and receive the data

Wallet

ToolInputDescription
create_walletlabelCreate a new agent wallet
get_balancewallet_idCheck wallet balance (SOL + SPL tokens)
send_solwallet_id, to, amountTransfer SOL
send_tokenwallet_id, mint, to, amountTransfer SPL tokens

How the On-Chain Registry Works

The registry is fully decentralized — it lives on the Solana blockchain, not in any database.
  • Registration: Merchants send an SPL Memo transaction containing their manifest URL — cost: ~$0.001, permanent.
  • Discovery: Buyers call getSignaturesForAddress on the registry wallet, parse valid memos, and verify each manifest is live.
  • No gatekeeper: Anyone can register. No approval process. No single point of failure.
  • Survivability: If every server goes offline, any buyer can reconstruct the full registry from a fresh RPC call.