# foundry-zksync [Health: Active]

**Category:** 💻 Developer Tools  
**Repository:** https://github.com/Jrigada/foundry-zksync-mcp  
**GitHub Stars:** 1  
**npm Downloads (last month):** 345  
**Views:** 2  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/foundry-zksync

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

## Tools
Capabilities this server exposes over MCP:

- **init** — Scaffold a new foundry project and add [profile.default.zksync] config (forge init)
- **install** — Install dependencies for a foundry project (forge install)
- **clean** — Remove build artifacts (out/ and zkout/) from a foundry project (forge clean)
- **compile** — 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.
- **test** — 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.
- **run_script** — Run a forge script targeting zkSync (forge script --zksync)
- **deploy** — Deploy a contract to a zkSync network (forge create --zksync). Returns structured output with contract address, tx hash, and deployer.
- **verify** — Verify a deployed contract on a block explorer (forge verify-contract --zksync). Supports Etherscan (requires API key) and zkSync Explorer (no key needed).
- **gas_report** — Run tests and generate a gas usage report (forge test --zksync --gas-report). Note: zkSync gas values are aggregate-only (no computation/pubdata breakdown).
- **snapshot** — Create or compare gas snapshots (forge snapshot --zksync). Use diff=true to compare against existing .gas-snapshot, check=true to fail on changes.
- **read_foundry_toml** — Read and return the contents of foundry.toml from a project. Useful for inspecting profiles, zkSync config, library links, and other settings.
- **explain** — 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.
- **cast_abi_encode** — ABI-encode values for a given Solidity function/constructor signature (cast abi-encode)
- **cast_abi_decode** — Decode ABI-encoded hex data back into human-readable values (cast abi-decode)
- **cast_calldata_decode** — Decode raw transaction calldata (with 4-byte selector) into function arguments (cast calldata-decode)
- **cast_call** — Read-only call to a deployed contract — no gas spent, no state change (cast call)
- **cast_send** — Send a state-changing transaction to a deployed contract (cast send)
- **cast_balance** — Query the ETH balance of an address (cast balance)
- **cast_nonce** — Query the transaction nonce of an address (cast nonce). Note: on zkSync this returns the TX nonce only, not the deploy nonce.
- **get_zksync_docs** — 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.
- **anvil_zksync** — Start or check a local anvil-zksync development node. Supports forking from mainnet/testnet. Default port: 8011.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

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

## Documentation

## What foundry-zksync MCP server does

The foundry-zksync MCP server connects an MCP-compatible assistant to the foundry-zksync command-line tools used for zkSync Era projects. Its Forge-related tools can initialize a project with zkSync configuration, compile and test contracts, run scripts, deploy contracts, verify deployments, install dependencies, remove build output, and inspect `foundry.toml` settings.

It also exposes Cast operations for ABI encoding and decoding, calldata decoding, read-only calls, transactions, balance checks, and nonce queries. Gas reports and snapshots support usage analysis and benchmarking. The `explain` and `get_zksync_docs` tools provide lookup-oriented assistance for known zkSync issues and documentation topics. The `anvil_zksync` tool starts or checks a local development node.

## How it works

The server receives tool requests over MCP and invokes the corresponding foundry-zksync CLI command. Forge commands use zkSync-specific flags where applicable, such as `--zksync`; deployment output is parsed into structured results. Testing accepts filter and verbosity options, while script execution supports broadcasting, sender selection, and slow mode. Verification supports Etherscan and the zkSync Explorer.

Signing operations include deployment, transaction sending, and script execution. They can use local private keys, named encrypted keystores, keystore files, Ledger or Trezor devices, and AWS or GCP KMS options. Private keys are visible to the assistant and may be logged, so the documented guidance limits them to local test accounts. Named keystores, hardware wallets, or cloud KMS are intended for safer production workflows.

## Setup and configuration

The foundry-zksync MCP server requires Node.js 18 or newer and an installed foundry-zksync distribution through `foundryup-zksync`. The simplest setup runs it directly with npx:

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

It can also be registered in Claude Desktop configuration with `npx`, or installed from source with `npm install` followed by `npm run build`. Source-based Claude Code registration points to the built `dist/index.js` file.

Cloud KMS signing adds provider-specific configuration. AWS KMS uses `AWS_KMS_KEY_ID`; GCP KMS uses project, location, and related GCP settings. These variables are only relevant when using those signing methods, not for the basic server process.

## Tools and capabilities

- Initialize, compile, test, clean, and configure Forge projects for zkSync.
- Run scripts, deploy contracts, verify contracts, and install dependencies.
- Produce gas reports and snapshots for measurement and comparison.
- Encode ABI values, decode ABI data, and decode calldata.
- Call contracts without changing state or send state-changing transactions.
- Query balances and nonces.
- Start or inspect a local anvil-zksync node.
- Explain recognized zkSync errors and look up embedded documentation.

## Limitations and notes

The server depends on external Node.js and foundry-zksync installations; it does not replace those command-line prerequisites. Private-key parameters should not be used with accounts holding real funds because tool inputs can be exposed to the assistant or logs. The `explain` and documentation tools are based on embedded knowledge, so their coverage is limited to the included zkSync entries and documentation content.

_Full upstream README: https://allmcps.com/mcp/foundry-zksync/readme_

