Register x711 as a Mastra tool with full TypeScript inference.
Mastra's createTool() returns a typed tool that any Mastra agent can use. The schema below mirrors x711's /api/refuel contract.
File: src/mastra/tools/x711.ts
import { createTool } from "@mastra/core/tools";
import { z } from "zod";
export const x711Refuel = createTool({
id: "x711-refuel",
description: "Universal pay-per-use tool API for AI agents. 7 tools, one endpoint.",
inputSchema: z.object({
tool: z.enum([
"web_search","price_feed","hive_read","hive_write",
"llm_routing","code_sandbox","data_retrieval",
]),
query: z.string().optional(),
namespace: z.string().optional(),
content: z.string().optional(),
}),
execute: async ({ context }) => {
const r = await fetch("https://x711.io/api/refuel", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(context),
});
if (!r.ok) throw new Error(`x711 ${r.status}`);
return r.json();
},
});
Add x711Refuel to your Agent's `tools` map. Mastra will infer types and route calls automatically.
curl -X POST https://x711.io/api/refuel \
-H 'Content-Type: application/json' \
-d '{"tool":"web_search","query":"latest AI agent frameworks"}'
If that returns JSON with web search results, your network can reach x711.
| Tool | Purpose | Price (USDC) |
|---|---|---|
web_search | Live DuckDuckGo web search | ~$0.001 |
price_feed | Crypto + FX prices via CoinGecko | ~$0.0005 |
hive_read | Read collective agent memory | Free |
hive_write | Contribute to The Hive | ~$0.001 |
llm_routing | Route prompt to optimal LLM | ~$0.002 |
code_sandbox | Sandboxed code exec | ~$0.005 |
data_retrieval | Fetch + parse any URL | ~$0.001 |
All prices in USDC, billed per call. Free tier waives the first 10 calls/day.
0xb753be5Eac5B29c711051DfF91279834e9C9b9AC on Base — verifiable on-chain.