web3-tools-mcp 1.0.1 โ†’ 1.2.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 (93) hide show
  1. package/README.md +46 -230
  2. package/dist/package.json +63 -0
  3. package/dist/src/client.d.ts +1653 -0
  4. package/dist/src/client.d.ts.map +1 -0
  5. package/dist/src/client.js +142 -0
  6. package/dist/src/client.js.map +1 -0
  7. package/dist/src/index.d.ts +3 -0
  8. package/dist/src/index.d.ts.map +1 -0
  9. package/dist/src/index.js +88 -0
  10. package/dist/src/index.js.map +1 -0
  11. package/dist/src/tools/advanced.d.ts +75 -0
  12. package/dist/src/tools/advanced.d.ts.map +1 -0
  13. package/dist/src/tools/advanced.js +234 -0
  14. package/dist/src/tools/advanced.js.map +1 -0
  15. package/dist/src/tools/balance.d.ts +55 -0
  16. package/dist/src/tools/balance.d.ts.map +1 -0
  17. package/dist/src/tools/balance.js +146 -0
  18. package/dist/src/tools/balance.js.map +1 -0
  19. package/dist/src/tools/contract-info.d.ts +79 -0
  20. package/dist/src/tools/contract-info.d.ts.map +1 -0
  21. package/dist/src/tools/contract-info.js +450 -0
  22. package/dist/src/tools/contract-info.js.map +1 -0
  23. package/dist/src/tools/contract.d.ts +79 -0
  24. package/dist/src/tools/contract.d.ts.map +1 -0
  25. package/dist/src/tools/contract.js +140 -0
  26. package/dist/src/tools/contract.js.map +1 -0
  27. package/dist/src/tools/ens.d.ts +119 -0
  28. package/dist/src/tools/ens.d.ts.map +1 -0
  29. package/dist/src/tools/ens.js +425 -0
  30. package/dist/src/tools/ens.js.map +1 -0
  31. package/dist/src/tools/index.d.ts +3 -0
  32. package/dist/src/tools/index.d.ts.map +1 -0
  33. package/dist/src/tools/index.js +29 -0
  34. package/dist/src/tools/index.js.map +1 -0
  35. package/dist/src/tools/logs.d.ts +39 -0
  36. package/dist/src/tools/logs.d.ts.map +1 -0
  37. package/dist/src/tools/logs.js +231 -0
  38. package/dist/src/tools/logs.js.map +1 -0
  39. package/dist/src/tools/signatures.d.ts +83 -0
  40. package/dist/src/tools/signatures.d.ts.map +1 -0
  41. package/dist/src/tools/signatures.js +93 -0
  42. package/dist/src/tools/signatures.js.map +1 -0
  43. package/dist/src/types.d.ts +22 -0
  44. package/dist/src/types.d.ts.map +1 -0
  45. package/dist/src/types.js +2 -0
  46. package/dist/src/types.js.map +1 -0
  47. package/dist/src/utils.d.ts +22 -0
  48. package/dist/src/utils.d.ts.map +1 -0
  49. package/dist/src/utils.js +183 -0
  50. package/dist/src/utils.js.map +1 -0
  51. package/dist/test/tools/advanced.test.d.ts +2 -0
  52. package/dist/test/tools/advanced.test.d.ts.map +1 -0
  53. package/dist/test/tools/advanced.test.js +235 -0
  54. package/dist/test/tools/advanced.test.js.map +1 -0
  55. package/dist/test/tools/balance.test.d.ts +2 -0
  56. package/dist/test/tools/balance.test.d.ts.map +1 -0
  57. package/dist/test/tools/balance.test.js +167 -0
  58. package/dist/test/tools/balance.test.js.map +1 -0
  59. package/dist/test/tools/contract-info.test.d.ts +2 -0
  60. package/dist/test/tools/contract-info.test.d.ts.map +1 -0
  61. package/dist/test/tools/contract-info.test.js +286 -0
  62. package/dist/test/tools/contract-info.test.js.map +1 -0
  63. package/dist/test/tools/contract.test.d.ts +2 -0
  64. package/dist/test/tools/contract.test.d.ts.map +1 -0
  65. package/dist/test/tools/contract.test.js +234 -0
  66. package/dist/test/tools/contract.test.js.map +1 -0
  67. package/dist/test/tools/ens.test.d.ts +2 -0
  68. package/dist/test/tools/ens.test.d.ts.map +1 -0
  69. package/dist/test/tools/ens.test.js +236 -0
  70. package/dist/test/tools/ens.test.js.map +1 -0
  71. package/dist/test/tools/logs.test.d.ts +2 -0
  72. package/dist/test/tools/logs.test.d.ts.map +1 -0
  73. package/dist/test/tools/logs.test.js +196 -0
  74. package/dist/test/tools/logs.test.js.map +1 -0
  75. package/dist/test/tools/signatures.test.d.ts +2 -0
  76. package/dist/test/tools/signatures.test.d.ts.map +1 -0
  77. package/dist/test/tools/signatures.test.js +112 -0
  78. package/dist/test/tools/signatures.test.js.map +1 -0
  79. package/package.json +37 -22
  80. package/src/client.ts +160 -0
  81. package/src/index.ts +96 -0
  82. package/src/tools/advanced.ts +262 -0
  83. package/src/tools/balance.ts +176 -0
  84. package/src/tools/contract-info.ts +582 -0
  85. package/src/tools/contract.ts +180 -0
  86. package/src/tools/ens.ts +493 -0
  87. package/src/tools/index.ts +37 -0
  88. package/src/tools/logs.ts +291 -0
  89. package/src/tools/signatures.ts +126 -0
  90. package/src/types.ts +29 -0
  91. package/src/utils.ts +222 -0
  92. package/dist/hypersync-client.darwin-arm64-7fegfwn5.node +0 -0
  93. package/dist/index.js +0 -28282
