Agent (app/agent.ts)
Your agent is defined using Vercel AI SDK (ai@^6). The file exports a default ToolLoopAgent and an optional accepts for payment pricing.
ToolLoopAgent
The ToolLoopAgent from Vercel AI SDK handles multi-step tool execution loops automatically. It:
- Takes a model, instructions, and a set of tools
- Executes tool calls in a loop until the stop condition is met
- Returns the final response
accepts Export
The optional accepts named export controls x402 payment gating on the A2A /agent endpoint:
- Agents with
acceptsare registered on payment-gated A2A endpoints - Agents without
acceptsare not registered
Tools (app/tools/*.ts)
Each .ts file in app/tools/ exports a Vercel AI SDK tool and an optional accepts for MCP payment gating. Tools are automatically discovered and registered on both A2A and MCP endpoints.
Tool Discovery
The build pipeline automatically discovers all.ts files in app/tools/:
- Each file is registered as an MCP tool
- Tools with
acceptsare payment-gated on the/mcpendpoint - Tools without
acceptsare not registered on MCP
Files starting with
_ (e.g., _helpers.ts) are ignored by the build pipeline. Use this convention for shared
utilities.Per-Tool Pricing
Each tool can declare its own price, enabling granular pricing across your agent:Custom Server
For full control over endpoint registration and middleware, createapp/server.ts. This overrides auto-generation entirely: