@t402/mcp 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -135,6 +135,12 @@ interface McpServerConfig {
135
135
  seedPhrase?: string;
136
136
  /** WDK chains to support (e.g., ['ethereum', 'arbitrum']) */
137
137
  wdkChains?: string[];
138
+ /** Enable unified mode (base + WDK + unified tools) */
139
+ unifiedMode?: boolean;
140
+ /** @ton/mcp server URL for TON bridge tools */
141
+ tonMcpEndpoint?: string;
142
+ /** TON API key for direct TON bridge tool execution */
143
+ tonApiKey?: string;
138
144
  }
139
145
  /**
140
146
  * Tool execution context
@@ -148,4 +154,86 @@ interface ToolContext {
148
154
  getPublicClient: (network: SupportedNetwork) => Promise<unknown>;
149
155
  }
150
156
 
151
- export type { BridgeFeeQuote as B, ChainBalance as C, GaslessPaymentResult as G, McpServerConfig as M, PaymentParams as P, SupportedNetwork as S, TokenBalance as T, BridgeResult as a, PaymentResult as b, ToolContext as c };
157
+ /**
158
+ * TON MCP Bridge - Connects @ton/mcp tools with @t402/mcp
159
+ *
160
+ * Enables AI agents to perform end-to-end TON payment flows by
161
+ * proxying @ton/mcp's 15 blockchain tools through the t402 MCP server.
162
+ */
163
+ /**
164
+ * Configuration for the TON MCP bridge
165
+ */
166
+ interface TonMcpBridgeConfig {
167
+ /** @ton/mcp server URL or SSE endpoint */
168
+ tonMcpEndpoint?: string;
169
+ /** TON API key for direct calls (e.g., toncenter.com API key) */
170
+ tonApiKey?: string;
171
+ /** Enable demo mode (simulates calls without executing) */
172
+ demoMode?: boolean;
173
+ }
174
+ /**
175
+ * Tool input/output schema type
176
+ */
177
+ interface ToolSchema {
178
+ type: 'object';
179
+ properties: Record<string, {
180
+ type: string;
181
+ description: string;
182
+ enum?: string[];
183
+ }>;
184
+ required: string[];
185
+ }
186
+ /**
187
+ * TON bridge tool definition
188
+ */
189
+ interface TonBridgeTool {
190
+ name: string;
191
+ description: string;
192
+ inputSchema: ToolSchema;
193
+ }
194
+ /**
195
+ * Proxy tool definitions from @ton/mcp
196
+ *
197
+ * These map to the tools available in the @ton/mcp server.
198
+ * When registered, they proxy requests to the @ton/mcp endpoint.
199
+ */
200
+ declare const TON_BRIDGE_TOOLS: Record<string, TonBridgeTool>;
201
+ /**
202
+ * Execute a TON bridge tool call
203
+ *
204
+ * Proxies the tool call to the @ton/mcp endpoint or executes it
205
+ * directly using the TON API key.
206
+ *
207
+ * @param toolName - Name of the tool to execute
208
+ * @param args - Tool arguments
209
+ * @param config - Bridge configuration
210
+ * @returns Tool execution result
211
+ */
212
+ declare function executeTonBridgeTool(toolName: string, args: Record<string, unknown>, config: TonMcpBridgeConfig): Promise<{
213
+ content: Array<{
214
+ type: 'text';
215
+ text: string;
216
+ }>;
217
+ isError?: boolean;
218
+ }>;
219
+ /**
220
+ * Register TON bridge tools on a t402 MCP server
221
+ *
222
+ * This function adds the TON bridge tools to the server's tool registry,
223
+ * enabling AI agents to use TON blockchain operations alongside t402 payment tools.
224
+ *
225
+ * @param config - Bridge configuration
226
+ * @returns Tool definitions and handler
227
+ */
228
+ declare function createTonBridgeToolSet(config: TonMcpBridgeConfig): {
229
+ definitions: Record<string, TonBridgeTool>;
230
+ handleToolCall(name: string, args: Record<string, unknown>): Promise<{
231
+ content: Array<{
232
+ type: "text";
233
+ text: string;
234
+ }>;
235
+ isError?: boolean;
236
+ }>;
237
+ };
238
+
239
+ export { type BridgeFeeQuote as B, type ChainBalance as C, type GaslessPaymentResult as G, type McpServerConfig as M, type PaymentParams as P, type SupportedNetwork as S, type TokenBalance as T, type BridgeResult as a, type PaymentResult as b, type ToolContext as c, TON_BRIDGE_TOOLS as d, type TonMcpBridgeConfig as e, createTonBridgeToolSet as f, executeTonBridgeTool as g };
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { S as SupportedNetwork, C as ChainBalance, b as PaymentResult, G as GaslessPaymentResult, B as BridgeFeeQuote, a as BridgeResult } from '../types-CwwW_c2B.js';
2
+ import { S as SupportedNetwork, C as ChainBalance, b as PaymentResult, G as GaslessPaymentResult, B as BridgeFeeQuote, a as BridgeResult } from '../ton-bridge-BN3RKhNy.js';
3
+ export { d as TON_BRIDGE_TOOLS, e as TonMcpBridgeConfig, f as createTonBridgeToolSet, g as executeTonBridgeTool } from '../ton-bridge-BN3RKhNy.js';
3
4
  import { T402WDK } from '@t402/wdk';
