web3agent

io.github.Apegurus由 GitHub 账号 Apegurus 发布v0.6.2更新于 Oct 24, 2026

Web3 MCP proxy for AI agents: DeFi swaps, bridges, market data, wallets, and gated writes.

概览

AI 生成的概览

让 AI 助手获得 EVM 与 DeFi 工具:兑换、跨链桥、订单、交易所交易、行情数据、研究与钱包管理。

可以做什么
这是一个本地 stdio MCP 服务器,提供 190 多个工具,覆盖 EVM 链与 DeFi。功能包括链上读写、代币兑换、跨链桥、限价与触发订单、CCXT 交易所交易、区块浏览器查询、行情与研究数据、代币解析以及钱包生命周期管理。默认情况下写操作需经确认队列,钱包密钥工具默认关闭,除非显式启用。
适用场景
当助手需要报价、准备或执行兑换、跨链桥、订单等 DeFi 操作,或读取多条 EVM 链上的余额、交易与行情数据时适用。适合希望直接使用协议集成而不自行重建的智能体开发者与 DeFi 团队。
运行要求
以 npx 运行的本地进程;需要 Node.js 22+。可选密钥:COINGECKO_API_KEY、ETHERSCAN_API_KEY、ZEROX_API_KEY、OWS_PASSPHRASE。可选 CCXT_CONFIG_PATH 用于交易所凭据,CHAIN_ID 用于覆盖默认的 Base 主网(8453)。需要访问 RPC 与数据提供方的网络。
安装前请注意
它可以用真实资金执行链上交易与交易操作;写操作默认通过 CONFIRM_WRITES 确认门控,建议保持开启。除非设置 WEB3AGENT_ALLOW_AGENT_VISIBLE_SECRETS=1,钱包密钥不会进入智能体上下文,该设置会把私钥或助记词暴露给模型。OWS_PASSPHRASE 用于保护持久化钱包,未设置时回退到仅靠文件权限的旧存储。CCXT_CONFIG_PATH 中的交易所凭据与各 API 密钥均属敏感信息。

安装

在 SourceWeft 中

  1. 打开 控制台中的 web3agent,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

[npm version] [npm downloads] [License: MIT] [GitHub stars] [smithery badge]

See it in production: The Arena — 11 AI agents trade real capital through Web3Agent.

web3agent

MCP package: web3agent | npm: https://www.npmjs.com/package/web3agent | GitHub: https://github.com/Apegurus/web3agent | Contact: [email protected]

Links: Website · GitHub · npm · Smithery · The Arena · X / @Web3AgentFi

Give your AI agent EVM execution and DeFi tooling: swaps, bridges, limit and trigger orders, exchange trading, market data, research, wallet management. 190+ MCP tools. One install.

Works out of the box with Claude Code, Cursor, Windsurf, OpenCode, and Codex. Self-custodial. By default, write operations go through a confirmation queue: nothing executes without your approval unless you explicitly disable confirmations.

EVM execution is a solved problem. Stop rebuilding it. Plug in and ship.


What you can do

Once installed, your AI agent can execute real DeFi operations in plain language:

  • "Swap 0.1 ETH for USDC on Base" — quoted, routed, confirmation-gated, executed
  • "Bridge 500 USDC from Arbitrum to Optimism" — cross-chain via LI.FI, 20+ chains
  • "Set a limit or trigger order to buy ETH at $2,800" — decentralized Spot orders via Orbs
  • "Cancel my open orders on Binance" — CCXT exchange access with per-method risk classification
  • "What's my USDC balance on Base?" — read-only EVM and ERC-20 balance checks
  • "Show me yield opportunities above 5% APY" — research tools, protocol analysis, due diligence

Common flows avoid ABI handling and transaction building. Generic contract reads and writes are available when you provide or register an ABI, or when explorer ABI lookup is available. The agent handles routing, transaction preparation, and the confirmation queue. You approve, it executes.


Quickstart for agent power users

bash
npx web3agent init

This detects Claude Code, Cursor, Windsurf, OpenCode, or Codex and configures the MCP server automatically. Restart your host, then ask:

text
What Web3 tools do you have available, and what chain are you configured for?

For any other MCP-capable host, configure a stdio server that runs:

bash
npx web3agent

The generic MCP config shape is:

json
{  "web3agent": {    "type": "stdio",    "command": "npx",    "args": ["web3agent"]  }}

Writes are confirmation-gated by default, and wallet secrets are not exposed through MCP unless explicitly enabled.

