foundry-zksync-mcp
Integrates with Google Cloud KMS for secure transaction signing during deployments and contract interactions.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@foundry-zksync-mcp compile the contract in src/Counter.sol"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
foundry-zksync-mcp
An MCP (Model Context Protocol) server that exposes foundry-zksync CLI tools to AI assistants like Claude.
Tools
Tool | Description |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Read and inspect project configuration |
| Match errors/logs against a knowledge base of zkSync gotchas |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Look up foundry-zksync documentation by topic |
| Start or check a local anvil-zksync dev node |
Related MCP server: TermPipe MCP
Prerequisites
Node.js >= 18
foundry-zksync installed (
foundryup-zksync)
Quick Start (npx)
No install needed — run directly with npx:
claude mcp add foundry-zksync -- npx -y foundry-zksync-mcpOr 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 buildThen register with Claude Code:
claude mcp add foundry-zksync node /absolute/path/to/foundry-zksync-mcp/dist/index.jsKey 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
privateKeywith 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.
# 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 # TrezorCloud 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 ( | None through MCP (encrypted on disk) | General production use |
Keystore file | None through MCP (encrypted on disk) | Existing workflows |
| 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 toolsanvil_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
Scored across 21 tools
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.
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.
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.
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
AI Agent Utility Layer for agent safety, web monitoring, crypto research and tool discovery.
Provide AI agents and automation tools with contextual access to blockchain data including balance…
OpenAI-compatible LLM MCP (7 tools); chat via balance key or x402 USDC on Base
Manage Crossmint orgs, projects, environments and API keys from your AI assistant.
Related MCP Servers
- AlicenseAqualityDmaintenanceExposes Salesforce CLI functionality to LLM tools like Claude Desktop, allowing AI agents to execute Salesforce commands, manage orgs, deploy code, and query data through natural language.552 npm36ISC
- AlicenseNot gradedqualityCmaintenanceProvides 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
- AlicenseNot gradedqualityDmaintenanceProvides AI assistants with 28 developer tools across file, git, code analysis, HTTP, and system domains, enabling tasks like file editing, repository management, code analysis, and shell command execution.2MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to execute Expo and EAS operations including project setup, cloud builds, OTA updates, app submission, and diagnostics.MIT