4
5
  import 'viem';
5
6
 
@@ -535,6 +536,222 @@ declare function executeAutoPayDemo(input: AutoPayInput): AutoPayResult;
535
536
  */
536
537
  declare function formatAutoPayResult(result: AutoPayResult): string;
537
538
 
539
+ /**
540
+ * Unified MCP Toolkit - Combines WDK wallet tools with t402 payment tools.
541
+ *
542
+ * Agent workflow: check price -> check balance -> bridge if needed -> pay
543
+ * All in one MCP session with a single server.
544
+ */
545
+
546
+ /**
547
+ * Configuration for unified MCP mode
548
+ */
549
+ interface UnifiedMcpConfig {
550
+ /** WDK seed phrase for wallet management */
551
+ wdkSeedPhrase?: string;
552
+ /** Chain RPC configurations */
553
+ chains?: Record<string, string | string[]>;
554
+ /** Enable auto-pay mode (automatic balance check + bridge + pay) */
555
+ autoPayEnabled?: boolean;
556
+ }
557
+ /**
558
+ * SmartPay input schema
559
+ */
560
+ declare const smartPayInputSchema: z.ZodObject<{
561
+ url: z.ZodString;
562
+ maxBridgeFee: z.ZodOptional<z.ZodString>;
563
+ preferredNetwork: z.ZodOptional<z.ZodString>;
564
+ }, "strip", z.ZodTypeAny, {
565
+ url: string;
566
+ maxBridgeFee?: string | undefined;
567
+ preferredNetwork?: string | undefined;
568
+ }, {
569
+ url: string;
570
+ maxBridgeFee?: string | undefined;
571
+ preferredNetwork?: string | undefined;
572
+ }>;
573
+ type SmartPayInput = z.infer<typeof smartPayInputSchema>;
574
+ /**
575
+ * SmartPay result
576
+ */
577
+ interface SmartPayResult {
578
+ /** Whether the resource was successfully accessed */
579
+ success: boolean;
580
+ /** HTTP status code */
581
+ statusCode: number;
582
+ /** Response body (truncated if large) */
583
+ body: string;
584
+ /** Content type of the response */
585
+ contentType?: string;
586
+ /** Steps taken during smart payment */
587
+ steps: SmartPayStep[];
588
+ /** Payment details (if payment was made) */
589
+ payment?: {
590
+ network: string;
591
+ scheme: string;
592
+ amount: string;
593
+ payTo: string;
594
+ };
595
+ /** Error message (if failed) */
596
+ error?: string;
597
+ }
598
+ /**
599
+ * A step in the smart payment flow
600
+ */
601
+ interface SmartPayStep {
602
+ action: 'check_price' | 'check_balance' | 'bridge' | 'pay' | 'fetch';
603
+ status: 'success' | 'skipped' | 'failed';
604
+ detail: string;
605
+ }
606
+ /**
607
+ * PaymentPlan input schema
608
+ */
609
+ declare const paymentPlanInputSchema: z.ZodObject<{
610
+ paymentRequired: z.ZodObject<{
611
+ scheme: z.ZodOptional<z.ZodString>;
612
+ network: z.ZodOptional<z.ZodString>;
613
+ maxAmountRequired: z.ZodOptional<z.ZodString>;
614
+ resource: z.ZodOptional<z.ZodString>;
615
+ description: z.ZodOptional<z.ZodString>;
616
+ payTo: z.ZodOptional<z.ZodString>;
617
+ maxDeadline: z.ZodOptional<z.ZodNumber>;
618
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
619
+ scheme: z.ZodOptional<z.ZodString>;
620
+ network: z.ZodOptional<z.ZodString>;
621
+ maxAmountRequired: z.ZodOptional<z.ZodString>;
622
+ resource: z.ZodOptional<z.ZodString>;
623
+ description: z.ZodOptional<z.ZodString>;
624
+ payTo: z.ZodOptional<z.ZodString>;
625
+ maxDeadline: z.ZodOptional<z.ZodNumber>;
626
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
627
+ scheme: z.ZodOptional<z.ZodString>;
628
+ network: z.ZodOptional<z.ZodString>;
629
+ maxAmountRequired: z.ZodOptional<z.ZodString>;
630
+ resource: z.ZodOptional<z.ZodString>;
631
+ description: z.ZodOptional<z.ZodString>;
632
+ payTo: z.ZodOptional<z.ZodString>;
633
+ maxDeadline: z.ZodOptional<z.ZodNumber>;
634
+ }, z.ZodTypeAny, "passthrough">>;
635
+ }, "strip", z.ZodTypeAny, {
636
+ paymentRequired: {
637
+ network?: string | undefined;
638
+ description?: string | undefined;
639
+ scheme?: string | undefined;
640
+ payTo?: string | undefined;
641
+ maxAmountRequired?: string | undefined;
642
+ resource?: string | undefined;
643
+ maxDeadline?: number | undefined;
644
+ } & {
645
+ [k: string]: unknown;
646
+ };
647
+ }, {
648
+ paymentRequired: {
649
+ network?: string | undefined;
650
+ description?: string | undefined;
651
+ scheme?: string | undefined;
652
+ payTo?: string | undefined;
653
+ maxAmountRequired?: string | undefined;
654
+ resource?: string | undefined;
655
+ maxDeadline?: number | undefined;
656
+ } & {
657
+ [k: string]: unknown;
658
+ };
659
+ }>;
660
+ type PaymentPlanInput = z.infer<typeof paymentPlanInputSchema>;
661
+ /**
662
+ * Payment plan result
663
+ */
664
+ interface PaymentPlanResult {
665
+ /** Whether a viable plan was found */
666
+ viable: boolean;
667
+ /** Recommended network to pay on */
668
+ recommendedNetwork?: string;
669
+ /** Available balance on that network */
670
+ availableBalance?: string;
671
+ /** Whether bridging is needed */
672
+ bridgeRequired: boolean;
673
+ /** Bridge details if needed */
674
+ bridgeDetails?: {
675
+ fromChain: string;
676
+ toChain: string;
677
+ amount: string;
678
+ estimatedFee: string;
679
+ };
680
+ /** Balances across all chains */
681
+ balances: Array<{
682
+ chain: string;
683
+ usdt0: string;
684
+ usdc: string;
685
+ }>;
686
+ /** Reason if not viable */
687
+ reason?: string;
688
+ }
689
+ /**
690
+ * Unified tool definitions (additional tools beyond base + WDK)
691
+ */
692
+ declare const UNIFIED_TOOL_DEFINITIONS: {
693
+ readonly 't402/smartPay': {
694
+ readonly name: "t402/smartPay";
695
+ readonly description: "Intelligent payment that automatically checks balance, bridges if needed, and pays. Handles the entire payment flow for 402-protected resources.";
696
+ readonly inputSchema: {
697
+ readonly type: "object";
698
+ readonly properties: {
699
+ readonly url: {
700
+ readonly type: "string";
701
+ readonly description: "URL of the 402-protected resource";
702
+ };
703
+ readonly maxBridgeFee: {
704
+ readonly type: "string";
705
+ readonly description: "Maximum acceptable bridge fee in native token (optional)";
706
+ };
707
+ readonly preferredNetwork: {
708
+ readonly type: "string";
709
+ readonly description: "Preferred network for payment (optional)";
710
+ };
711
+ };
712
+ readonly required: readonly ["url"];
713
+ };
714
+ };
715
+ readonly 't402/paymentPlan': {
716
+ readonly name: "t402/paymentPlan";
717
+ readonly description: "Analyze a 402 response and create an optimal payment plan considering balances across all chains. Returns recommended network, bridge requirements, and balance overview.";
718
+ readonly inputSchema: {
719
+ readonly type: "object";
720
+ readonly properties: {
721
+ readonly paymentRequired: {
722
+ readonly type: "object";
723
+ readonly description: "The 402 PaymentRequired response";
724
+ };
725
+ };
726
+ readonly required: readonly ["paymentRequired"];
727
+ };
728
+ };
729
+ };
730
+ /**
731
+ * Execute t402/smartPay tool
732
+ */
733
+ declare function executeSmartPay(input: SmartPayInput, wdk: T402WDK): Promise<SmartPayResult>;
734
+ /**
735
+ * Execute t402/smartPay in demo mode
736
+ */
737
+ declare function executeSmartPayDemo(input: SmartPayInput): SmartPayResult;
738
+ /**
739
+ * Execute t402/paymentPlan tool
740
+ */
741
+ declare function executePaymentPlan(input: PaymentPlanInput, wdk: T402WDK): Promise<PaymentPlanResult>;
742
+ /**
743
+ * Execute t402/paymentPlan in demo mode
744
+ */
745
+ declare function executePaymentPlanDemo(_input: PaymentPlanInput): PaymentPlanResult;
746
+ /**
747
+ * Format smartPay result for display
748
+ */
749
+ declare function formatSmartPayResult(result: SmartPayResult): string;
750
+ /**
751
+ * Format paymentPlan result for display
752
+ */
753
+ declare function formatPaymentPlanResult(result: PaymentPlanResult): string;
754
+
538
755
  /**
539
756
  * t402 MCP Tools - Export all payment tools
540
757
  */