For a step-by-step guide covering both human and agent setups, see docs/guides/universal-access.md.

Smithery local bundle

Smithery URL publishing requires a hosted Streamable HTTP MCP endpoint. Web3Agent is distributed as a local stdio/npm server, so Smithery distribution uses an MCPB bundle instead:

bash
pnpm run mcpb:checksmithery mcp publish dist/web3agent.mcpb -n Apegurus/web3agent

The generated MCPB is a thin local bundle that launches the published npm package with npm exec --package [email protected].

Why Web3Agent

  • One-line install. npx web3agent init auto-configures Claude Code, Cursor, Windsurf, OpenCode, or Codex. No manual config edits for supported hosts.
  • Self-custodial. Keys stay in your environment, wallet secrets are kept out of agent-visible MCP flows by default, and every write goes through the confirmation queue unless you intentionally disable it.
  • Battle-tested infrastructure. Built on GOAT SDK, LI.FI, Orbs, Blockscout, Etherscan, DexScreener, and other production Web3 rails.
  • Live in production. Powers Orbzy and The Arena, where AI agents trade real capital through Web3Agent.
  • One MCP surface. Swaps, bridges, orders, market data, research, token resolution, wallet lifecycle, and agent-payment protocols are available through one server.

Who it is for

  • AI agent builders who need Web3 execution without rebuilding protocol integrations
  • DeFi teams adding MCP support to internal tools, research agents, or trading agents
  • Developers prototyping wallet-aware agents, swaps, bridges, and market workflows
  • MCP host users who want read-only chain data plus explicit-confirmation write flows

Copy-paste prompts

Use these after installation to get to value quickly:

text
List the supported chains and tell me which Web3 tools are safest to try first.
text
Resolve USDC, WETH, and DEGEN on Base. Show token addresses and decimals.
text
Quote swapping 0.01 ETH to USDC on Base, but do not execute anything.
text
Show yield opportunities above 5% APY and explain the main protocol risks.
text
Explain this wallet's recent activity on Base: 0x0000000000000000000000000000000000000000

Supported hosts

HostConfig location
Claude Code~/.claude/mcp.json
Cursor.cursor/mcp.json
Windsurf~/.codeium/windsurf/mcp_config.json
OpenCode.opencode/config.json
Codex.codex/config.toml
OpenClawagent-mediated self-install via canonical guide

Supported chains

Basic EVM operations use viem's chain registry and can target any viem-supported EVM chain when RPC access is available.

Enhanced swap and order integrations currently cover Ethereum, Base, Arbitrum, Optimism, Polygon, Linea, BSC, Avalanche, Sonic, Mode, Blast, Celo, and Gnosis. Token resolution, explorer, LI.FI, and market/research tools have provider-specific coverage; LI.FI bridge quotes and execution support 20+ chains through LI.FI's own chain list.

Default: Base (8453). Override with the CHAIN_ID env var or pass chainId per call.


What's included

CapabilityProviderNotes
On-chain stateNative EVM toolsBalances, contract reads/writes, gas, ENS, multicall (27 tools)
SwapsGOAT / Uniswap / BalancerSame-chain, ERC-20/721
Aggregated swapsOrbs Liquidity HubOptimal pricing via solver network
Cross-chain bridgesLI.FI20+ chains
LendingGOAT SDK / protocol integrationsAave, Morpho, and major money-market surfaces where supported
Advanced ordersOrbsSpot market, limit, TWAP, stop-loss, take-profit, delayed orders
Exchange tradingCCXTPublic/private access across 100+ exchanges (6 tools)
Block explorerBlockscout + EtherscanAddress info, tx history, NFTs, contract ABIs, network stats (35 tools)
Market dataDefiLlama / CoinGecko / BinanceTVL, prices, DEX volume, stablecoin stats, sentiment (20 tools)
ResearchDefiLlama / on-chainContract security, yield analysis, whale tracking, governance (13 tools)
Token resolutionBuilt-in registry + DexScreenerSymbol-to-address, long-tail assets
Wallet managementweb3agent + Open Wallet StandardCLI/MCP lifecycle, encrypted OWS vault when configured, legacy fallback
Confirmation queueBuilt-inWrite operations require explicit approval by default
Agent protocolsaGDP / ACP / ERC-8183 / x402 / ERC-8004Agent marketplace, cooperation, payments
Price dataCoinGeckoRequires COINGECKO_API_KEY
0x swaps0xRequires ZEROX_API_KEY

Starter templates

bash
npx web3agent create

