Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (create-aixyz-app) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
aixyz
Framework for bundling AI agents into deployable services with A2A, MCP, x402 payments, and ERC-8004 identity.
Write your agent logic. aixyz wires up the protocols, payments, and deployment.
Prerequisites
Install Bun if you don't have it:
curl -fsSL https://bun.sh/install | bashQuick Start
bunx create-aixyz-app my-agent
cd my-agent
bun install
bun run devYour agent is running. It exposes:
| Endpoint | Protocol | What it does |
|---|---|---|
/.well-known/agent-card.json |
A2A | Agent discovery card |
/agent |
A2A | JSON-RPC endpoint, x402 payment gate |
/mcp |
MCP | Tool sharing with MCP clients |
How It Works
An aixyz agent has three parts: a config, an agent, and tools.
1. Config
aixyz.config.ts declares your agent's identity, payment address, and skills:
import type { AixyzConfig } from "aixyz/config";
const config: AixyzConfig = {
name: "Weather Agent",
description: "Get current weather for any location worldwide.",
version: "0.1.0",
x402: {
payTo: "0x...",
network: "eip155:8453", // Base mainnet
},
skills: [
{
id: "get-weather",
name: "Get Weather",
description: "Get current weather conditions for any city or location",
tags: ["weather"],
examples: ["What's the weather in Tokyo?"],
},
],
};
export default config;2. Agent
app/agent.ts defines your agent, its payment price, and A2A capabilities:
import { openai } from "@ai-sdk/openai";
import { stepCountIs, ToolLoopAgent } from "ai";
import type { Accepts } from "aixyz/accepts";
import type { Capabilities } from "aixyz/app/plugins/a2a";
import weather from "./tools/weather";
export const accepts: Accepts = {
scheme: "exact",
price: "$0.005",
};
export const capabilities: Capabilities = {
streaming: true, // default: true — set to false to use generate() instead of stream()
pushNotifications: false, // default: false
};
export default new ToolLoopAgent({
model: openai("gpt-4o-mini"),
instructions: "You are a helpful weather assistant.",
tools: { weather },
stopWhen: stepCountIs(10),
});3. Tools
Each file in app/tools/ exports a Vercel AI SDK tool and an optional accepts for MCP payment gating:
import { tool } from "ai";
import { z } from "zod";
import type { Accepts } from "aixyz/accepts";
export const accepts: Accepts = {
scheme: "exact",
price: "$0.0001",
};
export default tool({
description: "Get current weather conditions for a city.",
inputSchema: z.object({
location: z.string().describe("City name"),
}),
execute: async ({ location }) => {
// your logic here
},
});That's it. Run bun run dev and aixyz auto-generates the server, wires up A2A + MCP + x402, and starts serving.
Custom Server
For full control, create app/server.ts instead. This takes precedence over auto-generation:
import { AixyzApp } from "aixyz/app";
import { IndexPagePlugin } from "aixyz/app/plugins/index-page";
import { A2APlugin } from "aixyz/app/plugins/a2a";
import { MCPPlugin } from "aixyz/app/plugins/mcp";
import * as agent from "./agent";
import lookup from "./tools/lookup";
const server = new AixyzApp();
// Index page: human-readable agent info
await server.withPlugin(new IndexPagePlugin());
// A2A: agent discovery + JSON-RPC endpoint
await server.withPlugin(new A2APlugin(agent));
// MCP: expose tools to MCP clients
await server.withPlugin(
new MCPPlugin([
{
name: "lookup",
exports: {
default: lookup,
accepts: { scheme: "exact", price: "$0.001" },
},
},
]),
);
await server.initialize();
export default server;Configuration
| Field | Type | Required | Description |
|---|---|---|---|
name |
string |
Yes | Agent display name |
description |
string |
Yes | What the agent does |
version |
string |
Yes | Semver version |
url |
string |
No | Agent base URL. Auto-detected on Vercel |
x402.payTo |
string |
Yes | EVM address to receive payments |
x402.network |
string |
Yes | Payment network (eip155:8453 for Base) |
skills |
AgentSkill[] |
No | Skills your agent exposes (used in A2A agent card) |
Environment variables are loaded in the same order as Next.js: .env, .env.local, .env.$(NODE_ENV),
.env.$(NODE_ENV).local.
Payment (Accepts)
Each agent and tool declares an accepts export to control payment:
// Require x402 payment
export const accepts: Accepts = {
scheme: "exact",
price: "$0.005", // USD-denominated
network: "eip155:8453", // optional, defaults to config.x402.network
payTo: "0x...", // optional, defaults to config.x402.payTo
};Agents and tools without an accepts export are not registered.
CLI
aixyz dev
Starts a local dev server with hot reload. Watches app/ and aixyz.config.ts for changes.
aixyz dev # default port 3000
aixyz dev -p 4000 # custom portaixyz build
Bundles your agent for deployment. Default output goes to .aixyz/output/server.js.
aixyz build # standalone (default), outputs to .aixyz/output/server.js
bun .aixyz/output/server.js # run the standalone build
aixyz build --output vercel # Vercel Build Output API v3, outputs to .vercel/output/
vercel deploy # deploy the Vercel build
aixyz build --output executable # self-contained binary, no Bun runtime required
./.aixyz/output/server # run directlyaixyz erc-8004 register
Register your agent's on-chain identity (ERC-8004). Creates
app/erc-8004.ts if it doesn't exist, asks for your deployment URL, and writes the registration back to the file after a successful on-chain transaction.
aixyz erc-8004 register --url "https://my-agent.vercel.app" --chain base-sepolia --broadcastaixyz erc-8004 update
Update the metadata URI of a registered agent. Reads registrations from
app/erc-8004.ts and lets you select which one to update.
aixyz erc-8004 update --url "https://new-domain.example.com" --broadcastProtocols
A2A (Agent-to-Agent) — Generates an agent card at /.well-known/agent-card.json and a JSON-RPC endpoint at
/agent. Protocol version 0.3.0. Other agents discover yours and send tasks via JSON-RPC.
MCP (Model Context Protocol) — Exposes your tools at /mcp using
WebStandardStreamableHTTPServerTransport. Any MCP client (Claude Desktop, VS Code, Cursor) can connect and call your tools.
x402 — HTTP 402 micropayments. Clients pay per-request with an
X-Payment header containing cryptographic payment proof. No custodial wallets, no subscriptions. Payments are verified on-chain via a facilitator.
ERC-8004 — On-chain agent identity. Register your agent on Ethereum, Base, Polygon, Scroll, Monad, BSC, or Gnosis so other agents and contracts can reference it.
Agent File Structure
my-agent/
aixyz.config.ts # Agent config (required)
app/
agent.ts # Agent definition (required if no server.ts)
server.ts # Custom server (optional, overrides auto-generation)
erc-8004.ts # ERC-8004 identity registration (optional)
tools/
weather.ts # Tool exports (files starting with _ are ignored)
icon.png # Agent icon (served as static asset)
public/ # Static assets
vercel.json # Vercel deployment config
.env.local # Local environment variablesEnvironment Variables
| Variable | Description |
|---|---|
X402_PAY_TO |
Default payment recipient address |
X402_NETWORK |
Default payment network (e.g. eip155:8453) |
X402_FACILITATOR_URL |
Custom facilitator (default: https://x402.use-agently.com/facilitator) |
CDP_API_KEY_ID |
Coinbase CDP API key ID (uses Coinbase facilitator) |
CDP_API_KEY_SECRET |
Coinbase CDP API key secret |
STRIPE_SECRET_KEY |
Enable experimental Stripe payment adapter |
OPENAI_API_KEY |
OpenAI API key (for agents using OpenAI models) |
Examples
| Example | Description |
|---|---|
boilerplate |
Minimal starter (auto-generated server) |
chainlink |
Chainlink data feeds with custom server |
flight-search |
Flight search with Stripe payments |
local-llm |
Local LLM via Docker (no external API) |
with-custom-facilitator |
Bring-your-own x402 facilitator |
with-custom-server |
Custom server setup |
with-express |
Express middleware integration |
sub-agents |
Multiple A2A endpoints from one deployment |
with-tests |
Agent with test examples |
fake-llm |
Fully deterministic testing with fake() model |
Contributing
bun install
bun run build
bun run formatLicense
MIT