@@ -821,4 +1038,4 @@ declare const WDK_TOOL_DEFINITIONS: {
821
1038
  };
822
1039
  };
823
1040
 
824
- export { type AllBalancesResult, type AutoPayInput, type AutoPayResult, type BridgeInput, type BridgeOptions, GASLESS_SUPPORTED_NETWORKS, type GetAllBalancesInput, type GetBalanceInput, type GetBridgeFeeInput, type PayGaslessInput, type PayGaslessOptions, type PayInput, type PayOptions, TOOL_DEFINITIONS, WDK_TOOL_DEFINITIONS, type WdkBalancesResult, type WdkGetBalancesInput, type WdkGetWalletInput, type WdkSwapInput, type WdkSwapResult, type WdkTransferInput, type WdkTransferResult, type WdkWalletInfo, autoPayInputSchema, bridgeInputSchema, executeAutoPay, executeAutoPayDemo, executeBridge, executeGetAllBalances, executeGetBalance, executeGetBridgeFee, executePay, executePayGasless, executeWdkGetBalances, executeWdkGetBalancesDemo, executeWdkGetWallet, executeWdkGetWalletDemo, executeWdkSwap, executeWdkSwapDemo, executeWdkTransfer, executeWdkTransferDemo, formatAllBalancesResult, formatAutoPayResult, formatBalanceResult, formatBridgeFeeResult, formatBridgeResult, formatGaslessPaymentResult, formatPaymentResult, formatWdkBalancesResult, formatWdkSwapResult, formatWdkTransferResult, formatWdkWalletResult, getAllBalancesInputSchema, getBalanceInputSchema, getBridgeFeeInputSchema, payGaslessInputSchema, payInputSchema, wdkGetBalancesInputSchema, wdkGetWalletInputSchema, wdkSwapInputSchema, wdkTransferInputSchema };
1041
+ export { type AllBalancesResult, type AutoPayInput, type AutoPayResult, type BridgeInput, type BridgeOptions, GASLESS_SUPPORTED_NETWORKS, type GetAllBalancesInput, type GetBalanceInput, type GetBridgeFeeInput, type PayGaslessInput, type PayGaslessOptions, type PayInput, type PayOptions, type PaymentPlanInput, type PaymentPlanResult, type SmartPayInput, type SmartPayResult, type SmartPayStep, TOOL_DEFINITIONS, UNIFIED_TOOL_DEFINITIONS, type UnifiedMcpConfig, WDK_TOOL_DEFINITIONS, type WdkBalancesResult, type WdkGetBalancesInput, type WdkGetWalletInput, type WdkSwapInput, type WdkSwapResult, type WdkTransferInput, type WdkTransferResult, type WdkWalletInfo, autoPayInputSchema, bridgeInputSchema, executeAutoPay, executeAutoPayDemo, executeBridge, executeGetAllBalances, executeGetBalance, executeGetBridgeFee, executePay, executePayGasless, executePaymentPlan, executePaymentPlanDemo, executeSmartPay, executeSmartPayDemo, executeWdkGetBalances, executeWdkGetBalancesDemo, executeWdkGetWallet, executeWdkGetWalletDemo, executeWdkSwap, executeWdkSwapDemo, executeWdkTransfer, executeWdkTransferDemo, formatAllBalancesResult, formatAutoPayResult, formatBalanceResult, formatBridgeFeeResult, formatBridgeResult, formatGaslessPaymentResult, formatPaymentPlanResult, formatPaymentResult, formatSmartPayResult, formatWdkBalancesResult, formatWdkSwapResult, formatWdkTransferResult, formatWdkWalletResult, getAllBalancesInputSchema, getBalanceInputSchema, getBridgeFeeInputSchema, payGaslessInputSchema, payInputSchema, paymentPlanInputSchema, smartPayInputSchema, wdkGetBalancesInputSchema, wdkGetWalletInputSchema, wdkSwapInputSchema, wdkTransferInputSchema };