铸造厂zksync mcp
一个MCP(模型上下文协议)服务器,它公开 肮脏的zksync CLI工具,用于像Claude这样的AI助手。
工具
| 工具 | 说明 |
|---|---|
init | forge init 具有自动zkSync配置 |
compile | forge build --zksync |
test | forge test --zksync 具有过滤/冗长选项 |
run_script | forge script --zksync 具有广播、发送器、慢速模式 |
deploy | forge create --zksync 使用结构化输出解析 |
verify | forge verify-contract --zksync (Etherscan和zkSync浏览器) |
install | forge install 用于依赖关系管理 |
clean | forge clean 删除构建工件 |
gas_report | forge test --gas-report 用于气体使用分析 |
snapshot | forge snapshot 用于天然气基准测试 |
read_foundry_toml | 阅读并检查项目配置 |
explain | 将错误/日志与zkSync陷阱的知识库进行匹配 |
cast_abi_encode | cast abi-encode |
cast_abi_decode | cast abi-decode |
cast_calldata_decode | cast calldata-decode |
cast_call | cast call 用于只读合约交互 |
cast_send | cast send 用于状态更改事务 |
cast_balance | cast balance 用于ETH余额查询 |
cast_nonce | cast nonce 用于事务随机数查询 |
get_zksync_docs | 按主题查找代工zksync文档 |
anvil_zksync | 启动或检查本地砧zksync开发节点 |
先决条件
- Node.js>=18
- 肮脏的zksync 已安装(
foundryup-zksync)
快速入门(npx)
无需安装--直接使用npx运行:
claude mcp add foundry-zksync -- npx -y foundry-zksync-mcp或添加到 claude_desktop_config.json / ~/.claude.json:
{
"mcpServers": {
"foundry-zksync": {
"command": "npx",
"args": ["-y", "foundry-zksync-mcp"]
}
}
}从源代码安装
git clone https://github.com/Jrigada/foundry-zksync-mcp.git
cd foundry-zksync-mcp
npm install
npm run build然后用Claude Code注册:
claude mcp add foundry-zksync node /absolute/path/to/foundry-zksync-mcp/dist/index.js密钥管理
所有签名工具(deploy, cast_send, run_script)支持多种钱包方式。根据您的安全需求进行选择:
地方发展(砧zksync)
对于具有众所周知的测试密钥的本地开发人员,请使用 privateKey 直接:
privateKey: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"这些是默认的砧zksync测试帐户——它们没有真正的价值。
警告: 从不使用 privateKey 持有真实资金的钥匙。MCP工具参数对AI助手可见,并可能被记录下来。推荐生产:命名Keystore
密钥在磁盘上加密——只有帐户名通过MCP。
# Import a private key into a named keystore (interactive, key never shown)
cast wallet import deployer --interactive
# List your keystores
ls ~/.foundry/keystores/然后使用 account: "deployer" 在任何签名工具中。Forge将在运行时提示输入密码,或者您可以指向一个密码文件 passwordFile.
密钥库文件
如果您有一个现有的加密密钥库JSON文件(例如来自Geth、MetaMask导出):
keystore: "/path/to/keystore.json"
passwordFile: "/path/to/password.txt"硬件钱包
ledger: true # Ledger
trezor: true # Trezor云知识管理系统
aws: true # AWS KMS (set AWS_KMS_KEY_ID env var)
gcp: true # Google Cloud KMS (set GCP_PROJECT_ID, GCP_LOCATION, etc.)签名方法摘要
| 方法 | 关键曝光 | 最适合 |
|---|---|---|
| 硬件钱包 | 无(密钥永不离开设备) | 高价值生产 |
| 云KMS | 无(HSM中的密钥) | 自动化生产 |
命名密钥库(account) | 通过MCP(磁盘加密)无 | 一般生产用途 |
| 密钥库文件 | 通过MCP(在磁盘上加密)无 | 现有工作流 |
privateKey | AI助手可见 | 仅使用测试密钥的本地开发人员 |
项目结构
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)