{"slug": "show-hn-how-to-use-mu-tools-for-agents-with-x402-payments", "title": "Show HN: How to use Mu – Tools for Agents – with x402 payments", "summary": "Mu, an open-source MCP server by Micro, now accepts USDC payments via Coinbase's x402 protocol, enabling agents to pay for tools without holding ETH or creating accounts. A live transaction on Base mainnet (block 49920226) shows an agent paying 0.020000 USDC with gas covered by a facilitator, and the server at https://micro.mu responds to unpaid requests with a 402 challenge specifying price and payment details.", "body_md": "# How to use Mu - tools for agents - with x402 payments\n\nFor a while I’ve been playing around with Mu - an open source project that provides tools for agents behind one MCP server and app.\n\nYou can find it on github [https://github.com/micro/mu](https://github.com/micro/mu).\n\nI started to wonder how to turn this into something I could run and charge money for. Then spent some time building out payments using stripe and a top-up credit model. Eventually getting tired of that, I realised agents should probably do this without an account using Coinbase’s [x402](https://x402.org/) protocol.\n\nThis is an example of how to use an agent to pay for MCP tools with a USDC wallet and x402 on the live instance of Mu at [https://micro.mu](https://micro.mu).\n\n## What is x402\n\nHTTP 402 was reserved in 1997 and left unimplemented for two decades. [x402](https://x402.org) puts it to work: a server answers `402`\n\nwith a machine-readable price, the client pays on-chain and retries, and the whole exchange takes one round trip with no human involvement. I guess its no more interesting than adding a credit card to some cloud account and getting an API token. But what if in the long term your agent could discover and use many different x402 servers with no human involvement. Thats where it gets interesting. But we have to enable that future first. And so Mu accepts USDC payments using x402 as an experiment to test the thesis.\n\nNote: You can run your own Mu server and make some money doing it!\n\n## A transaction\n\nHere’s a real call, on Base mainnet, from an agent when doing this experiment:\n\n| Status | SUCCESS — block 49920226 |\n| Tx | `0x58d2ac05de3b410ee4f9c2af0e9977a270be5bf8559cf054a23228f95f0e3a54` |\n| Amount | 0.020000 USDC |\n| From | `0x4160A86303eeBA12fc0A3FFB8480A9d2D1eAb7A1` (the agent) |\n| To | `0x9a717EFF039622231C65ADbF7B2A002b544b06A9` (the server) |\n| Gas paid by | `0x67b9ce70…` — the facilitator, not the payer |\n| Payer ETH | 0.0 — it has never held any |\n\nThe paying wallet holds no ETH and never needed any. It signs an authorisation; somebody else pays the gas to execute it. An agent can therefore be funded with nothing but the money it spends — no gas token, no top-up effort, no account or token to deal with. Maybe many of us are thinking, so what? We are no crypto experts. Well turns out ethereum “gas” fees can add up to a lot, so using USDC on Base cuts through a lot of that.\n\n## What happens on the wire\n\nFour steps, and only the third involves any cryptography you have to think about.\n\n**Call as normal.** An ordinary request with no credentials. Free endpoints just answer — which matters more than it sounds, and we will come back to it.**Read the 402.** The body names the price, the asset, the chain and the address to pay. Nothing is hardcoded in the client; the server declares its own terms.**Sign an authorisation.** An[EIP-3009](https://eips.ethereum.org/EIPS/eip-3009)`transferWithAuthorization`\n\nfor exactly that amount. It moves nothing by itself — it is permission, not a transfer.**Retry with the header.** The server presents the signature to a facilitator, which settles it on-chain and pays the gas. The tool answers in the same response.\n\nHere is a real challenge, from a live server:\n\n``` bash\n$ curl -s -X POST https://micro.mu/mcp \\\n    -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\n         \"params\":{\"name\":\"web_search\",\"arguments\":{\"query\":\"x402\"}}}'\n{\n  \"x402Version\": 1,\n  \"accepts\": [{\n    \"scheme\":  \"exact\",\n    \"network\": \"base\",\n    \"maxAmountRequired\": \"20000\",\n    \"asset\":   \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\n    \"payTo\":   \"0x9a717EFF039622231C65ADbF7B2A002b544b06A9\",\n    \"extra\":   { \"name\": \"USD Coin\", \"version\": \"2\" }\n  }]\n}\n```\n\n`maxAmountRequired`\n\nis in atomic units — 20000 is $0.02. You can run that command right now. It costs nothing to be told a price.\n\n## Paying it, in about ten lines\n\nYou don’t need to implement any of this. The [x402 Foundation](https://github.com/x402-foundation/x402) ships clients for Go, TypeScript, Python and Java. In Go, the payment lives inside an ordinary `http.Client`\n\n, so the calling code has no payment logic in it at all:\n\n```\nsigner, _ := evmsigners.NewClientSignerFromPrivateKey(os.Getenv(\"X402_PRIVATE_KEY\"))\n\n// v1 names its networks \"base\"; v2 uses CAIP-2. Registering both\n// is one line and survives a server upgrading underneath you.\nclient := x402.Newx402Client().\n    RegisterV1(\"base\", evmv1.NewExactEvmSchemeV1(signer)).\n    Register(\"eip155:*\", evm.NewExactEvmScheme(signer, nil))\n\nhttpClient := x402http.WrapHTTPClientWithPayment(\n    http.DefaultClient,\n    x402http.Newx402HTTPClient(client),\n)\n\n// From here it's just HTTP. The 402, the signature and the\n// retry all happen inside RoundTrip.\nresp, _ := httpClient.Post(server+\"/mcp\", \"application/json\", body)\n```\n\n**The error you hit first** is an empty wallet, and facilitators report it as `execution reverted`\n\n— words that say nothing about funding anything. If you are building the server side, catch that case and say *“this wallet has no USDC”*. It is the single most common first-run failure and the least self-explanatory message in the stack.\n\n## The part that makes agents work\n\nAgents can’t use tools they can’t see. If reading the catalogue cost money, you would be back to signing up before you can evaluate anything — a subscription with extra steps.\n\nSo `tools/list`\n\ntakes no credentials and costs nothing:\n\n``` bash\n$ curl -s -X POST https://micro.mu/mcp \\\n    -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/list\"}' | jq '.result.tools | length'\n96\n```\n\nNinety-six tools so far — names, descriptions and JSON schemas. The agent learns what’s available then decides what answers the question, and only then spends when it needs to. Plus half of them are free anyway.\n\n## A loop that spends its own money\n\nWith a paying HTTP client and a free catalogue, an agent is smaller than you would expect. This is the whole thing:\n\n```\ntools := fetchCatalogue(server)        // free\nprompt := question\n\nfor step := 0; step < maxSteps; step++ {\n    reply := model.Ask(systemFor(tools), prompt, history)\n\n    call, isTool := parseToolCall(reply)\n    if !isTool {\n        return reply                   // it answered\n    }\n\n    out := payAndCall(call.Tool, call.Args)   // 402 → sign → retry\n\n    history = append(history, turn{prompt, reply})\n    prompt = \"Result of \" + call.Tool + \":\\n\" + out\n}\n```\n\nA detail easy to miss. The loop needs to be stopped — a model that keeps calling tools without converging is spending real money on every iteration. You can do that by max steps or looking at wallet balance or success of the response. Here we just have max steps. and then exit when its no longer a tool call.\n\n## What it costs\n\nNot everything is priced, and that is deliberate rather than generous. A free tier an anonymous caller can actually reach is the on-ramp — it is what lets an agent prove the integration works before any money moves.\n\n| Call | What it does | Price |\n|---|---|---|\n`tools/list` |\nthe whole catalogue | free |\n`news_list` |\nheadlines, summarised | free |\n`markets_list` |\ncrypto, stocks, FX | free |\n`weather_forecast` |\npaid weather provider | $0.01 |\n`web_search` |\npaid search provider | $0.02 |\n`image_generate` |\na model call | $0.15 |\n\nThirteen of the twenty-nine priced operations cost nothing. A call is charged when it costs something to run — a model, or a third party they are billed for. Calls that only touch the server’s own storage are free, but that could always be changed.\n\n## What we’re building\n\nThe loop above is now a command — `mu agent`\n\n— in [Mu](https://github.com/micro/mu), which is also the server it calls. It brings your model and your wallet, reads its capabilities from a remote instance, and pays per call.\n\n``` bash\n$ mu agent\n96 tools from https://micro.mu\npaying from 0x4160a863… (1.271017 USDC)\n\n> what are the top news headlines today?\n· news_list\n…\n> of those, which matters most for markets?\n… answered with no tool call, and no charge\n```\n\nWhat it does *not* do is include the model. There is no inference tool in the catalogue. The model is the one thing every developer already has I think. Bring your own model basically; rent everything else two pence at a time.\n\n## Try it\n\n`mu`\n\nis the server in this post and also an agent that calls it\n\n### 1. Install\n\n```\ncurl -fsSL https://raw.githubusercontent.com/micro/mu/main/install.sh | sh\n```\n\n### 2. Bring a model\n\nThe tools are rented; the thinking is yours. Any one of these:\n\n```\nexport ANTHROPIC_API_KEY=sk-ant-...                 # console.anthropic.com\nexport OPENROUTER_API_KEY=sk-or-...                 # openrouter.ai/keys\nexport OPENAI_BASE_URL=http://localhost:11434/v1    # Ollama, or any\n                                                    # OpenAI-compatible server\n```\n\n### 3. Make a wallet and fund it\n\n```\nmu wallet new\naddress: 0x60810c050048bf048659626e7706496ba46f5036\nkey:     ~/.mu/keys/wallet.seed (0600)\n\nSend USDC on Base to that address to fund it. No ETH is needed —\npayments are signed here and the gas is paid by whoever settles them.\n\nBack this file up. It is the only copy, and it is the money.\n```\n\nSend it **USDC on Base**. A dollar is fifty web searches.\n\nIf you skip this step entirely, `mu agent`\n\nmakes a wallet for you on first run\nand tells you it needs funding. The free tools work either way.\n\n### 4. Ask\n\n```\nmu agent                                  # a conversation\nmu agent \"what happened in markets today?\"   # one-shot\nmodel: anthropic/claude-sonnet-4-6\n96 tools from https://micro.mu\nwallet: 0x4160a863… (1.27 USDC)\n\n> what are the top news headlines today?\n· news_list\n\nHere's a balanced roundup across politics, finance, tech…\n\n> of those, which matters most for markets?\n\n… answered with no tool call, and no charge\n\nspent 0.000000 USDC\n```\n\nThe `·`\n\nlines are tool calls. Free ones cost nothing and say nothing about\npayment; a priced one signs, pays and retries before the answer comes back. What\na session spent is read off the chain when it ends — not totted up from what the\nagent believes it authorised.\n\nPoint it somewhere else with `--server`\n\n, or at your own instance:\n\n```\nmu agent --server https://your-instance.example \"what's in my inbox?\"\nmu --serve       # ...which is the same binary, being the server instead\n```\n\n## Things to note\n\nSome technical stuff\n\n- Settlement goes through a facilitator. That is an operational dependency, not a trustless one — the facilitator can decline.\n- The tool-call protocol here is JSON-in-prose rather than native function calling, which is portable across providers and less reliable than either.\n- Paying a remote instance means it sees your queries. Self-hosting for control and renting tools for convenience pull in opposite directions.\n\n## What next\n\nSo what’s the overall value? Hand an agent a wallet, let it call whatever it needs to. The more people who run these servers, the more we can add to an X402_SERVERS list or some form of dynamic discovery to provide access to more and more tools.\n\nI’m still working out a lot of the details but if you want to follow along, Join the discord or checkout the source code below.\n\n- Source:\n[github.com/micro/mu](https://github.com/micro/mu)— the worked example is`examples/x402-agent`\n\n- Protocol:\n[x402.org](https://x402.org)·[x402-foundation/x402](https://github.com/x402-foundation/x402) - Discord:\n[https://discord.gg/G8Gk5j3uXr](https://discord.gg/G8Gk5j3uXr)\n\n### Comments\n\n[Login](/login) to add a comment\n\nNo comments yet. Be the first to comment!", "url": "https://wpnews.pro/news/show-hn-how-to-use-mu-tools-for-agents-with-x402-payments", "canonical_source": "https://micro.mu/blog/post?id=1786633600633959421", "published_at": "2026-08-13 15:28:54+00:00", "updated_at": "2026-08-13 15:44:36.171429+00:00", "lang": "en", "topics": ["ai-agents", "ai-infrastructure", "ai-tools"], "entities": ["Mu", "Micro", "Coinbase", "x402", "Base", "USDC", "EIP-3009", "x402 Foundation"], "alternates": {"html": "https://wpnews.pro/news/show-hn-how-to-use-mu-tools-for-agents-with-x402-payments", "markdown": "https://wpnews.pro/news/show-hn-how-to-use-mu-tools-for-agents-with-x402-payments.md", "text": "https://wpnews.pro/news/show-hn-how-to-use-mu-tools-for-agents-with-x402-payments.txt", "jsonld": "https://wpnews.pro/news/show-hn-how-to-use-mu-tools-for-agents-with-x402-payments.jsonld"}}