web3agent 0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 DeFi Zoo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # web3agent
2
+
3
+ > Web3 MCP proxy server — gives AI agents (Claude Code, Cursor, Windsurf, OpenCode) complete Web3 capabilities through a single install.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npx web3agent init
9
+ ```
10
+
11
+ Detects your AI agent host and configures it automatically.
12
+
13
+ ## Usage
14
+
15
+ ```bash
16
+ # Configure your AI agent host
17
+ npx web3agent init
18
+
19
+ # Start the MCP server (stdio)
20
+ npx web3agent
21
+
22
+ # Options
23
+ npx web3agent --help
24
+ npx web3agent --version
25
+ ```
26
+
27
+ ## What you get
28
+
29
+ - **Blockscout** — indexed blockchain data (address info, tx history, NFTs, contract ABIs)
30
+ - **EVM MCP** — live on-chain state (balances, contract reads, gas, ENS)
31
+ - **GOAT plugins** — Uniswap, Balancer, ERC-20/721, DexScreener
32
+ - **LI.FI** — cross-chain bridging and swaps
33
+ - **Orbs** — Liquidity Hub aggregated swaps, dTWAP, dLIMIT orders
34
+ - **Wallet management** — generate, persist, derive addresses
35
+
36
+ ## Supported Hosts
37
+
38
+ | Host | Config Location |
39
+ |------|----------------|
40
+ | Claude Code | `~/.claude/mcp.json` |
41
+ | Cursor | `.cursor/mcp.json` |
42
+ | Windsurf | `~/.codeium/windsurf/mcp_config.json` |
43
+ | OpenCode | `.opencode/config.json` |
44
+
45
+ ## Supported Chains
46
+
47
+ Ethereum, Base, Arbitrum, Optimism, Polygon, Linea, BSC, Avalanche, zkSync Era, Scroll, Mode, Blast, Mantle, Celo, Gnosis, Sepolia, Base Sepolia.
48
+
49
+ Default: **Base (8453)**. Override with `CHAIN_ID` env var or `chainId` parameter per call.
50
+
51
+ ## Environment Variables
52
+
53
+ See [WEB3_CONTEXT.md](./WEB3_CONTEXT.md) for the full environment variable table.
54
+
55
+ ## Requirements
56
+
57
+ - Node.js 18+
58
+ - pnpm (for development)
59
+
60
+ ## License
61
+
62
+ MIT
@@ -0,0 +1,91 @@
1
+ # Web3Agent — MCP Proxy Context
2
+
3
+ All Web3 tools are accessible through a single `web3agent` MCP server entry.
4
+
5
+ ## Tool Routing Guide
6
+
7
+ ### Blockscout tools (prefix: `blockscout_`)
8
+ Indexed blockchain data: address info, token balances, transaction history, NFT metadata, contract ABI, contract source code, ENS resolution, block info. Works on 3000+ chains.
9
+
10
+ Tools: `blockscout_get_address_info`, `blockscout_get_tokens_by_address`, `blockscout_get_transactions_by_address`, `blockscout_get_token_transfers_by_address`, `blockscout_nft_tokens_by_address`, `blockscout_get_block_info`, `blockscout_get_transaction_info`, `blockscout_get_contract_abi`, `blockscout_inspect_contract_code`, `blockscout_read_contract`, `blockscout_get_block_number`, `blockscout_lookup_token_by_symbol`, `blockscout_get_address_by_ens_name`, `blockscout_get_chains_list`, `blockscout_direct_api_call`
11
+
12
+ ### EVM tools (prefix: `evm_`)
13
+ Live on-chain state: current balances, contract reads, gas estimation, ENS resolution, multicall, signing. Writes require a configured wallet.
14
+
15
+ ### Wallet tools (prefix: `wallet_`)
16
+ - `wallet_generate` — generate new wallet (key shown once, never stored)
17
+ - `wallet_generate_mnemonic` — generate BIP-39 mnemonic
18
+ - `wallet_from_mnemonic` — derive address from mnemonic
19
+ - `wallet_derive_addresses` — batch derive 1-20 addresses
20
+ - `wallet_get_active` — get current wallet address, chain, mode
21
+
22
+ ### Transaction management
23
+ - `transaction_confirm(id)` — execute a queued write operation
24
+ - `transaction_deny(id)` — discard a queued operation
25
+ - `transaction_list()` — list pending operations
26
+
27
+ ### DeFi tools
28
+
29
+ **GOAT plugins** (Uniswap, Balancer, ERC-20, ERC-721, ENS, DexScreener):
30
+ - All accept optional `chainId` parameter (defaults to active chain)
31
+ - Uniswap: chains 1, 137, 43114, 8453, 10, 42161, 42220
32
+ - Balancer: chains 34443, 8453, 137, 100, 42161, 43114, 10
33
+
34
+ **LI.FI cross-chain bridging** (prefix: `lifi_`):
35
+ - `lifi_get_chains` — list supported chains
36
+ - `lifi_get_quote` — get bridge/swap quote
37
+ - `lifi_execute_bridge` — execute cross-chain bridge (write, confirmation-gated)
38
+
39
+ **Orbs DeFi** (prefix: `orbs_`):
40
+ - `orbs_get_quote` — Liquidity Hub aggregated swap quote (chains: 137, 56, 8453, 59144, 81457, 42161)
41
+ - `orbs_swap` — execute swap (write, confirmation-gated)
42
+ - `orbs_place_twap` — place dTWAP order (write, confirmation-gated)
43
+ - `orbs_place_limit` — place dLIMIT order (write, confirmation-gated)
44
+ - `orbs_list_orders` — list open TWAP/dLIMIT orders
45
+
46
+ ### Utilities
47
+ - `server_status` — wallet mode, active chain, confirmation setting, backend health
48
+ - `list_supported_chains` — all 17 supported chains with IDs and names
49
+
50
+ ## Chain Selection
51
+ Default chain: **Base (8453)**. Override per-call with `chainId` parameter.
52
+
53
+ Supported chains:
54
+ | Chain | ID |
55
+ |-------|-----|
56
+ | Ethereum | 1 |
57
+ | Base | 8453 |
58
+ | Arbitrum | 42161 |
59
+ | Optimism | 10 |
60
+ | Polygon | 137 |
61
+ | Linea | 59144 |
62
+ | BSC | 56 |
63
+ | Avalanche | 43114 |
64
+ | zkSync Era | 324 |
65
+ | Scroll | 534352 |
66
+ | Mode | 34443 |
67
+ | Blast | 81457 |
68
+ | Mantle | 5000 |
69
+ | Celo | 42220 |
70
+ | Gnosis | 100 |
71
+ | Sepolia | 11155111 |
72
+ | Base Sepolia | 84532 |
73
+
74
+ ## Confirmation Queue
75
+ Write operations (swaps, bridges, transfers) are queued by default. Use `transaction_confirm(id)` to execute. Disable with `CONFIRM_WRITES=false`.
76
+
77
+ ## Environment Variables
78
+ | Variable | Default | Description |
79
+ |----------|---------|-------------|
80
+ | `CHAIN_ID` | 8453 | Default chain (Base) |
81
+ | `PRIVATE_KEY` | — | Wallet private key |
82
+ | `MNEMONIC` | — | BIP-39 mnemonic |
83
+ | `WALLET_ACCOUNT_INDEX` | 0 | HD account index |
84
+ | `WALLET_ADDRESS_INDEX` | 0 | HD address index |
85
+ | `RPC_URL` | — | Custom RPC for default chain |
86
+ | `CONFIRM_WRITES` | true | Require confirmation for writes |
87
+ | `BLOCKSCOUT_MCP_URL` | https://mcp.blockscout.com/mcp | Blockscout MCP endpoint |
88
+ | `ETHERSCAN_API_KEY` | — | Etherscan API key |
89
+ | `LIFI_API_KEY` | — | LI.Fi API key |
90
+ | `ZEROX_API_KEY` | — | 0x API key (enables 0x plugin) |
91
+ | `COINGECKO_API_KEY` | — | CoinGecko API key (enables CoinGecko plugin) |
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/version.ts
4
+ var VERSION = true ? "0.1.0" : "0.0.0-dev";
5
+
6
+ export {
7
+ VERSION
8
+ };
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/chains/registry.ts
4
+ import * as viemChains from "viem/chains";
5
+ var CHAINS_BY_ID = /* @__PURE__ */ new Map();
6
+ var CHAINS_BY_NAME = /* @__PURE__ */ new Map();
7
+ for (const value of Object.values(viemChains)) {
8
+ if (value && typeof value === "object" && "id" in value && "name" in value) {
9
+ const chain = value;
10
+ CHAINS_BY_ID.set(chain.id, chain);
11
+ CHAINS_BY_NAME.set(chain.name.toLowerCase(), chain);
12
+ }
13
+ }
14
+ function getChainById(id) {
15
+ return CHAINS_BY_ID.get(id);
16
+ }
17
+ function isSupported(id) {
18
+ return CHAINS_BY_ID.has(id);
19
+ }
20
+
21
+ // src/config/env.ts
22
+ var BLOCKSCOUT_DEFAULT_URL = "https://mcp.blockscout.com/mcp";
23
+ var ETHERSCAN_DEFAULT_URL = "https://mcp.etherscan.io/mcp";
24
+ var ValidationError = class extends Error {
25
+ field;
26
+ rawValue;
27
+ constructor(field, rawValue, message) {
28
+ super(message);
29
+ this.name = "ValidationError";
30
+ this.field = field;
31
+ this.rawValue = rawValue;
32
+ }
33
+ };
34
+ var FALSE_VALUES = /* @__PURE__ */ new Set(["false", "0", "no"]);
35
+ function parseBoolean(value, fallback) {
36
+ if (value === void 0 || value === "") return fallback;
37
+ return !FALSE_VALUES.has(value.toLowerCase());
38
+ }
39
+ function parseIntStrict(field, value, fallback) {
40
+ if (value === void 0 || value === "") return fallback;
41
+ const parsed = Number(value);
42
+ if (!Number.isInteger(parsed)) {
43
+ throw new ValidationError(field, value, `${field} must be an integer, got "${value}"`);
44
+ }
45
+ return parsed;
46
+ }
47
+ var RPC_URL_PREFIX = "RPC_URL_";
48
+ function parseChainRpcUrls(env) {
49
+ const urls = {};
50
+ for (const [key, value] of Object.entries(env)) {
51
+ if (key.startsWith(RPC_URL_PREFIX) && value) {
52
+ const chainId = Number(key.slice(RPC_URL_PREFIX.length));
53
+ if (Number.isInteger(chainId) && chainId > 0) {
54
+ urls[chainId] = value;
55
+ }
56
+ }
57
+ }
58
+ return urls;
59
+ }
60
+ function parseEnv(env = {}) {
61
+ const chainId = parseIntStrict("CHAIN_ID", env.CHAIN_ID, 8453);
62
+ if (!isSupported(chainId)) {
63
+ throw new ValidationError(
64
+ "CHAIN_ID",
65
+ env.CHAIN_ID ?? String(chainId),
66
+ `Unsupported chain ID: ${chainId}`
67
+ );
68
+ }
69
+ return {
70
+ chainId,
71
+ privateKey: env.PRIVATE_KEY || void 0,
72
+ mnemonic: env.MNEMONIC || void 0,
73
+ walletAccountIndex: parseIntStrict("WALLET_ACCOUNT_INDEX", env.WALLET_ACCOUNT_INDEX, 0),
74
+ walletAddressIndex: parseIntStrict("WALLET_ADDRESS_INDEX", env.WALLET_ADDRESS_INDEX, 0),
75
+ rpcUrl: env.RPC_URL || void 0,
76
+ chainRpcUrls: parseChainRpcUrls(env),
77
+ confirmWrites: parseBoolean(env.CONFIRM_WRITES, true),
78
+ blockscoutMcpUrl: env.BLOCKSCOUT_MCP_URL || BLOCKSCOUT_DEFAULT_URL,
79
+ etherscanMcpUrl: env.ETHERSCAN_MCP_URL || ETHERSCAN_DEFAULT_URL,
80
+ etherscanApiKey: env.ETHERSCAN_API_KEY || void 0,
81
+ lifiApiKey: env.LIFI_API_KEY || void 0,
82
+ zeroxApiKey: env.ZEROX_API_KEY || void 0,
83
+ coingeckoApiKey: env.COINGECKO_API_KEY || void 0,
84
+ orbsPartner: env.ORBS_PARTNER || void 0
85
+ };
86
+ }
87
+ var cached;
88
+ function setConfig(config) {
89
+ cached = config;
90
+ }
91
+ function getConfig() {
92
+ if (!cached) {
93
+ throw new Error("Config not initialized \u2014 call setConfig() during startup");
94
+ }
95
+ return cached;
96
+ }
97
+
98
+ export {
99
+ getChainById,
100
+ isSupported,
101
+ BLOCKSCOUT_DEFAULT_URL,
102
+ ETHERSCAN_DEFAULT_URL,
103
+ ValidationError,
104
+ parseEnv,
105
+ setConfig,
106
+ getConfig
107
+ };
package/dist/index.js ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ VERSION
4
+ } from "./chunk-4GQR4EEY.js";
5
+
6
+ // src/index.ts
7
+ var args = process.argv.slice(2);
8
+ if (args[0] === "init") {
9
+ import("./init-DKWQSYDZ.js").then(({ runInit }) => {
10
+ runInit(args.slice(1)).catch((e) => {
11
+ process.stderr.write(`Error: ${e.message}
12
+ `);
13
+ process.exit(1);
14
+ });
15
+ });
16
+ } else if (args.includes("--version")) {
17
+ process.stderr.write(`web3agent ${VERSION}
18
+ `);
19
+ process.exit(0);
20
+ } else if (args.includes("--help")) {
21
+ process.stderr.write(
22
+ `${[
23
+ "web3agent \u2014 Web3 MCP proxy server",
24
+ "",
25
+ "Usage:",
26
+ " web3agent Start MCP proxy server (stdio)",
27
+ " web3agent init Configure your AI agent host",
28
+ "",
29
+ "Options:",
30
+ " --version Print version",
31
+ " --help Print this help"
32
+ ].join("\n")}
33
+ `
34
+ );
35
+ process.exit(0);
36
+ } else {
37
+ import("./startup-PHXZQ2SL.js").then(({ startServer }) => {
38
+ startServer().catch((e) => {
39
+ process.stderr.write(`Fatal: ${e.message}
40
+ `);
41
+ process.exit(1);
42
+ });
43
+ });
44
+ }