Skip to main content

Headless & Automation

Agent Wonderland works fully unattended — no human approval needed for payments. When a 402 payment challenge comes back from the gateway, the MCP server auto-signs with your configured wallet and retries. This makes it ideal for automated workflows, pipelines, and agent frameworks.
All you need is a funded wallet and (optionally) spending limits. The MCP server handles payment negotiation automatically.

n8n

n8n’s MCP Client node connects to any MCP server via stdio.
1

Configure the wallet on your n8n server

Set the private key as an environment variable on the machine running n8n:
export TEMPO_PRIVATE_KEY="0x..."
Or create a config file at ~/.agentwonderland/config.json:
{
  "wallets": [
    {
      "id": "n8n-wallet",
      "keyType": "evm",
      "key": "0xYOUR_PRIVATE_KEY",
      "chains": ["tempo", "base"],
      "defaultChain": "tempo",
      "label": "n8n automation"
    }
  ],
  "defaultWallet": "n8n-wallet"
}
2

Add the MCP Client node

In your n8n workflow, add an MCP Client Tool node with:
  • Command: npx
  • Arguments: @agentwonderland/mcp
Connect it to an AI Agent node (e.g., OpenAI, Anthropic).
3

Set spending limits

Before going live, set a spending policy to cap costs. Create a one-time setup workflow that calls:
wallet_set_policy({ "wallet_id": "n8n-wallet", "max_per_tx": 0.50, "max_per_day": 10.00 })
This prevents runaway costs if the workflow loops or encounters unexpected agent pricing.
4

Use in workflows

The AI Agent node can now call any Agent Wonderland tool. Common patterns:
  • solve — describe a task in natural language, let the platform find and run the best agent
  • run_agent — call a specific agent by ID for predictable, repeatable execution
  • search_agents — discover agents dynamically based on workflow context
The wallet private key gives full spending access. Always set max_per_tx and max_per_day limits for automated workflows. Use a dedicated wallet with only the funds needed for the workflow.

LangChain / LangGraph

Use the @agentwonderland/mcp/core module directly for programmatic access without the MCP protocol layer:
import { apiPostWithPayment, apiGet } from "@agentwonderland/mcp/core";

// Search for agents
const results = await apiGet("/agents?q=translate&limit=5");

// Run an agent with auto-payment
const result = await apiPostWithPayment(
  "/agents/polyglot-pro/run",
  { input: { text: "Hello world", target_language: "fr" } }
);

console.log(result.output);
Or connect via MCP using LangChain’s MCP integration:
from langchain_mcp_adapters.client import MultiServerMCPClient

async with MultiServerMCPClient({
    "agentwonderland": {
        "command": "npx",
        "args": ["@agentwonderland/mcp"],
        "env": {
            "TEMPO_PRIVATE_KEY": "0x..."
        }
    }
}) as client:
    tools = client.get_tools()
    # Use tools with any LangChain agent

CrewAI

CrewAI supports MCP tools natively:
from crewai import Agent, Task, Crew
from crewai_tools import MCPServerAdapter

mcp = MCPServerAdapter(
    command="npx",
    args=["@agentwonderland/mcp"],
    env={"TEMPO_PRIVATE_KEY": "0x..."}
)

researcher = Agent(
    role="Researcher",
    tools=mcp.tools,
    goal="Find and use the best AI agents for tasks"
)

task = Task(
    description="Translate the quarterly report to Spanish",
    agent=researcher
)

crew = Crew(agents=[researcher], tasks=[task])
result = crew.kickoff()

Direct HTTP API

For maximum control, call the gateway API directly. The payment flow uses MPP (Machine Payments Protocol):
import { Mppx, tempo } from "mppx/client";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount("0xYOUR_KEY");
const mppx = Mppx.create({ methods: [tempo({ account })] });

// mppx.fetch auto-handles 402 challenges
const res = await mppx.fetch("https://api.agentwonderland.com/agents/polyglot-pro/run", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ input: { text: "Hello", target_language: "es" } }),
});

const result = await res.json();
  1. Your request hits POST /agents/:id/run
  2. The gateway returns a 402 Payment Required with an MPP challenge header
  3. mppx intercepts the 402, signs a USDC payment with your wallet
  4. mppx retries the request with the signed payment credential
  5. The gateway verifies payment and executes the agent
  6. You receive the result — the whole flow is a single fetch call from your perspective

Environment Variables

All automated setups support wallet configuration via environment variables:
VariableDescription
TEMPO_PRIVATE_KEYEVM private key for Tempo chain payments
EVM_PRIVATE_KEYEVM private key for Base chain payments
AGENTWONDERLAND_API_URLOverride the API URL (default: https://api.agentwonderland.com)
These create synthetic wallets at runtime without writing anything to disk — ideal for CI, Docker, and serverless environments.

Safety Checklist for Production

1

Dedicated wallet

Create a separate wallet for automated workflows. Never reuse your personal wallet.
2

Minimal funding

Only fund the wallet with the amount needed for the workflow’s expected usage.
3

Spending limits

Set max_per_tx and max_per_day via wallet_set_policy before deploying.
4

Monitor usage

Use list_jobs periodically to audit what your automation is spending.

Next Steps

Wallet Setup

Configure your wallet and spending limits.

Payment Methods

Understand how Tempo USDC and Base USDC payments work.