web3-tools-mcp 1.0.1 → 1.1.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.
Files changed (135) hide show
  1. package/README.md +25 -233
  2. package/dist/client.d.ts +1653 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +142 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +78 -28272
  9. package/dist/index.js.map +1 -0
  10. package/dist/package.json +60 -0
  11. package/dist/src/client.d.ts +1653 -0
  12. package/dist/src/client.d.ts.map +1 -0
  13. package/dist/src/client.js +142 -0
  14. package/dist/src/client.js.map +1 -0
  15. package/dist/src/index.d.ts +3 -0
  16. package/dist/src/index.d.ts.map +1 -0
  17. package/dist/src/index.js +88 -0
  18. package/dist/src/index.js.map +1 -0
  19. package/dist/src/tools/advanced.d.ts +75 -0
  20. package/dist/src/tools/advanced.d.ts.map +1 -0
  21. package/dist/src/tools/advanced.js +234 -0
  22. package/dist/src/tools/advanced.js.map +1 -0
  23. package/dist/src/tools/balance.d.ts +55 -0
  24. package/dist/src/tools/balance.d.ts.map +1 -0
  25. package/dist/src/tools/balance.js +146 -0
  26. package/dist/src/tools/balance.js.map +1 -0
  27. package/dist/src/tools/contract-info.d.ts +79 -0
  28. package/dist/src/tools/contract-info.d.ts.map +1 -0
  29. package/dist/src/tools/contract-info.js +450 -0
  30. package/dist/src/tools/contract-info.js.map +1 -0
  31. package/dist/src/tools/contract.d.ts +79 -0
  32. package/dist/src/tools/contract.d.ts.map +1 -0
  33. package/dist/src/tools/contract.js +140 -0
  34. package/dist/src/tools/contract.js.map +1 -0
  35. package/dist/src/tools/index.d.ts +3 -0
  36. package/dist/src/tools/index.d.ts.map +1 -0
  37. package/dist/src/tools/index.js +27 -0
  38. package/dist/src/tools/index.js.map +1 -0
  39. package/dist/src/tools/logs.d.ts +39 -0
  40. package/dist/src/tools/logs.d.ts.map +1 -0
  41. package/dist/src/tools/logs.js +231 -0
  42. package/dist/src/tools/logs.js.map +1 -0
  43. package/dist/src/tools/signatures.d.ts +83 -0
  44. package/dist/src/tools/signatures.d.ts.map +1 -0
  45. package/dist/src/tools/signatures.js +93 -0
  46. package/dist/src/tools/signatures.js.map +1 -0
  47. package/dist/src/types.d.ts +22 -0
  48. package/dist/src/types.d.ts.map +1 -0
  49. package/dist/src/types.js +2 -0
  50. package/dist/src/types.js.map +1 -0
  51. package/dist/src/utils.d.ts +22 -0
  52. package/dist/src/utils.d.ts.map +1 -0
  53. package/dist/src/utils.js +183 -0
  54. package/dist/src/utils.js.map +1 -0
  55. package/dist/test/mcp-client.test.d.ts +2 -0
  56. package/dist/test/mcp-client.test.d.ts.map +1 -0
  57. package/dist/test/mcp-client.test.js +376 -0
  58. package/dist/test/mcp-client.test.js.map +1 -0
  59. package/dist/test/tools/advanced.test.d.ts +2 -0
  60. package/dist/test/tools/advanced.test.d.ts.map +1 -0
  61. package/dist/test/tools/advanced.test.js +235 -0
  62. package/dist/test/tools/advanced.test.js.map +1 -0
  63. package/dist/test/tools/balance.test.d.ts +2 -0
  64. package/dist/test/tools/balance.test.d.ts.map +1 -0
  65. package/dist/test/tools/balance.test.js +167 -0
  66. package/dist/test/tools/balance.test.js.map +1 -0
  67. package/dist/test/tools/contract-info.test.d.ts +2 -0
  68. package/dist/test/tools/contract-info.test.d.ts.map +1 -0
  69. package/dist/test/tools/contract-info.test.js +286 -0
  70. package/dist/test/tools/contract-info.test.js.map +1 -0
  71. package/dist/test/tools/contract.test.d.ts +2 -0
  72. package/dist/test/tools/contract.test.d.ts.map +1 -0
  73. package/dist/test/tools/contract.test.js +234 -0
  74. package/dist/test/tools/contract.test.js.map +1 -0
  75. package/dist/test/tools/logs.test.d.ts +2 -0
  76. package/dist/test/tools/logs.test.d.ts.map +1 -0
  77. package/dist/test/tools/logs.test.js +196 -0
  78. package/dist/test/tools/logs.test.js.map +1 -0
  79. package/dist/test/tools/signatures.test.d.ts +2 -0
  80. package/dist/test/tools/signatures.test.d.ts.map +1 -0
  81. package/dist/test/tools/signatures.test.js +112 -0
  82. package/dist/test/tools/signatures.test.js.map +1 -0
  83. package/dist/tools/advanced.d.ts +75 -0
  84. package/dist/tools/advanced.d.ts.map +1 -0
  85. package/dist/tools/advanced.js +234 -0
  86. package/dist/tools/advanced.js.map +1 -0
  87. package/dist/tools/balance.d.ts +55 -0
  88. package/dist/tools/balance.d.ts.map +1 -0
  89. package/dist/tools/balance.js +146 -0
  90. package/dist/tools/balance.js.map +1 -0
  91. package/dist/tools/batch.d.ts +122 -0
  92. package/dist/tools/batch.d.ts.map +1 -0
  93. package/dist/tools/batch.js +243 -0
  94. package/dist/tools/batch.js.map +1 -0
  95. package/dist/tools/contract-info.d.ts +79 -0
  96. package/dist/tools/contract-info.d.ts.map +1 -0
  97. package/dist/tools/contract-info.js +450 -0
  98. package/dist/tools/contract-info.js.map +1 -0
  99. package/dist/tools/contract.d.ts +79 -0
  100. package/dist/tools/contract.d.ts.map +1 -0
  101. package/dist/tools/contract.js +140 -0
  102. package/dist/tools/contract.js.map +1 -0
  103. package/dist/tools/index.d.ts +3 -0
  104. package/dist/tools/index.d.ts.map +1 -0
  105. package/dist/tools/index.js +27 -0
  106. package/dist/tools/index.js.map +1 -0
  107. package/dist/tools/logs.d.ts +39 -0
  108. package/dist/tools/logs.d.ts.map +1 -0
  109. package/dist/tools/logs.js +231 -0
  110. package/dist/tools/logs.js.map +1 -0
  111. package/dist/tools/signatures.d.ts +83 -0
  112. package/dist/tools/signatures.d.ts.map +1 -0
  113. package/dist/tools/signatures.js +93 -0
  114. package/dist/tools/signatures.js.map +1 -0
  115. package/dist/types.d.ts +22 -0
  116. package/dist/types.d.ts.map +1 -0
  117. package/dist/types.js +2 -0
  118. package/dist/types.js.map +1 -0
  119. package/dist/utils.d.ts +22 -0
  120. package/dist/utils.d.ts.map +1 -0
  121. package/dist/utils.js +183 -0
  122. package/dist/utils.js.map +1 -0
  123. package/package.json +35 -23
  124. package/src/client.ts +160 -0
  125. package/src/index.ts +96 -0
  126. package/src/tools/advanced.ts +262 -0
  127. package/src/tools/balance.ts +176 -0
  128. package/src/tools/contract-info.ts +582 -0
  129. package/src/tools/contract.ts +180 -0
  130. package/src/tools/index.ts +35 -0
  131. package/src/tools/logs.ts +291 -0
  132. package/src/tools/signatures.ts +126 -0
  133. package/src/types.ts +29 -0
  134. package/src/utils.ts +222 -0
  135. package/dist/hypersync-client.darwin-arm64-7fegfwn5.node +0 -0
