Foundry Zksync

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

Expose foundry-zksync (forge, cast, anvil-zksync) tools for zkSync Era development

已验证STDIO仅桌面金融开发者工具

概览

AI 生成的概览

暴露 foundry-zksync 命令行工具,让助手能够编译、测试、部署并与 zkSync Era 智能合约交互。

可以做什么
把 foundry-zksync 工具链(forge、cast、anvil-zksync)封装为 MCP 工具。涵盖项目初始化、编译、带过滤与详细度选项的测试、gas 报告与快照、脚本执行、带结构化输出的合约部署,以及在 Etherscan 和 zkSync Explorer 上验证合约。cast 工具负责 ABI 编码与解码、calldata 解码、只读调用、改变状态的发送、余额与 nonce 查询。还可读取 foundry.toml、依据 zkSync 知识库解释错误、查询文档,并启动或检查本地 anvil-zksync 节点。
适用场景
适用于开发或测试 zkSync Era 智能合约,并希望助手直接驱动 forge 与 cast 工作流的场景。既适合基于 anvil-zksync 的本地开发,也适合在 zkSync 网络上部署与验证合约。
运行要求
以 npm 包(foundry-zksync-mcp)形式通过 stdio 在本地运行,通常使用 npx。需要 Node.js 18 或更高版本,以及通过 foundryup-zksync 安装的 foundry-zksync。签名工具需要一种钱包方式:命名 keystore 账户、带密码文件的 keystore 文件、硬件钱包、云 KMS 或私钥。云 KMS 选项涉及 AWS_KMS_KEY_ID、GCP_PROJECT_ID 等环境变量。服务器本身未声明认证。
安装前请注意
签名工具(deploy、cast_send、run_script)可以转移资金并改变链上状态。README 警告 privateKey 参数对 AI 助手可见且可能被记录,持有真实资金的私钥绝不应以此方式传入;生产环境建议使用命名 keystore、keystore 文件、硬件钱包或云 KMS。验证会把合约数据发送给 Etherscan 和 zkSync Explorer。install、clean、deploy 等命令会写入项目或网络。

安装

在 SourceWeft 中

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

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

其他 MCP 客户端

参照 仓库 中的启动说明。

README

foundry-zksync-mcp

An MCP (Model Context Protocol) server that exposes foundry-zksync CLI tools to AI assistants like Claude.

Tools

ToolDescription
initforge init with automatic zkSync config
compileforge build --zksync
testforge test --zksync with filter/verbosity options
run_scriptforge script --zksync with broadcast, sender, slow mode
deployforge create --zksync with structured output parsing
verifyforge verify-contract --zksync (Etherscan & zkSync Explorer)
installforge install for dependency management
cleanforge clean to remove build artifacts
gas_reportforge test --gas-report for gas usage analysis
snapshotforge snapshot for gas benchmarking
read_foundry_tomlRead and inspect project configuration
explainMatch errors/logs against a knowledge base of zkSync gotchas
cast_abi_encodecast abi-encode
cast_abi_decodecast abi-decode
cast_calldata_decodecast calldata-decode
cast_callcast call for read-only contract interaction
cast_sendcast send for state-changing transactions
cast_balancecast balance for ETH balance queries
cast_noncecast nonce for transaction nonce queries
get_zksync_docsLook up foundry-zksync documentation by topic
anvil_zksyncStart or check a local anvil-zksync dev node

Prerequisites

Quick Start (npx)

No install needed — run directly with npx:

bash
claude mcp add foundry-zksync -- npx -y foundry-zksync-mcp

Or add to claude_desktop_config.json / ~/.claude.json:

json
{  "mcpServers": {    "foundry-zksync": {      "command": "npx",      "args": ["-y", "foundry-zksync-mcp"]    }  }}

Install from Source

bash
git clone https://github.com/Jrigada/foundry-zksync-mcp.gitcd foundry-zksync-mcpnpm installnpm run build

Then register with Claude Code:

bash
claude mcp add foundry-zksync node /absolute/path/to/foundry-zksync-mcp/dist/index.js

Key Management

All signing tools (deploy, cast_send, run_script) support multiple wallet methods. Choose based on your security needs:

Local Development (anvil-zksync)

For local dev with well-known test keys, use privateKey directly:

privateKey: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"

These are the default anvil-zksync test accounts — they hold no real value.

Warning: Never use privateKey with keys that hold real funds. MCP tool parameters are visible to the AI assistant and may be logged.

Recommended for Production: Named Keystores

Keys are encrypted on disk — only the account name travels through MCP.

bash
# Import a private key into a named keystore (interactive, key never shown)cast wallet import deployer --interactive
# List your keystoresls ~/.foundry/keystores/

Then use account: "deployer" in any signing tool. Forge will prompt for the password at runtime, or you can point to a password file with passwordFile.

Keystore Files

If you have an existing encrypted keystore JSON file (e.g. from Geth, MetaMask export):

keystore: "/path/to/keystore.json"passwordFile: "/path/to/password.txt"

Hardware Wallets

ledger: true    # Ledgertrezor: true    # Trezor

Cloud KMS

aws: true       # AWS KMS (set AWS_KMS_KEY_ID env var)gcp: true       # Google Cloud KMS (set GCP_PROJECT_ID, GCP_LOCATION, etc.)

Signing Method Summary

MethodKey ExposureBest For
Hardware walletNone (key never leaves device)High-value production
Cloud KMSNone (key in HSM)Automated production
Named keystore (account)None through MCP (encrypted on disk)General production use
Keystore fileNone through MCP (encrypted on disk)Existing workflows
privateKeyVisible to AI assistantLocal dev with test keys only

Project Structure

src/  index.ts              MCP server entry point, registers all 21 tools  knowledge.ts          Knowledge base (45+ entries) and system addresses  tools/    shared.ts           Profile field and env builder shared across forge tools    init.ts             forge init with zkSync config    compile.ts          forge build --zksync    test.ts             forge test --zksync    run_script.ts       forge script --zksync    deploy.ts           forge create --zksync (structured output)    verify.ts           forge verify-contract --zksync    install.ts          forge install    clean.ts            forge clean    gas_report.ts       forge test --gas-report    snapshot.ts         forge snapshot    read_foundry_toml.ts  Read project config    explain.ts          Error/log explanation with knowledge base    get_zksync_docs.ts  Documentation lookup with embedded content    cast_abi_encode.ts  cast abi-encode    cast_abi_decode.ts  cast abi-decode    cast_calldata_decode.ts  cast calldata-decode    cast_call.ts        cast call    cast_send.ts        cast send    cast_balance.ts     cast balance    cast_nonce.ts       cast nonce    anvil_zksync.ts     anvil-zksync node management  __tests__/            133 tests (vitest)

来源:README.md,提交 0c030bc

工具

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

版本历史

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

评分

已满足适用检查项的 50%

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

  • 近 30 天内可连通25 分

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

  • 已声明认证方式10 分

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

  • 已列出工具15 分

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

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