Skip to content

Commit ba40e87

Browse files
badjerclaude
andcommitted
feat: auto-register X402 + MPP protocol handlers by default
protocolHandlers now defaults to [X402ProtocolHandler, MPPProtocolHandler] instead of empty array. Developers no longer need to manually configure protocol support — all protocols work out of the box. ATXP-MCP doesn't need a handler — it's the native MCP payment flow that runs as the fallback when no protocol handler matches. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b88d870 commit ba40e87

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

packages/atxp-client/src/atxpFetcher.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ import {
2222
} from '@atxp/common';
2323
import type { PaymentMaker, ProspectivePayment, ClientConfig, PaymentFailureContext } from './types.js';
2424
import type { ProtocolHandler, ProtocolConfig } from './protocolHandler.js';
25+
import { X402ProtocolHandler } from './x402ProtocolHandler.js';
26+
import { MPPProtocolHandler } from './mppProtocolHandler.js';
27+
28+
/** Default protocol handlers — all supported protocols enabled out of the box. */
29+
const DEFAULT_PROTOCOL_HANDLERS: ProtocolHandler[] = [
30+
new X402ProtocolHandler(),
31+
new MPPProtocolHandler(),
32+
];
2533
import { InsufficientFundsError, ATXPPaymentError } from './errors.js';
2634
import { getIsReactNative, createReactNativeSafeFetch, Destination } from '@atxp/common';
2735
import { McpError } from '@modelcontextprotocol/sdk/types.js';
@@ -110,7 +118,7 @@ export class ATXPFetcher {
110118
onPayment = async () => {},
111119
onPaymentFailure,
112120
onPaymentAttemptFailed,
113-
protocolHandlers = [],
121+
protocolHandlers,
114122
protocolFlag
115123
} = config;
116124
// Use React Native safe fetch if in React Native environment
@@ -132,7 +140,7 @@ export class ATXPFetcher {
132140
this.onPayment = onPayment;
133141
this.onPaymentFailure = onPaymentFailure || this.defaultPaymentFailureHandler;
134142
this.onPaymentAttemptFailed = onPaymentAttemptFailed;
135-
this.protocolHandlers = protocolHandlers;
143+
this.protocolHandlers = protocolHandlers ?? DEFAULT_PROTOCOL_HANDLERS;
136144
this.protocolFlag = protocolFlag;
137145
}
138146

0 commit comments

Comments
 (0)