Overview

The ATXP client library provides a comprehensive API for integrating pay-per-use functionality into your agents and MCP tools. This reference covers the core functions, types, and configuration options.

Installation

npm install @atxp/sdk

Core agent functions

atxpClient(options)

import { atxpClient } from '@atxp/sdk'

const client = await atxpClient({
  mcpServer: 'https://browse.mcp.atxp.ai/',
  account: new Account(atxpConnectionString),
})
Returns a client object that can be used to interact with MCP servers.
options
ATXPClientConfig
required
Configuration options for the client:

Core MCP server functions

atxpServer(options)

Express middleware that handles payment processing for MCP tools.
options
ATXPConfig
required
Configuration options for the payment middleware.
router
Express Router
Express middleware router function that can be used with app.use().
import { atxpServer } from '@atxp/sdk'

const app = express()

app.use(atxpServer({
  destination: 'your_wallet_id',
  payeeName: 'Your Tool Name'
}))

requirePayment(options)

Requires payment before executing a tool. This function must be called before any paid tool logic.
price
BigNumber
required
The price to charge in USDC.
import { requirePayment } from '@atxp/sdk'
import BigNumber from 'bignumber.js'

await requirePayment({
  price: BigNumber('0.01') // 0.01 USDC
})