package/README.md CHANGED
@@ -118,173 +118,51 @@ npx web3-tools-mcp
118
118
  ### 1. ABI Signature Tools
119
119
 
120
120
  #### `get_function_signature`
121
- Generate 4-byte function selectors from ABI definitions.
122
-
123
- **Parameters:**
124
- - `functionAbi` (string): Function ABI (e.g., `"function transfer(address to, uint256 amount)"`)
125
-
126
- **Example:**
127
- ```json
128
- {
129
- "name": "get_function_signature",
130
- "arguments": {
131
- "functionAbi": "function balanceOf(address owner) view returns (uint256)"
132
- }
133
- }
134
- ```
121
+ Generate 4-byte function selectors from ABI definitions. Supports batch operations for multiple functions at once.
135
122
 
136
123
  #### `get_event_signature`
137
- Generate 32-byte event signatures (topic0) from ABI definitions.
138
-
139
- **Parameters:**
140
- - `eventAbi` (string): Event ABI (e.g., `"event Transfer(address indexed from, address indexed to, uint256 value)"`)
124
+ Generate 32-byte event signatures (topic0) from ABI definitions. Supports batch operations for multiple events at once.
141
125
 
142
126
  #### `get_error_signature`
143
- Generate 4-byte error selectors from ABI definitions.
144
-
145
- **Parameters:**
146
- - `errorAbi` (string): Error ABI (e.g., `"error InsufficientBalance(uint256 available, uint256 required)"`)
127
+ Generate 4-byte error selectors from ABI definitions. Supports batch operations for multiple errors at once.
147
128
 
