Skip to main content
Glama
foundry-zksync-mcp

foundry-zksync-mcp

by Jrigada

foundry-zksync-mcp

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

Tools

Tool

Description

init

forge init with automatic zkSync config

compile

forge build --zksync

test

forge test --zksync with filter/verbosity options

run_script

forge script --zksync with broadcast, sender, slow mode

deploy

forge create --zksync with structured output parsing

verify

forge verify-contract --zksync (Etherscan & zkSync Explorer)

install

forge install for dependency management

clean

forge clean to remove build artifacts

gas_report

forge test --gas-report for gas usage analysis

snapshot

forge snapshot for gas benchmarking

read_foundry_toml

Read and inspect project configuration

explain

Match errors/logs against a knowledge base of zkSync gotchas

cast_abi_encode

cast abi-encode

cast_abi_decode

cast abi-decode

cast_calldata_decode

cast calldata-decode

cast_call

cast call for read-only contract interaction

cast_send

cast send for state-changing transactions

cast_balance

cast balance for ETH balance queries

cast_nonce

cast nonce for transaction nonce queries

get_zksync_docs

Look up foundry-zksync documentation by topic

anvil_zksync

Start or check a local anvil-zksync dev node

Related MCP server: TermPipe MCP

Prerequisites

Quick Start (npx)

No install needed — run directly with npx:

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

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

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

Install from Source

git clone https://github.com/Jrigada/foundry-zksync-mcp.git
cd foundry-zksync-mcp
npm install
npm run build

Then register with Claude Code:

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.

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

# Import a private key into a named keystore (interactive, key never shown)
cast wallet import deployer --interactive

# List your keystores
ls ~/.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    # Ledger
trezor: 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

Method

Key Exposure

Best For

Hardware wallet

None (key never leaves device)

High-value production

Cloud KMS

None (key in HSM)

Automated production

Named keystore (account)

None through MCP (encrypted on disk)

General production use

Keystore file

None through MCP (encrypted on disk)

Existing workflows

privateKey

Visible to AI assistant

Local 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)

Available Tools

21 tools
anvil_zksyncA

Start or check a local anvil-zksync development node. Supports forking from mainnet/testnet. Default port: 8011.

Inputs: action (required), port, forkUrl, forkBlockNumber, +2 more.

cast_abi_decodeA

Decode ABI-encoded hex data back into human-readable values (cast abi-decode)

Inputs: signature (required), data (required), input.

cast_abi_encodeB

ABI-encode values for a given Solidity function/constructor signature (cast abi-encode)

Inputs: signature (required), args (required).

cast_balanceB

Query the ETH balance of an address (cast balance)

Inputs: address (required), rpcUrl (required), blockTag, ether.

cast_callA

Read-only call to a deployed contract — no gas spent, no state change (cast call)

Inputs: to (required), signature (required), rpcUrl (required), args, +1 more.

cast_calldata_decodeA

Decode raw transaction calldata (with 4-byte selector) into function arguments (cast calldata-decode)

Inputs: signature (required), calldata (required).

cast_nonceA

Query the transaction nonce of an address (cast nonce). Note: on zkSync this returns the TX nonce only, not the deploy nonce.

Inputs: address (required), rpcUrl (required), blockTag.

cast_sendB

Send a state-changing transaction to a deployed contract (cast send)

Inputs: to (required), signature (required), rpcUrl (required), args, +13 more.

cleanA

Remove build artifacts (out/ and zkout/) from a foundry project (forge clean)

Inputs: projectPath (required), profile.

compileA

Compile a foundry-zksync project (forge build --zksync). Check foundry.toml for [profile.X.zksync] sections — if zkSync sources live under a specific profile (e.g. 'zksync'), pass that as the profile argument.

Inputs: projectPath (required), profile.

deployB

Deploy a contract to a zkSync network (forge create --zksync). Returns structured output with contract address, tx hash, and deployer.

Inputs: projectPath (required), contractPath (required), rpcUrl (required), profile, +16 more.

explainA

Explain raw output from foundry-zksync: error messages, logs, or transactions. Matches against a knowledge base of known zkSync gotchas and returns actionable advice. Use context='general' for background on what foundry-zksync is and how it works.

Inputs: rawText (required), context.

gas_reportA

Run tests and generate a gas usage report (forge test --zksync --gas-report). Note: zkSync gas values are aggregate-only (no computation/pubdata breakdown).

Inputs: projectPath (required), profile, filter, contractFilter, +1 more.

get_zksync_docsA

Look up foundry-zksync documentation by topic. Returns URLs to the foundry-zksync book for installation, config, testing, deployment, cheatcodes, nonces, factory deps, paymasters, verification, and more. Use topic='list' to see all available topics.

Inputs: topic (required).

initB

Scaffold a new foundry project and add [profile.default.zksync] config (forge init)

Inputs: projectPath (required), name, noGit, noCommit, +1 more.

installB

Install dependencies for a foundry project (forge install)

Inputs: projectPath (required), dependencies, noCommit.

read_foundry_tomlA

Read and return the contents of foundry.toml from a project. Useful for inspecting profiles, zkSync config, library links, and other settings.

Inputs: projectPath (required), summary.

run_scriptC

Run a forge script targeting zkSync (forge script --zksync)

Inputs: projectPath (required), scriptPath (required), profile, rpcUrl, +15 more.

snapshotB

Create or compare gas snapshots (forge snapshot --zksync). Use diff=true to compare against existing .gas-snapshot, check=true to fail on changes.

Inputs: projectPath (required), profile, filter, contractFilter, +2 more.

testA

Run tests in a foundry-zksync project (forge test --zksync). Check foundry.toml for [profile.X] sections — if the test directory differs per profile (e.g. profile 'zksync' has test = 'zksync/tests'), pass the correct profile argument.

Inputs: projectPath (required), profile, filter, contractFilter, +2 more.

verifyB

Verify a deployed contract on a block explorer (forge verify-contract --zksync). Supports Etherscan (requires API key) and zkSync Explorer (no key needed).

Inputs: projectPath (required), contractAddress (required), contractPath (required), verifier (required), +8 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 21 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: node management, ABI operations, contract interactions, compilation, deployment, testing, documentation, etc. No two tools overlap in function; even decoding tools differ in input type.

    Naming Consistency4/5

    Tools follow a mix of patterns: some are single verbs (compile, deploy), others are prefixed with 'cast_' for Foundry commands, and a few are descriptive (get_zksync_docs, read_foundry_toml). While not a strict verb_noun pattern throughout, naming is intuitive and predictable.

    Tool Count5/5

    With 21 tools, the server covers the full lifecycle of foundry-zksync development without being overwhelming. Each tool serves a necessary role, and the count is well-scoped for the domain.

    Completeness5/5

    The tool set covers all major operations: project setup, compilation, deployment, testing, gas analysis, script execution, contract interaction, ABI handling, verification, and documentation. No critical gaps are apparent for typical foundry-zksync workflows.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides AI assistants with direct terminal access to execute commands, manage files, and run persistent REPL sessions. It features automated installation scripts that educate AI assistants on its capabilities for seamless integration.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI assistants to execute Expo and EAS operations including project setup, cloud builds, OTA updates, app submission, and diagnostics.
      MIT