Overview
The @atxp/common package provides shared utilities, types, and interfaces that are used across all ATXP SDK packages. This package contains the foundational building blocks for authentication, payment processing, and MCP integration.
Installation
This package is typically installed automatically as a dependency when you install other ATXP packages like @atxp/client
or @atxp/express
. You only need to install it directly if you’re building custom integrations or extending the ATXP SDK.
Client Types
Account
The Account
class represents an ATXP account and handles authentication with the ATXP service.
import { Account } from '@atxp/common'
const account = new Account ( connectionString )
The ATXP connection string in the format: https://accounts.atxp.ai?connection_token=<token>
Example usage
import { Account } from '@atxp/common'
// Get connection string from environment variables
const connectionString = process . env . ATXP_CONNECTION_STRING
const account = new Account ( connectionString )
ClientArgs
Configuration interface for creating ATXP clients.
Show ClientArgs properties
The URL of the MCP server to connect to.
The ATXP account instance for authentication.
Callback function called when authorization succeeds. onAuthorize : async ( data : AuthorizationData ) => void
Callback function called when authorization fails. onAuthorizeFailure : async ( error : AuthorizationError ) => void
Callback function called when payment succeeds. onPayment : async ( data : PaymentData ) => void
Callback function called when payment fails. onPaymentFailure : async ( error : PaymentError ) => void
Custom payment approval logic. approvePayment : async ( request : PaymentRequest ) => Promise < boolean >
AuthorizationData
Data structure returned when authorization succeeds.
Show AuthorizationData properties
Unique identifier for the authorized user.
OAuth access token for API authentication.
Token used to refresh the access token when it expires.
Timestamp when the access token expires.
PaymentData
Data structure returned when payment succeeds.
Show PaymentData properties
The payment amount in USDC.
The payment currency (typically “USDC”).
Unique identifier for the payment transaction.
When the payment was processed.
Name of the tool that triggered the payment.
PaymentRequest
Data structure representing a payment request.
Show PaymentRequest properties
The requested payment amount in USDC.
The payment currency (typically “USDC”).
Name of the tool requesting payment.
Human-readable description of what the payment is for.
Error Types
AuthorizationError
Error thrown when authorization fails.
Show AuthorizationError properties
Human-readable error message describing the authorization failure.
Error code for programmatic error handling.
Additional error details and context.
PaymentError
Error thrown when payment processing fails.
Show PaymentError properties
Human-readable error message describing the payment failure.
Error code for programmatic error handling.
ID of the failed transaction, if available.
Additional error details and context.
Server Types
ATXPArgs
Configuration interface for ATXP server middleware.
The wallet address where payments will be sent.
Human-readable name for the payee, displayed during payment.