148
129
  ### 2. Contract Interaction Tools
149
130
 
150
131
  #### `call_contract_function`
151
- Call view/pure functions on smart contracts.
152
-
153
- **Parameters:**
154
- - `chain` (enum): Blockchain network (`mainnet`, `base`, `arbitrum`, `polygon`, `optimism`, `celo`, `localhost`)
155
- - `contractAddress` (string): Contract address to call
156
- - `functionAbi` (string): Function ABI definition
157
- - `args` (array, optional): Function arguments
158
- - `blockNumber` (string, optional): Specific block number to query
159
-
160
- **Example:**
161
- ```json
162
- {
163
- "name": "call_contract_function",
164
- "arguments": {
165
- "chain": "mainnet",
166
- "contractAddress": "0xA0b86a33E6441c1e4e9c08975a0c8246e8dB8C4F",
167
- "functionAbi": "function balanceOf(address owner) view returns (uint256)",
168
- "args": ["0x742d35Cc6cF36C3e0C37d3f6D1D5e4f2C8F3E8A9"]
169
- }
170
- }
171
- ```
132
+ Call view/pure functions on smart contracts. Supports batch operations for executing multiple calls efficiently across different contracts and chains.
172
133
 
173
134
  #### `get_contract_abi`
174
- Get comprehensive contract information including ABI, proxy detection, and verification status from Etherscan.
135
+ Get comprehensive contract information including ABI, proxy detection, compilation info, creation info, and verification status from Etherscan. Includes smart caching for performance.
175
136
 
176
- **Parameters:**
177
- - `chain` (enum): Blockchain network
178
- - `address` (string): Contract address
137
+ #### `get_contract_source_code`
138
+ Retrieve verified contract source code from Etherscan with proxy support and flexible output options (full source, summary, or metadata only). Features smart caching.
179
139
 
180
- #### `is_contract`
181
- Check if an address is a smart contract or EOA (Externally Owned Account).
140
+ #### `get_contract_source_file`
141
+ Retrieve specific source file from cached contract data. Use after calling `get_contract_source_code` with full source option.
182
142
 
183
- **Parameters:**
184
- - `chain` (enum): Blockchain network
185
- - `address` (string): Address to check
143
+ #### `is_contract`
144
+ Check if an address is a smart contract or EOA (Externally Owned Account). Returns contract status and bytecode length.
186
145
 
187
146
  ### 3. Balance Query Tools
188
147
 
189
148
  #### `get_balance`
190
- Get native token balance for an address.
191
-
192
- **Parameters:**
193
- - `chain` (enum): Blockchain network
194
- - `address` (string): Address to check
195
- - `blockNumber` (string, optional): Specific block number
196
-
197
- #### `get_token_balance`
198
- Get ERC20/ERC777 token balance for an address.
199
-
200
- **Parameters:**
201
- - `chain` (enum): Blockchain network
202
- - `tokenAddress` (string): Token contract address
203
- - `holderAddress` (string): Address to check balance for
204
- - `blockNumber` (string, optional): Specific block number
205
-
206
- #### `batch_native_balances`
207
- Get native token balances for multiple addresses in a single call.
208
-
209
- **Parameters:**
210
- - `chain` (enum): Blockchain network
211
- - `addresses` (array): Array of addresses to check
212
- - `blockNumber` (string, optional): Specific block number
213
-
214
- #### `batch_token_balances`
215
- Get multiple token balances for multiple addresses efficiently.
216
-
217
- **Parameters:**
218
- - `chain` (enum): Blockchain network
219
- - `queries` (array): Array of balance queries with `tokenAddress`, `holderAddress`, and optional `label`
220
- - `blockNumber` (string, optional): Specific block number
149
+ Get native or ERC20 token balances for single or multiple addresses efficiently. Supports batch operations for optimal performance. Omit `tokenAddress` for native balance, include it for ERC20 tokens.
221
150
 
