UNPKG

@agentauth/mcp

Version:

Universal payment-enabled MCP gateway for AI agents with native x402 protocol support.

70 lines 2.39 kB
/** * Universal Payment Handler * * Manages payment flows across different protocols (x402 v1.0, AgentPay v0.0.2) with * automatic protocol detection, zero-configuration chain setup, and stateless design. * * Features: * - x402 protocol prioritization (industry standard) * - AgentPay v0.0.2 fallback support * - Dynamic chain configuration based on server requirements * - Agent-centric transaction state retention */ import { type JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js'; import type { WalletService } from '../wallet/walletService.js'; import type { PaymentProtocol } from '../protocols/agentpay-v002.js'; /** * Universal payment handler that works with multiple protocols */ export declare class PaymentHandler { private walletService; private protocols; private protocolDetector; constructor(walletService: WalletService); /** * Register a payment protocol * Handles both protocols map and detector registration in single operation */ registerProtocol(name: string, protocol: PaymentProtocol): void; /** * Check if a message contains a payment request */ isPaymentRequired(message: JSONRPCMessage): boolean; /** * Process a payment required response (STATELESS) */ processPaymentRequired(message: JSONRPCMessage, originalRequest?: JSONRPCMessage): Promise<JSONRPCMessage>; /** * Check if a request contains payment authorization (STATELESS) */ hasPaymentAuthorization(message: JSONRPCMessage): boolean; /** * Process a payment authorization request (STATELESS) */ processPaymentAuthorization(message: JSONRPCMessage): Promise<{ headers?: Record<string, string>; error?: string; }>; /** * Extract request parameters */ private extractRequestParams; /** * Create an enhanced message with payment info */ private createEnhancedMessage; /** * Create an error response for payment failures */ private createErrorResponse; /** * Estimate gas cost for transaction with robust error handling * Returns { costEth: string, sufficient: boolean, errorMessage?: string } */ private estimateTransactionGas; /** * Extract USDC amount from transaction data */ private extractAmountFromTransaction; } //# sourceMappingURL=paymentHandler.d.ts.map