Skip to main content
AixyzServer extends x402ResourceServer from @x402/core/server, which wraps Express 5. It provides built-in x402 payment verification for agent and tool endpoints.
import { AixyzServer } from "aixyz/server";

Constructor

new AixyzServer(
  facilitator?: FacilitatorClient,
  config?: AixyzConfig,
  express?: Express
)
ParameterTypeDefaultDescription
facilitatorFacilitatorClientDefault x402 facilitatorPayment verification service
configAixyzConfigLoaded from aixyz.config.tsAgent configuration
expressExpressNew Express 5 appExpress instance to use
After constructing, call await server.initialize() before registering any routes.

Properties

PropertyTypeDescription
configAixyzConfigThe parsed agent configuration
expressExpressThe underlying Express 5 app

Methods

withX402Exact(route, accepts)

Registers x402 payment middleware on a route:
server.withX402Exact("POST /agent", {
  scheme: "exact",
  price: "$0.005",
});
ParameterTypeDescription
route`${"GET" | "POST"} /${string}`Route pattern
acceptsAcceptsX402Payment configuration
The payTo and network fields default to the values from your aixyz.config.ts if not specified in the accepts object.

withPaymentRequirements(accepts)

Builds payment requirements for a given accepts configuration. Used internally by the MCP adapter.
const requirements = await server.withPaymentRequirements({
  scheme: "exact",
  price: "$0.001",
});

Example

import { AixyzServer } from "aixyz/server";
import { useA2A } from "aixyz/server/adapters/a2a";
import { AixyzMCP } from "aixyz/server/adapters/mcp";
import * as agent from "./agent";

const server = new AixyzServer();
await server.initialize();
server.unstable_withIndexPage();

useA2A(server, agent);

export default server;