Scaffolds a ready-to-run project from one of three bundled templates:

  • Vercel AI SDK — chat agent with tool calling
  • Mastra — agent framework with web3agent tools
  • MCP-host — lightweight MCP client

Each starter uses the same web3agent lifecycle surfaces as MCP and CLI.


Examples

Root examples are included in the npm package:

bash
# Safe import-only previewsnode examples/swap.mjsnode examples/bridge.mjs
# Read-only live quote examplesnode examples/swap.mjs --quotenode examples/bridge.mjs --quote
# Prepared external-wallet flowsWEB3AGENT_EXAMPLE_ACCOUNT=0x... node examples/swap.mjs --prepareWEB3AGENT_EXAMPLE_ACCOUNT=0x... node examples/bridge.mjs --prepare

The examples default to small USDC-denominated flows and only prepare wallet actions when you pass --prepare.

Quickstart examples

Agent that prepares a swap on Base

js
import { prepareOperation, resolveCanonicalTokenSync } from "web3agent";
const chainId = 8453;const usdc = resolveCanonicalTokenSync({ chainId, symbol: "USDC" });const weth = resolveCanonicalTokenSync({ chainId, symbol: "WETH" });
if (!usdc || !weth) throw new Error("Missing canonical token");
const intent = await prepareOperation({  integration: "orbs",  kind: "swap",  account: "0xYourWallet",  chainId,  fromToken: usdc.address,  toToken: weth.address,  fromAmount: "10000000",  slippagePct: 0.5,});
console.log(intent.nextActions);

Agent that prepares a bridge from Ethereum to Arbitrum

js
import { prepareOperation, resolveCanonicalTokenSync } from "web3agent";
const fromChainId = 1;const toChainId = 42161;const from = resolveCanonicalTokenSync({ chainId: fromChainId, symbol: "USDC" });const to = resolveCanonicalTokenSync({ chainId: toChainId, symbol: "USDC" });
if (!from || !to) throw new Error("Missing canonical token");
const bridge = await prepareOperation({  integration: "lifi",  kind: "bridge",  account: "0xYourWallet",  fromChainId,  toChainId,  fromToken: from.address,  toToken: to.address,  fromAmount: "1000000",});
console.log(bridge.nextActions);

Agent that monitors a wallet

js
import { getAddressInfo, getTransactionHistory, listSupportedChains } from "web3agent";
const address = "0x0000000000000000000000000000000000000000";const chainId = 8453;
const [chains, info, history] = await Promise.all([  listSupportedChains(),  getAddressInfo({ address, chainId }),  getTransactionHistory({ address, chainId, pageSize: 5 }),]);
console.log({  supportedChains: chains.chains.length,  wallet: info,  recentTransactions: history.transactions,});

For crypto teams

Use web3agent when you want AI agents to discover or interact with your protocol without every team rebuilding wallet, chain, token, quote, explorer, and confirmation plumbing.

Integration surfaces:

  • MCP tools for Claude Code, Cursor, Windsurf, OpenCode, Codex, and other MCP hosts
  • Programmatic SDK from web3agent for app-owned agents and browser-wallet flows
  • Prepared operations for protocols that need users or apps to sign externally
  • Confirmation-gated writes so execution never bypasses an explicit approval path by default

Good first integration targets:

  • token, market, and position reads
  • quote and simulation tools
  • prepared wallet actions for browser/app signing
  • protocol-specific research or risk tools

For protocol support or integration questions, open an issue at https://github.com/Apegurus/web3agent/issues or contact [email protected].


Usage

bash
# Initialize for your host (run once)npx web3agent init
# Start the MCP servernpx web3agent
# CLI fallback (for non-MCP hosts or scripting)npx web3agent tools list --jsonnpx web3agent tools call resolve_token --input '{"symbol":"USDC","chainId":8453}' --jsonnpx web3agent doctor --json
# Local-only wallet secret flows (requires OWS_PASSPHRASE >= 12 chars and an interactive TTY)OWS_PASSPHRASE='...' npx web3agent wallet generateOWS_PASSPHRASE='...' npx web3agent wallet generate --mnemonicOWS_PASSPHRASE='...' npx web3agent wallet activate --from-file ./secret.txt --type private-key
# Optionsnpx web3agent --helpnpx web3agent --version

Wallet secret MCP tools are disabled by default so private keys and mnemonics do not enter an AI agent's inference context. Use the local web3agent wallet ... commands above for safe generation/import. If you explicitly accept the risk of agent-visible secrets, set WEB3AGENT_ALLOW_AGENT_VISIBLE_SECRETS=1 to re-enable the legacy MCP behavior.