222
151
  ### 4. Event Log Tools
223
152
 
224
153
  #### `get_logs`
225
- Query contract events with decoded output and parameter filtering. Automatically falls back to Hypersync for supported chains when needed.
226
-
227
- **Parameters:**
228
- - `chain` (enum): Blockchain network
229
- - `eventAbi` (string): Event ABI definition for decoding
230
- - `address` (string, optional): Contract address to filter logs
231
- - `fromBlock` (string, optional): Start block number
232
- - `toBlock` (string, optional): End block number
233
- - `eventArgs` (object, optional): Filter by indexed event parameters
234
-
235
- **Example:**
236
- ```json
237
- {
238
- "name": "get_logs",
239
- "arguments": {
240
- "chain": "mainnet",
241
- "eventAbi": "event Transfer(address indexed from, address indexed to, uint256 value)",
242
- "address": "0xA0b86a33E6441c1e4e9c08975a0c8246e8dB8C4F",
243
- "fromBlock": "18000000",
244
- "toBlock": "18001000",
245
- "eventArgs": {
246
- "from": "0x742d35Cc6cF36C3e0C37d3f6D1D5e4f2C8F3E8A9"
247
- }
248
- }
249
- }
250
- ```
251
-
252
- ### 5. Batch Operations
253
-
254
- #### `batch_contract_calls`
255
- Execute multiple contract calls in a single batch operation.
154
+ Query contract events with decoded output and parameter filtering. Automatically falls back to Hypersync for supported chains when needed. Supports filtering by contract address, block range, and indexed event parameters.
256
155
 
257
- **Parameters:**
258
- - `chain` (enum): Blockchain network
259
- - `calls` (array): Array of contract calls with `contractAddress`, `functionAbi`, `args`, and optional `label`
260
- - `blockNumber` (string, optional): Specific block number
261
-
262
- ### 6. Advanced Tools
156
+ ### 5. Advanced Tools
263
157
 
264
158
  #### `get_storage_at`
265
- Read raw storage data from a contract with ABI-based decoding.
266
-
267
- **Parameters:**
268
- - `chain` (enum): Blockchain network
269
- - `address` (string): Contract address
270
- - `slot` (string): Storage slot to read (hex string)
271
- - `abiType` (string): ABI type for decoding (`uint256`, `address`, `bool`, `bytes32`, etc.)
272
- - `blockNumber` (string, optional): Specific block number
159
+ Read raw storage data from a contract with ABI-based decoding. Supports various types like uint256, address, bool, bytes32, etc.
273
160
 
274
161
  #### `get_block_info`
275
- Get comprehensive block information including timestamp, hash, and formatted dates.
276
-
277
- **Parameters:**
278
- - `chain` (enum): Blockchain network
279
- - `blockNumber` (string, optional): Block number to query (defaults to latest)
162
+ Get comprehensive block information including timestamp, hash, parent hash, and formatted dates. Defaults to latest block if not specified.
280
163
 
281
164
  #### `trace_transaction`
282
- Trace a transaction to see detailed execution information including internal calls, state changes, and gas usage.
283
-
284
- **Parameters:**
285
- - `chain` (enum): Blockchain network
286
- - `transactionHash` (string): Transaction hash to trace
287
- - `traceType` (enum, optional): Type of trace (`trace`, `vmTrace`, `stateDiff`)
165
+ Trace a transaction to see detailed execution information including internal calls, state changes, and gas usage. Supports multiple trace types: `trace` (call tree), `vmTrace` (VM execution), `stateDiff` (state changes).
288
166
 
289
167
  ## ⚙️ Configuration
290
168
 
@@ -301,7 +179,7 @@ The server supports multiple configuration options through environment variables
301
179
 
302
180
  **Example:**
303
181
  ```bash
304
- bun index.ts --custom-rpc '{"mainnet": "https://my-custom-rpc.com", "base": "https://base-rpc.com"}'
182
+ npx web3-tools-mcp --custom-rpc '{"mainnet": "https://my-custom-rpc.com", "base": "https://base-rpc.com"}'
305
183
  ```
