web3-tools-mcp 1.3.0 → 1.3.2

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.
@@ -0,0 +1,111 @@
1
+ import { z } from 'zod';
2
+ declare const _default: {
3
+ send_native_token: {
4
+ title: string;
5
+ description: string;
6
+ schema: z.ZodObject<{
7
+ chain: z.ZodEnum<["mainnet", "arbitrum", "avalanche", "base", "bnb", "gnosis", "sonic", "optimism", "polygon", "zksync", "linea", "unichain", "localhost"]>;
8
+ to: z.ZodString;
9
+ amount: z.ZodString;
10
+ data: z.ZodOptional<z.ZodString>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
13
+ to: string;
14
+ amount: string;
15
+ data?: string | undefined;
16
+ }, {
17
+ chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
18
+ to: string;
19
+ amount: string;
20
+ data?: string | undefined;
21
+ }>;
22
+ handler: (args: {
23
+ chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
24
+ to: string;
25
+ amount: string;
26
+ data?: string | undefined;
27
+ }) => Promise<import("../types.js").ToolResult>;
28
+ };
29
+ send_erc20_token: {
30
+ title: string;
31
+ description: string;
32
+ schema: z.ZodObject<{
33
+ chain: z.ZodEnum<["mainnet", "arbitrum", "avalanche", "base", "bnb", "gnosis", "sonic", "optimism", "polygon", "zksync", "linea", "unichain", "localhost"]>;
34
+ tokenAddress: z.ZodString;
35
+ to: z.ZodString;
36
+ amount: z.ZodString;
37
+ decimals: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
38
+ }, "strip", z.ZodTypeAny, {
39
+ chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
40
+ to: string;
41
+ tokenAddress: string;
42
+ decimals: number;
43
+ amount: string;
44
+ }, {
45
+ chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
46
+ to: string;
47
+ tokenAddress: string;
48
+ amount: string;
49
+ decimals?: number | undefined;
50
+ }>;
51
+ handler: (args: {
52
+ chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
53
+ to: string;
54
+ tokenAddress: string;
55
+ decimals: number;
56
+ amount: string;
57
+ }) => Promise<import("../types.js").ToolResult>;
58
+ };
59
+ call_contract_write: {
60
+ title: string;
61
+ description: string;
62
+ schema: z.ZodObject<{
63
+ chain: z.ZodEnum<["mainnet", "arbitrum", "avalanche", "base", "bnb", "gnosis", "sonic", "optimism", "polygon", "zksync", "linea", "unichain", "localhost"]>;
64
+ contractAddress: z.ZodString;
65
+ functionAbi: z.ZodString;
66
+ args: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">>;
67
+ value: z.ZodOptional<z.ZodString>;
68
+ }, "strip", z.ZodTypeAny, {
69
+ chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
70
+ contractAddress: string;
71
+ functionAbi: string;
72
+ value?: string | undefined;
73
+ args?: (string | number | boolean)[] | undefined;
74
+ }, {
75
+ chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
76
+ contractAddress: string;
77
+ functionAbi: string;
78
+ value?: string | undefined;
79
+ args?: (string | number | boolean)[] | undefined;
80
+ }>;
81
+ handler: (args: {
82
+ chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
83
+ contractAddress: string;
84
+ functionAbi: string;
85
+ value?: string | undefined;
86
+ args?: (string | number | boolean)[] | undefined;
87
+ }) => Promise<import("../types.js").ToolResult>;
88
+ };
89
+ sign_message: {
90
+ title: string;
91
+ description: string;
92
+ schema: z.ZodObject<{
93
+ message: z.ZodString;
94
+ }, "strip", z.ZodTypeAny, {
95
+ message: string;
96
+ }, {
97
+ message: string;
98
+ }>;
99
+ handler: (args: {
100
+ message: string;
101
+ }) => Promise<import("../types.js").ToolResult>;
102
+ };
103
+ wallet_status: {
104
+ title: string;
105
+ description: string;
106
+ schema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
107
+ handler: (args: {}) => Promise<import("../types.js").ToolResult>;
108
+ };
109
+ };
110
+ export default _default;
111
+ //# sourceMappingURL=transactions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../../src/tools/transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWvB,wBAyOC"}
@@ -0,0 +1,198 @@
1
+ import { z } from 'zod';
2
+ import { getWalletServer } from '../wallet-server.js';
3
+ import { SUPPORTED_CHAINS } from '../client.js';
4
+ import { parseUnits, encodeFunctionData, parseAbiItem } from 'viem';
5
+ import { randomBytes } from 'crypto';
6
+ import { createTool, formatResponse } from '../utils.js';
7
+ function generateRequestId() {
8
+ return randomBytes(16).toString('hex');
9
+ }
10
+ export default {
11
+ send_native_token: createTool('Send Native Token', 'Send native tokens (ETH, MATIC, BNB, etc.) to an address. Opens browser wallet for approval.', z.object({
12
+ chain: z.enum(SUPPORTED_CHAINS).describe('Blockchain network'),
13
+ to: z.string().describe('Recipient address'),
14
+ amount: z.string().describe('Amount in native token (e.g., "0.1" for 0.1 ETH)'),
15
+ data: z.string().optional().describe('Optional hex-encoded data to include with transaction')
16
+ }), async (args) => {
17
+ const walletServer = getWalletServer();
18
+ try {
19
+ // Parse amount to wei
20
+ const value = '0x' + parseUnits(args.amount, 18).toString(16);
21
+ const txRequest = {
22
+ id: generateRequestId(),
23
+ type: 'send_transaction',
24
+ chain: args.chain,
25
+ data: {
26
+ to: args.to,
27
+ value,
28
+ ...(args.data && { data: args.data })
29
+ }
30
+ };
31
+ console.error(`[Transaction] Sending ${args.amount} native token to ${args.to} on ${args.chain}`);
32
+ const txHash = await walletServer.sendTransaction(txRequest);
33
+ return formatResponse({
34
+ success: true,
35
+ chain: args.chain,
36
+ transactionHash: txHash,
37
+ to: args.to,
38
+ amount: args.amount,
39
+ message: `Successfully sent ${args.amount} native token`,
40
+ explorerUrl: `https://etherscan.io/tx/${txHash}`
41
+ });
42
+ }
43
+ catch (error) {
44
+ const errorMessage = error instanceof Error ? error.message : String(error);
45
+ return formatResponse({
46
+ success: false,
47
+ error: errorMessage,
48
+ message: 'Transaction failed or was rejected'
49
+ });
50
+ }
51
+ }),
52
+ send_erc20_token: createTool('Send ERC20 Token', 'Send ERC20 tokens to an address. Opens browser wallet for approval.', z.object({
53
+ chain: z.enum(SUPPORTED_CHAINS).describe('Blockchain network'),
54
+ tokenAddress: z.string().describe('ERC20 token contract address'),
55
+ to: z.string().describe('Recipient address'),
56
+ amount: z.string().describe('Amount in token units (e.g., "100" for 100 USDC)'),
57
+ decimals: z.number().optional().default(18).describe('Token decimals (default: 18)')
58
+ }), async (args) => {
59
+ const walletServer = getWalletServer();
60
+ try {
61
+ const decimals = args.decimals || 18;
62
+ const amountWei = parseUnits(args.amount, decimals);
63
+ // ERC20 transfer(address to, uint256 amount)
64
+ const data = `0xa9059cbb${args.to.slice(2).padStart(64, '0')}${amountWei.toString(16).padStart(64, '0')}`;
65
+ const txRequest = {
66
+ id: generateRequestId(),
67
+ type: 'send_transaction',
68
+ chain: args.chain,
69
+ data: {
70
+ to: args.tokenAddress,
71
+ data,
72
+ value: '0x0'
73
+ }
74
+ };
75
+ console.error(`[Transaction] Sending ${args.amount} tokens to ${args.to} on ${args.chain}`);
76
+ const txHash = await walletServer.sendTransaction(txRequest);
77
+ return formatResponse({
78
+ success: true,
79
+ chain: args.chain,
80
+ transactionHash: txHash,
81
+ tokenAddress: args.tokenAddress,
82
+ to: args.to,
83
+ amount: args.amount,
84
+ message: `Successfully sent ${args.amount} tokens`,
85
+ explorerUrl: `https://etherscan.io/tx/${txHash}`
86
+ });
87
+ }
88
+ catch (error) {
89
+ const errorMessage = error instanceof Error ? error.message : String(error);
90
+ return formatResponse({
91
+ success: false,
92
+ error: errorMessage,
93
+ message: 'Token transfer failed or was rejected'
94
+ });
95
+ }
96
+ }),
97
+ call_contract_write: createTool('Call Contract (Write)', 'Call a state-changing contract function (write operation). Opens browser wallet for approval.', z.object({
98
+ chain: z.enum(SUPPORTED_CHAINS).describe('Blockchain network'),
99
+ contractAddress: z.string().describe('Contract address'),
100
+ functionAbi: z.string().describe('Function ABI definition (e.g., "function transfer(address to, uint256 amount)")'),
101
+ args: z.array(z.union([z.string(), z.number(), z.boolean()])).optional().describe('Function arguments in order matching the ABI signature'),
102
+ value: z.string().optional().describe('Optional ETH value to send with transaction (in ETH units, e.g., "0.1")')
103
+ }), async (args) => {
104
+ const walletServer = getWalletServer();
105
+ try {
106
+ // Parse the function ABI and encode the call data
107
+ console.error(`[Transaction] Parsing ABI: ${args.functionAbi}`);
108
+ console.error(`[Transaction] Args: ${JSON.stringify(args.args)}`);
109
+ const abiItem = parseAbiItem(args.functionAbi);
110
+ console.error(`[Transaction] Parsed function: ${abiItem.name}`);
111
+ const data = encodeFunctionData({
112
+ abi: [abiItem],
113
+ functionName: abiItem.name,
114
+ args: (args.args || [])
115
+ });
116
+ console.error(`[Transaction] Encoded data: ${data}`);
117
+ const valueHex = args.value ? '0x' + parseUnits(args.value, 18).toString(16) : '0x0';
118
+ const txRequest = {
119
+ id: generateRequestId(),
120
+ type: 'send_transaction',
121
+ chain: args.chain,
122
+ data: {
123
+ to: args.contractAddress,
124
+ data,
125
+ value: valueHex
126
+ }
127
+ };
128
+ console.error(`[Transaction] Calling ${abiItem.name}() on ${args.contractAddress} (${args.chain})`);
129
+ const txHash = await walletServer.sendTransaction(txRequest);
130
+ return formatResponse({
131
+ success: true,
132
+ chain: args.chain,
133
+ transactionHash: txHash,
134
+ contractAddress: args.contractAddress,
135
+ functionName: abiItem.name,
136
+ message: `Contract call to ${abiItem.name}() successful`,
137
+ explorerUrl: `https://etherscan.io/tx/${txHash}`
138
+ });
139
+ }
140
+ catch (error) {
141
+ console.error(`[Transaction] Error:`, error);
142
+ const errorMessage = error instanceof Error ? error.message : String(error);
143
+ return formatResponse({
144
+ success: false,
145
+ error: errorMessage,
146
+ message: 'Contract call failed or was rejected'
147
+ });
148
+ }
149
+ }),
150
+ sign_message: createTool('Sign Message', 'Sign a message with the connected wallet. Opens browser wallet for approval.', z.object({
151
+ message: z.string().describe('Message to sign')
152
+ }), async (args) => {
153
+ const walletServer = getWalletServer();
154
+ try {
155
+ const request = {
156
+ id: generateRequestId(),
157
+ type: 'sign_message',
158
+ chain: 'any',
159
+ data: {
160
+ message: args.message
161
+ }
162
+ };
163
+ console.error(`[Transaction] Signing message`);
164
+ const signature = await walletServer.sendTransaction(request);
165
+ return formatResponse({
166
+ success: true,
167
+ message: args.message,
168
+ signature,
169
+ signatureType: 'personal_sign'
170
+ });
171
+ }
172
+ catch (error) {
173
+ const errorMessage = error instanceof Error ? error.message : String(error);
174
+ return formatResponse({
175
+ success: false,
176
+ error: errorMessage,
177
+ message: 'Message signing failed or was rejected'
178
+ });
179
+ }
180
+ }),
181
+ wallet_status: createTool('Wallet Status', 'Check if a wallet is connected to the browser interface', z.object({}), async () => {
182
+ const walletServer = getWalletServer();
183
+ const isConnected = walletServer.isConnected();
184
+ const port = walletServer.getPort();
185
+ // Auto-open browser if no wallet connected
186
+ if (!isConnected) {
187
+ walletServer.openBrowser();
188
+ }
189
+ return formatResponse({
190
+ connected: isConnected,
191
+ walletUrl: `http://localhost:${port}`,
192
+ message: isConnected
193
+ ? 'Wallet is connected and ready to sign transactions'
194
+ : `No wallet connected. Opening browser to connect... Visit http://localhost:${port} if it didn't open automatically.`
195
+ });
196
+ })
197
+ };
198
+ //# sourceMappingURL=transactions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactions.js","sourceRoot":"","sources":["../../src/tools/transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,YAAY,EAAoB,MAAM,MAAM,CAAA;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAExD,SAAS,iBAAiB;IACxB,OAAO,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AACxC,CAAC;AAED,eAAe;IACb,iBAAiB,EAAE,UAAU,CAC3B,mBAAmB,EACnB,8FAA8F,EAC9F,CAAC,CAAC,MAAM,CAAC;QACP,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,oBAAoB,CAAC;QAC9D,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC;QAC5C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC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,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,EAAE,CAAA;QAC9C,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,EAAE,CAAA;QAEnC,2CAA2C;QAC3C,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,YAAY,CAAC,WAAW,EAAE,CAAA;QAC5B,CAAC;QAED,OAAO,cAAc,CAAC;YACpB,SAAS,EAAE,WAAW;YACtB,SAAS,EAAE,oBAAoB,IAAI,EAAE;YACrC,OAAO,EAAE,WAAW;gBAClB,CAAC,CAAC,oDAAoD;gBACtD,CAAC,CAAC,6EAA6E,IAAI,mCAAmC;SACzH,CAAC,CAAA;IACJ,CAAC,CACF;CACF,CAAA"}
@@ -0,0 +1,34 @@
1
+ export interface TransactionRequest {
2
+ id: string;
3
+ type: 'send_transaction' | 'sign_message' | 'sign_typed_data';
4
+ chain: string;
5
+ data: unknown;
6
+ }
7
+ export interface TransactionResponse {
8
+ id: string;
9
+ success: boolean;
10
+ result?: unknown;
11
+ error?: string;
12
+ }
13
+ declare class WalletServer {
14
+ private app;
15
+ private httpServer;
16
+ private wss;
17
+ private clients;
18
+ private pendingRequests;
19
+ private port;
20
+ private isStarted;
21
+ constructor(port?: number);
22
+ private setupExpress;
23
+ private setupWebSocket;
24
+ start(): Promise<void>;
25
+ stop(): Promise<void>;
26
+ openBrowser(): void;
27
+ sendTransaction(request: TransactionRequest): Promise<unknown>;
28
+ isConnected(): boolean;
29
+ getPort(): number;
30
+ }
31
+ export declare function getWalletServer(): WalletServer;
32
+ export declare function startWalletServer(): Promise<WalletServer>;
33
+ export {};
34
+ //# sourceMappingURL=wallet-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet-server.d.ts","sourceRoot":"","sources":["../src/wallet-server.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,kBAAkB,GAAG,cAAc,GAAG,iBAAiB,CAAA;IAC7D,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,OAAO,CAAA;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,cAAM,YAAY;IAChB,OAAO,CAAC,GAAG,CAAqB;IAChC,OAAO,CAAC,UAAU,CAAiC;IACnD,OAAO,CAAC,GAAG,CAAiB;IAC5B,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,eAAe,CAGT;IACd,OAAO,CAAC,IAAI,CAAQ;IACpB,OAAO,CAAC,SAAS,CAAQ;gBAEb,IAAI,SAAO;IAUvB,OAAO,CAAC,YAAY;IAkBpB,OAAO,CAAC,cAAc;IAqChB,KAAK;IAsBL,IAAI;IAaV,WAAW;IAuBL,eAAe,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAoDpE,WAAW,IAAI,OAAO;IAItB,OAAO,IAAI,MAAM;CAGlB;AAKD,wBAAgB,eAAe,IAAI,YAAY,CAK9C;AAED,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,YAAY,CAAC,CAI/D"}
@@ -0,0 +1,195 @@
1
+ import express from 'express';
2
+ import cors from 'cors';
3
+ import { WebSocketServer, WebSocket } from 'ws';
4
+ import { createServer } from 'http';
5
+ import { fileURLToPath } from 'url';
6
+ import { dirname, join } from 'path';
7
+ import { exec } from 'child_process';
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
10
+ class WalletServer {
11
+ app;
12
+ httpServer;
13
+ wss;
14
+ clients = new Set();
15
+ pendingRequests = new Map();
16
+ port;
17
+ isStarted = false;
18
+ constructor(port = 3456) {
19
+ this.port = port;
20
+ this.app = express();
21
+ this.httpServer = createServer(this.app);
22
+ this.wss = new WebSocketServer({ server: this.httpServer });
23
+ this.setupExpress();
24
+ this.setupWebSocket();
25
+ }
26
+ setupExpress() {
27
+ this.app.use(cors());
28
+ this.app.use(express.json());
29
+ this.app.use(express.static(join(__dirname, '..', 'public')));
30
+ this.app.get('/', (_req, res) => {
31
+ res.sendFile(join(__dirname, '..', 'public', 'wallet.html'));
32
+ });
33
+ this.app.get('/health', (_req, res) => {
34
+ res.json({
35
+ status: 'ok',
36
+ clients: this.clients.size,
37
+ pendingRequests: this.pendingRequests.size
38
+ });
39
+ });
40
+ }
41
+ setupWebSocket() {
42
+ this.wss.on('connection', (ws) => {
43
+ console.error('[Wallet Server] Client connected');
44
+ this.clients.add(ws);
45
+ ws.on('message', (data) => {
46
+ try {
47
+ const response = JSON.parse(data.toString());
48
+ console.error('[Wallet Server] Received response:', response.id);
49
+ console.error('[Wallet Server] Response data:', JSON.stringify(response));
50
+ const pending = this.pendingRequests.get(response.id);
51
+ if (pending) {
52
+ if (response.success) {
53
+ pending.resolve(response.result);
54
+ }
55
+ else {
56
+ pending.reject(new Error(response.error || 'Transaction failed'));
57
+ }
58
+ this.pendingRequests.delete(response.id);
59
+ }
60
+ }
61
+ catch (error) {
62
+ console.error('[Wallet Server] Error parsing message:', error);
63
+ }
64
+ });
65
+ ws.on('close', () => {
66
+ console.error('[Wallet Server] Client disconnected');
67
+ this.clients.delete(ws);
68
+ });
69
+ ws.on('error', (error) => {
70
+ console.error('[Wallet Server] WebSocket error:', error);
71
+ this.clients.delete(ws);
72
+ });
73
+ });
74
+ }
75
+ async start() {
76
+ if (this.isStarted) {
77
+ return;
78
+ }
79
+ return new Promise((resolve, reject) => {
80
+ this.httpServer.listen(this.port, () => {
81
+ this.isStarted = true;
82
+ console.error(`[Wallet Server] Running on http://localhost:${this.port}`);
83
+ resolve();
84
+ }).on('error', (error) => {
85
+ if (error.code === 'EADDRINUSE') {
86
+ console.error(`[Wallet Server] Port ${this.port} already in use, assuming server is already running`);
87
+ this.isStarted = true;
88
+ resolve();
89
+ }
90
+ else {
91
+ reject(error);
92
+ }
93
+ });
94
+ });
95
+ }
96
+ async stop() {
97
+ return new Promise((resolve) => {
98
+ this.clients.forEach(client => client.close());
99
+ this.wss.close(() => {
100
+ this.httpServer.close(() => {
101
+ this.isStarted = false;
102
+ console.error('[Wallet Server] Stopped');
103
+ resolve();
104
+ });
105
+ });
106
+ });
107
+ }
108
+ openBrowser() {
109
+ const url = `http://localhost:${this.port}`;
110
+ const platform = process.platform;
111
+ let command;
112
+ if (platform === 'darwin') {
113
+ command = `open "${url}"`;
114
+ }
115
+ else if (platform === 'win32') {
116
+ command = `start "${url}"`;
117
+ }
118
+ else {
119
+ command = `xdg-open "${url}"`;
120
+ }
121
+ exec(command, (error) => {
122
+ if (error) {
123
+ console.error('[Wallet Server] Failed to open browser:', error);
124
+ console.error(`[Wallet Server] Please open manually: ${url}`);
125
+ }
126
+ else {
127
+ console.error(`[Wallet Server] Opened browser at ${url}`);
128
+ }
129
+ });
130
+ }
131
+ async sendTransaction(request) {
132
+ if (!this.isStarted) {
133
+ await this.start();
134
+ }
135
+ // Always open/focus browser for transaction requests
136
+ this.openBrowser();
137
+ // Open browser if no clients connected
138
+ if (this.clients.size === 0) {
139
+ // Wait for client to connect (max 30 seconds)
140
+ const timeout = 30000;
141
+ const startTime = Date.now();
142
+ while (this.clients.size === 0 && Date.now() - startTime < timeout) {
143
+ await new Promise(resolve => setTimeout(resolve, 500));
144
+ }
145
+ if (this.clients.size === 0) {
146
+ throw new Error('No wallet connected. Please open the browser and connect your wallet.');
147
+ }
148
+ }
149
+ return new Promise((resolve, reject) => {
150
+ this.pendingRequests.set(request.id, { resolve, reject });
151
+ // Send to first available connected client only
152
+ const message = JSON.stringify(request);
153
+ let sent = false;
154
+ for (const client of this.clients) {
155
+ if (client.readyState === WebSocket.OPEN) {
156
+ client.send(message);
157
+ sent = true;
158
+ break;
159
+ }
160
+ }
161
+ if (!sent) {
162
+ this.pendingRequests.delete(request.id);
163
+ reject(new Error('No active wallet connection'));
164
+ return;
165
+ }
166
+ // Timeout after 5 minutes
167
+ setTimeout(() => {
168
+ if (this.pendingRequests.has(request.id)) {
169
+ this.pendingRequests.delete(request.id);
170
+ reject(new Error('Transaction request timed out'));
171
+ }
172
+ }, 300000);
173
+ });
174
+ }
175
+ isConnected() {
176
+ return this.clients.size > 0;
177
+ }
178
+ getPort() {
179
+ return this.port;
180
+ }
181
+ }
182
+ // Singleton instance
183
+ let walletServer = null;
184
+ export function getWalletServer() {
185
+ if (!walletServer) {
186
+ walletServer = new WalletServer();
187
+ }
188
+ return walletServer;
189
+ }
190
+ export async function startWalletServer() {
191
+ const server = getWalletServer();
192
+ await server.start();
193
+ return server;
194
+ }
195
+ //# sourceMappingURL=wallet-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet-server.js","sourceRoot":"","sources":["../src/wallet-server.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,IAAI,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAEpC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACjD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAgBrC,MAAM,YAAY;IACR,GAAG,CAAqB;IACxB,UAAU,CAAiC;IAC3C,GAAG,CAAiB;IACpB,OAAO,GAAmB,IAAI,GAAG,EAAE,CAAA;IACnC,eAAe,GAGlB,IAAI,GAAG,EAAE,CAAA;IACN,IAAI,CAAQ;IACZ,SAAS,GAAG,KAAK,CAAA;IAEzB,YAAY,IAAI,GAAG,I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,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;gBACvC,MAAM,CAAC,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC,CAAA;gBAChD,OAAM;YACR,CAAC;YAED,0BAA0B;YAC1B,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;oBACzC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;oBACvC,MAAM,CAAC,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC,CAAA;gBACpD,CAAC;YACH,CAAC,EAAE,MAAM,CAAC,CAAA;QACZ,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAA;IAC9B,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;CACF;AAED,qBAAqB;AACrB,IAAI,YAAY,GAAwB,IAAI,CAAA;AAE5C,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,YAAY,GAAG,IAAI,YAAY,EAAE,CAAA;IACnC,CAAC;IACD,OAAO,YAAY,CAAA;AACrB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,MAAM,MAAM,GAAG,eAAe,EAAE,CAAA;IAChC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;IACpB,OAAO,MAAM,CAAA;AACf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web3-tools-mcp",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Model Context Protocol server for blockchain interactions using viem, Etherscan, and Hypersync",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -10,6 +10,7 @@
10
10
  },
11
11
  "files": [
12
12
  "dist",
13
+ "public",
13
14
  "README.md",
14
15
  "LICENSE",
15
16
  "src"
@@ -50,11 +51,17 @@
50
51
  "dependencies": {
51
52
  "@envio-dev/hypersync-client": "^0.6.5",
52
53
  "@modelcontextprotocol/sdk": "^1.20.1",
54
+ "cors": "^2.8.5",
55
+ "express": "^4.21.2",
53
56
  "viem": "^2.31.4",
57
+ "ws": "^8.18.0",
54
58
  "zod": "^3.25.76"
55
59
  },
56
60
  "devDependencies": {
61
+ "@types/cors": "^2.8.17",
62
+ "@types/express": "^5.0.0",
57
63
  "@types/node": "^20.19.23",
64
+ "@types/ws": "^8.5.13",
58
65
  "@vitest/ui": "^3.2.4",
59
66
  "dotenv": "^17.2.3",
60
67
  "typescript": "^5.0.0",