UNPKG

@thorium-dev-group/x402-mcp-extension

Version:
56 lines 2.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/client/streamableHttp.js"); const X402MCPClient_1 = require("../../client/X402MCPClient"); const x402PKWalletProvider_1 = require("../../client/x402PKWalletProvider"); const accounts_1 = require("viem/accounts"); const InMemoryStorage_1 = require("../../shared/services/InMemoryStorage"); async function simpleClientExample() { console.log('🚀 Simple X402 MCP Client Example'); const privateKey = (0, accounts_1.generatePrivateKey)(); const walletProvider = new x402PKWalletProvider_1.X402PKWalletProvider(privateKey); const client1 = new X402MCPClient_1.X402MCPClient({ name: 'client-with-provider', version: '1.0.0', wallet: walletProvider, auditStorage: InMemoryStorage_1.InMemoryStorage.getInstance(), }); const client2 = new X402MCPClient_1.X402MCPClient({ clientInfo: { name: 'client-with-private-key', version: '1.0.0' }, wallet: (0, accounts_1.generatePrivateKey)(), guardrails: { maxPaymentPerCall: 0.01, }, }); const client3 = new X402MCPClient_1.X402MCPClient({ clientInfo: { name: 'minimal-client', version: '1.0.0' }, wallet: (0, accounts_1.generatePrivateKey)(), }); console.log('✅ Created three different client configurations'); console.log('📋 Client 1: Full configuration with audit storage'); console.log('📋 Client 2: With guardrails, no audit storage'); console.log('📋 Client 3: Minimal configuration'); const transport = new streamableHttp_js_1.StreamableHTTPClientTransport(new URL('http://localhost:3000/mcp')); await client1.connect(transport); try { const result = await client1.callTool({ name: 'free-calculator', arguments: { operation: 'add', a: 5, b: 3 } }); console.log('✅ Tool call result:', result); } catch (error) { console.log('❌ Tool call failed:', error.message); } finally { await transport.close(); } } simpleClientExample().catch(console.error); //# sourceMappingURL=simple-client.js.map