wallet_deactivate only deactivates the current runtime session and returns to read-only ephemeral mode. Use confirmation-gated wallet_delete when you intentionally want to permanently remove persisted wallet material.

Wallet security defaults

By default, web3agent keeps wallet secrets out of MCP tool responses and agent-visible inputs. The local web3agent wallet ... commands are the recommended way to generate or import private keys and mnemonics because they require an interactive TTY and refuse JSON secret output. Set WEB3AGENT_ALLOW_AGENT_VISIBLE_SECRETS=1 only if you explicitly accept that private keys or mnemonics can be sent through the MCP host and visible to the agent/inference provider.

For persisted server-side wallets, setting OWS_PASSPHRASE is not mandatory, but strongly recommended. When it is set on macOS/Linux and OWS is available, web3agent uses the Open Wallet Standard encrypted vault instead of the legacy filesystem-protected wallet store. The OWS spec minimum is 12 characters; web3agent warns on weak runtime passphrases and local wallet generation/import rejects shorter values. Use a 16+ character mixed passphrase in production. Configure it in the process that runs web3agent, whether that is npx web3agent as an MCP server or an app/service using createRuntime({ env: { OWS_PASSPHRASE: "..." } }).

If OWS_PASSPHRASE is missing, empty, OWS is unavailable, the platform is Windows, or OWS_FORCE_LEGACY=1 is set, web3agent falls back to legacy wallet storage protected by file permissions only. Migrating a legacy wallet.json leaves a plaintext wallet.json.migrated rollback backup; delete it after verifying OWS access. For multi-agent services, run separate wallet-using runtimes in separate processes until per-runtime wallet isolation is supported.


Programmatic usage

Root API

Use the package root for stable, typed EVM capabilities from another app or agent layer.

javascript
import {  getChain,  listChainTokens,  resolveCanonicalTokenSync,  resolveToken,} from "web3agent";
const chain = getChain(8453);const usdc = resolveCanonicalTokenSync({ symbol: "USDC", chainId: 8453 });const tokens = listChainTokens({ chainId: 8453 });const discovered = await resolveToken({ symbol: "DEGEN", chainId: 8453 });
console.log(  chain?.name,  usdc?.address,  discovered.address,  tokens.tokens.length,);

Use resolveCanonicalToken() for well-known registry tokens and native-token aliases. Use resolveToken() when you also want DexScreener discovery fallback for long-tail assets.

Browser wallet flows

Use the root API when your app owns the signer (e.g. a browser wallet via wagmi or AppKit).

javascript
import {  prepareOperation,  resumeOperation,  simulateTransaction,} from "web3agent";
  1. prepareOperation(...) returns the next wallet actions plus resumeState
  2. Your app executes those actions with the browser wallet
  3. resumeOperation(...) continues until the operation completes

Transaction actions are only considered complete once you return a confirmed result:

javascript
{ type: "transaction", txHash: "0x...", status: "confirmed" }

resumeOperation() independently verifies the receipt before advancing.

Architecture notes: docs/architecture/browser-wallet-operations.md

Runtime API

Use web3agent/runtime when you need tool discovery, generic invocation, or upstream passthrough tools.

javascript
import { createRuntime } from "web3agent/runtime";
const runtime = await createRuntime();
try {  console.log(runtime.getHealth());  console.log(    runtime      .listTools()      .slice(0, 5)      .map((tool) => tool.name),  );  const result = await runtime.invokeTool("list_supported_chains");  console.log(result.structuredContent);} finally {  await runtime.shutdown();}

Environment variables

See WEB3_CONTEXT.md for the full environment variable reference.

For authenticated exchange access via CCXT tools, set CCXT_CONFIG_PATH to a JSON file containing named accounts and exchange credentials.


Known limitations

  • Blockscout explorer tools work on 8 chains only (Ethereum, Polygon, Arbitrum, Optimism, Base, Gnosis, Scroll, zkSync Era)
  • Yield tooling is read-only research; protocol-specific execution beyond first-class tools uses ABI-backed EVM calls
  • 0x and CoinGecko plugins require their respective API keys
  • MCP hosts cannot open a browser wallet prompt directly — MCP can prepare, simulate, and submit signed payloads, but signing requires your app to handle the wallet interaction

Requirements

  • Node.js 22+
  • pnpm (for development)

License

MIT

来源:README.md,提交 122f159

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.6.2最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分