306
184
 
307
185
  ## 🔧 Technical Features
@@ -326,114 +204,28 @@ bun index.ts --custom-rpc '{"mainnet": "https://my-custom-rpc.com", "base": "htt
326
204
  - **Balance Batching**: Query multiple balances in parallel
327
205
  - **Result Aggregation**: Organized results with success/failure tracking
328
206
 
329
- ## 🚀 Usage Examples
330
-
331
- ### Basic Contract Call
332
- ```json
333
- {
334
- "name": "call_contract_function",
335
- "arguments": {
336
- "chain": "mainnet",
337
- "contractAddress": "0xA0b86a33E6441c1e4e9c08975a0c8246e8dB8C4F",
338
- "functionAbi": "function name() view returns (string)",
339
- "args": []
340
- }
341
- }
342
- ```
343
-
344
- ### Event Log Analysis
345
- ```json
346
- {
347
- "name": "get_logs",
348
- "arguments": {
349
- "chain": "base",
350
- "eventAbi": "event Swap(address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to)",
351
- "fromBlock": "10000000",
352
- "toBlock": "latest"
353
- }
354
- }
355
- ```
356
-
357
- ### Batch Balance Queries
358
- ```json
359
- {
360
- "name": "batch_token_balances",
361
- "arguments": {
362
- "chain": "mainnet",
363
- "queries": [
364
- {
365
- "tokenAddress": "0xA0b86a33E6441c1e4e9c08975a0c8246e8dB8C4F",
366
- "holderAddress": "0x742d35Cc6cF36C3e0C37d3f6D1D5e4f2C8F3E8A9",
367
- "label": "USDC Balance"
368
- },
369
- {
370
- "tokenAddress": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
371
- "holderAddress": "0x742d35Cc6cF36C3e0C37d3f6D1D5e4f2C8F3E8A9",
372
- "label": "WETH Balance"
373
- }
374
- ]
375
- }
376
- }
377
- ```
378
-
379
207
  ## 📋 Requirements
380
208
 
381
- - **Runtime**: Bun (recommended) or Node.js
209
+ - **Runtime**: Node.js v20.0.0 or higher
210
+ - **Package Manager**: npm (recommended) or yarn/pnpm
382
211
  - **Dependencies**: viem, @envio-dev/hypersync-client, @modelcontextprotocol/sdk
383
212
  - **Network Access**: Internet connection for blockchain RPC calls
384
213
 
385
214
  ## 🧪 Testing
386
215
 
387
- The server includes a comprehensive test suite that validates all functionality:
216
+ The server includes a comprehensive test suite with 70 tests covering all functionality:
388
217
 
389
218
  ### Running Tests
390
219
 
391
220
  ```bash
392
221
  # Run all tests
393
- bun test
222
+ npm test
394
223
 
395
224
  # Run tests in watch mode
396
- bun run test:watch
397
-
398
- # Run tests with coverage
399
- bun run test:coverage
400
-
401
- # Run type checking
402
- bun run lint
403
- ```
404
-
405
- ### Test Coverage
225
+ npm run test:watch
406
226
 
407
- The test suite covers:
408
-
409
- - **ABI Signature Generation**: Function, event, and error signatures
410
- - **Contract Interactions**: Detecting contracts vs EOAs, calling view functions
411
- - **Balance Queries**: Native and token balances, batch operations
412
- - **Block Information**: Latest and historical block data
413
- - **Multi-chain Support**: Testing across different networks
414
- - **Error Handling**: Invalid inputs, network failures, malformed requests
415
- - **Data Type Handling**: BigInt serialization, address normalization
416
- - **Performance**: Batch vs individual operation timing
417
-
418
- ### Example Usage
419
-
420
- ```bash
421
- # Run example demonstrations
422
- bun run examples
423
- ```
424
-
425
- The examples file demonstrates:
426
- - Function signature generation
427
- - Contract vs EOA detection
428
- - Smart contract function calls
429
- - Balance queries
430
- - Block information retrieval
431
-
432
- ### Test Structure
433
-
434
- ```
435
- test.ts # Main test suite
436
- examples.ts # Usage examples and demonstrations
227
+ # Run tests with UI
228
+ npm run test:ui
437
229
  ```
438
230
 
439
231
  ## 🔗 Related Tools