package/README.md CHANGED
@@ -92,11 +92,12 @@ npx web3-tools-mcp
92
92
  ## ๐ŸŒŸ Key Features
93
93
 
94
94
  - **Multi-chain Support**: Works with Ethereum mainnet, Base, Arbitrum, Polygon, Optimism, Celo, and localhost
95
+ - **ENS Name Resolution**: Resolve ENS names to addresses, reverse lookup addresses to names, and query ENS records
95
96
  - **Smart Contract Interactions**: Call view/pure functions, get contract ABIs, and analyze contract bytecode
96
97
  - **Event Log Analysis**: Query and decode blockchain events with flexible filtering
97
98
  - **Token Operations**: Get native and ERC20 token balances for single or multiple addresses
98
99
  - **ABI Utilities**: Generate function, event, and error signatures from ABI definitions
99
- - **Batch Operations**: Execute multiple contract calls or balance queries efficiently
100
+ - **Batch Operations**: Execute multiple contract calls, balance queries, or ENS resolutions efficiently
100
101
  - **Transaction Analysis**: Trace transactions for detailed execution information
101
102
  - **Enhanced RPC Support**: Automatic failover between providers (Alchemy, Infura, public RPCs)
102
103
  - **Hypersync Integration**: Fast event log querying with fallback support
@@ -118,173 +119,74 @@ npx web3-tools-mcp
118
119
  ### 1. ABI Signature Tools
119
120
 
120
121
  #### `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
- ```
122
+ Generate 4-byte function selectors from ABI definitions. Supports batch operations for multiple functions at once.
135
123
 
136
124
  #### `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)"`)
125
+ Generate 32-byte event signatures (topic0) from ABI definitions. Supports batch operations for multiple events at once.
141
126
 
142
127
  #### `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)"`)
128
+ Generate 4-byte error selectors from ABI definitions. Supports batch operations for multiple errors at once.
147
129
 
148
130
  ### 2. Contract Interaction Tools
149
131
 
150
132
  #### `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
