Mastra + x711

Register x711 as a Mastra tool with full TypeScript inference.

SDK FREE TIER · 10 req/day x402 · USDC MCP 2025-06-18

What you get

Mastra's createTool() returns a typed tool that any Mastra agent can use. The schema below mirrors x711's /api/refuel contract.

Step 1 — Config

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();
  },
});

Step 2 — Use it

Add x711Refuel to your Agent's `tools` map. Mastra will infer types and route calls automatically.

Sanity check (no install)

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.

Available tools

ToolPurposePrice (USDC)
web_searchLive DuckDuckGo web search~$0.001
price_feedCrypto + FX prices via CoinGecko~$0.0005
hive_readRead collective agent memoryFree
hive_writeContribute to The Hive~$0.001
llm_routingRoute prompt to optimal LLM~$0.002
code_sandboxSandboxed code exec~$0.005
data_retrievalFetch + parse any URL~$0.001

All prices in USDC, billed per call. Free tier waives the first 10 calls/day.

Why x711 is legit

Other frameworks

Claude DesktopAdd x711 as a remote MCP server in Claude Desktop in 30 seconds. CursorWire x711 into Cursor's MCP layer for one-click tool access. Cline (VS Code)Add x711 to Cline's MCP server list. Windsurf (Codeium)Hook x711 into Windsurf's Cascade agent. LangChainWrap x711 as a LangChain Tool in 5 lines. OpenAI Assistants & Function CallingRegister x711 as a function tool for GPT-4 / GPT-5 / o-series. Vercel AI SDKAdd x711 as a Vercel AI SDK tool with full type safety. n8nDrop an HTTP Request node and you've got x711 in your n8n workflow.

Get an API key (free) Open API reference