- ```
133
+ Call view/pure functions on smart contracts. Supports batch operations for executing multiple calls efficiently across different contracts and chains.
172
134
 
173
135
  #### `get_contract_abi`
174
- Get comprehensive contract information including ABI, proxy detection, and verification status from Etherscan.
136
+ Get comprehensive contract information including ABI, proxy detection, compilation info, creation info, and verification status from Etherscan. Includes smart caching for performance.
175
137
 
176
- **Parameters:**
177
- - `chain` (enum): Blockchain network
178
- - `address` (string): Contract address
138
+ #### `get_contract_source_code`
139
+ Retrieve verified contract source code from Etherscan with proxy support and flexible output options (full source, summary, or metadata only). Features smart caching.
179
140
 
180
- #### `is_contract`
181
- Check if an address is a smart contract or EOA (Externally Owned Account).
141
+ #### `get_contract_source_file`
142
+ Retrieve specific source file from cached contract data. Use after calling `get_contract_source_code` with full source option.
182
143
 
183
- **Parameters:**
184
- - `chain` (enum): Blockchain network
185
- - `address` (string): Address to check
144
+ #### `is_contract`
145
+ Check if an address is a smart contract or EOA (Externally Owned Account). Returns contract status and bytecode length.
186
146
 
187
- ### 3. Balance Query Tools
147
+ ### 3. ENS (Ethereum Name Service) Tools
188
148
 
189
- #### `get_balance`
190
- Get native token balance for an address.
149
+ #### `resolve_ens_name`
150
+ Resolve an ENS name to its Ethereum address. ENS names are human-readable identifiers (like vitalik.eth) that resolve to Ethereum addresses. Returns the resolved address or null if not found.
191
151
 
192
- **Parameters:**
193
- - `chain` (enum): Blockchain network
194
- - `address` (string): Address to check
195
- - `blockNumber` (string, optional): Specific block number
152
+ #### `reverse_resolve_ens`
153
+ Reverse resolve an Ethereum address to its primary ENS name. Returns the ENS name if the address has set a reverse record, useful for displaying human-readable names for addresses.
196
154
 
197
- #### `get_token_balance`
198
- Get ERC20/ERC777 token balance for an address.
155
+ #### `get_ens_text_record`
156
+ Retrieve text records from an ENS name. Common text record keys include:
157
+ - `avatar`: Avatar image URL
158
+ - `description`: Description text
159
+ - `email`: Email address
160
+ - `url`: Website URL
161
+ - `com.twitter`: Twitter handle
162
+ - `com.github`: GitHub username
199
163
 
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
164
+ #### `get_ens_avatar`
165
+ Get the avatar URI for an ENS name. Returns the avatar URL if set, which can be an HTTPS URL, IPFS hash, or NFT reference.
205
166
 
206
- #### `batch_native_balances`
207
- Get native token balances for multiple addresses in a single call.
167
+ #### `batch_resolve_ens_names`
168
+ Resolve multiple ENS names to addresses in a single batch operation for improved efficiency. Returns results for all names with success/failure status.
208
169
 
209
- **Parameters:**
210
- - `chain` (enum): Blockchain network
211
- - `addresses` (array): Array of addresses to check
212
- - `blockNumber` (string, optional): Specific block number
170
+ ### 4. Balance Query Tools
213
171
 
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
172
+ #### `get_balance`
173
+ 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
174
 
222
- ### 4. Event Log Tools
175
+ ### 5. Event Log Tools
223
176
 
224
177
  #### `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.
256
-
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
178
+ 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.
261
179
 
262
180
  ### 6. Advanced Tools
263
181
 
264
182
  #### `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
183
+ Read raw storage data from a contract with ABI-based decoding. Supports various types like uint256, address, bool, bytes32, etc.
273
184
 
274
185
  #### `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)
186
+ Get comprehensive block information including timestamp, hash, parent hash, and formatted dates. Defaults to latest block if not specified.
280
187
 
281
188
  #### `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`)
189
+ 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
190
 
289
191
  ## โš™๏ธ Configuration
290
192
 
@@ -301,7 +203,7 @@ The server supports multiple configuration options through environment variables
301
203
 
302
204
  **Example:**
303
205
  ```bash
304
- bun index.ts --custom-rpc '{"mainnet": "https://my-custom-rpc.com", "base": "https://base-rpc.com"}'
206
+ npx web3-tools-mcp --custom-rpc '{"mainnet": "https://my-custom-rpc.com", "base": "https://base-rpc.com"}'
305
207
  ```
306
208
 
307
209
  ## ๐Ÿ”ง Technical Features
@@ -326,114 +228,28 @@ bun index.ts --custom-rpc '{"mainnet": "https://my-custom-rpc.com", "base": "htt
326
228
  - **Balance Batching**: Query multiple balances in parallel
327
229
  - **Result Aggregation**: Organized results with success/failure tracking
328
230
 
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
231
  ## ๐Ÿ“‹ Requirements
380
232
 
381
- - **Runtime**: Bun (recommended) or Node.js
233
+ - **Runtime**: Node.js v20.0.0 or higher
234
+ - **Package Manager**: npm (recommended) or yarn/pnpm
382
235
  - **Dependencies**: viem, @envio-dev/hypersync-client, @modelcontextprotocol/sdk
383
236
  - **Network Access**: Internet connection for blockchain RPC calls
384
237
 
385
238
  ## ๐Ÿงช Testing
386
239
 
387
- The server includes a comprehensive test suite that validates all functionality:
240
+ The server includes a comprehensive test suite with 70 tests covering all functionality:
388
241
 
389
242
  ### Running Tests
390
243
 
391
244
  ```bash
392
245
  # Run all tests
393
- bun test
246
+ npm test
394
247
 
395
248
  # 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
406
-
407
- The test suite covers:
249
+ npm run test:watch
408
250
 
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
251
+ # Run tests with UI
252
+ npm run test:ui
437
253
  ```
438
254
 
439
255
  ## ๐Ÿ”— Related Tools
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "web3-tools-mcp",
3
+ "version": "1.2.0",
4
+ "description": "Model Context Protocol server for blockchain interactions using viem, Etherscan, and Hypersync",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "web3-tools-mcp": "dist/index.js"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "README.md",
14
+ "LICENSE",
15
+ "src"
16
+ ],
17
+ "engines": {
18
+ "node": ">=20.0.0"
19
+ },
20
+ "scripts": {
21
+ "clean": "rm -rf dist",
22
+ "build": "npm run clean && tsc",
23
+ "watch": "tsc --watch",
24
+ "prepare": "npm run build",
25
+ "test": "vitest run",
26
+ "test:watch": "vitest",
27
+ "test:ui": "vitest --ui"
28
+ },
29
+ "keywords": [
30
+ "mcp",
31
+ "ethereum",
32
+ "viem",
33
+ "blockchain",
34
+ "web3",
35
+ "ens",
36
+ "ethereum-name-service",
37
+ "model-context-protocol",
38
+ "ai"
39
+ ],
40
+ "author": "Benjamin Hajnal <hajnalbenjamin@gmail.com>",
41
+ "license": "MIT",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/hajnalben/web3-tools-mcp.git"
45
+ },
46
+ "bugs": {
47
+ "url": "https://github.com/hajnalben/web3-tools-mcp/issues"
48
+ },
49
+ "homepage": "https://github.com/hajnalben/web3-tools-mcp#readme",
50
+ "dependencies": {
51
+ "@envio-dev/hypersync-client": "^0.6.5",
52
+ "@modelcontextprotocol/sdk": "^1.20.1",
53
+ "viem": "^2.31.4",
54
+ "zod": "^3.25.76"
55
+ },
56
+ "devDependencies": {
57
+ "@types/node": "^20.19.23",
58
+ "@vitest/ui": "^3.2.4",
59
+ "dotenv": "^17.2.3",
60
+ "typescript": "^5.0.0",
61
+ "vitest": "^3.2.4"
62
+ }
63
+ }