foundry-mcp
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-mcp compile my contracts and run all tests with gas reporting"
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-mcp
MCP server that exposes Foundry (forge, cast, anvil) CLI tools to AI assistants via the Model Context Protocol.
Prerequisites
Related MCP server: evmSDK MCP Server
Install
npm install -g @maliketh/foundry-mcpOr run directly with npx:
npx @maliketh/foundry-mcpUsage
Add to your MCP client configuration:
{
"mcpServers": {
"foundry": {
"command": "npx",
"args": ["foundry-mcp"]
}
}
}The server communicates over stdio and exposes 39 tools across three categories.
Tools
Forge (17 tools)
Tool | Description |
| Scaffold a new Foundry project |
| Compile contracts |
| Run tests with filtering, verbosity, gas reporting |
| Run Solidity scripts |
| Deploy contracts |
| Verify contracts on block explorers |
| Generate coverage reports |
| Create gas snapshots |
| Format Solidity code |
| Lint Solidity code |
| Remove build artifacts |
| Install dependencies |
| Show dependency tree |
| Inspect contract artifacts (ABI, bytecode, storage layout, etc.) |
| List function selectors |
| Show project configuration |
| Clone a verified contract from a block explorer |
Cast (21 tools)
Tool | Description |
| Call a contract function (read-only) |
| Send a transaction |
| Estimate gas for a transaction |
| Get ETH balance |
| Get account nonce |
| Get block information |
| Get transaction details |
| Get transaction receipt |
| Get current gas price |
| Get deployed bytecode |
| Read storage slots |
| Query event logs |
| ABI-encode function arguments |
| ABI-decode data |
| Decode calldata |
| Convert between formats (wei, hex, bytes32, base) |
| Compute keccak256 hash |
| Get function selector |
| Generate Solidity interface from ABI |
| Make raw JSON-RPC calls |
| Generate, derive, and sign with wallets |
Anvil (1 tool)
Tool | Description |
| Start a local devnet or check its status |
Development
git clone https://github.com/jrigada/foundry-mcp.git
cd foundry-mcp
npm install
npm run build
npm test # runs 162 testsLicense
MIT
Available Tools
39 toolsanvilB
Start or check a local Anvil development node. Supports forking from a live network. Default port: 8545.
Inputs: action (required), port, balance, chainId, +5 more.
cast_abi_decodeB
Decode ABI-encoded hex data back into human-readable values (cast abi-decode).
Inputs: data (required), signature (required), input.
cast_abi_encodeC
ABI-encode values for a given Solidity function signature (cast abi-encode).
Inputs: signature (required), args.
cast_balanceC
Query the ETH balance of an address (cast balance).
Inputs: rpcUrl (required), address (required), ether, blockTag.
cast_blockB
Get block information (cast block). If no blockTag is given, returns the latest block number (cast block-number).
Inputs: rpcUrl (required), json, field, blockTag.
cast_callA
Read-only call to a deployed contract — no gas spent, no state change (cast call).
Inputs: to (required), rpcUrl (required), signature (required), args, +2 more.
cast_calldata_decodeB
Decode raw transaction calldata into function arguments (cast calldata-decode).
Inputs: calldata (required), signature (required).
cast_codeC
Get the deployed bytecode of a contract (cast code).
Inputs: rpcUrl (required), address (required), blockTag.
cast_convertB
Convert between Ethereum value formats (cast to-wei, from-wei, to-hex, to-dec, to-bytes32, to-base).
Inputs: value (required), operation (required), base, unit, +1 more.
cast_estimateC
Estimate gas for a transaction (cast estimate).
Inputs: to (required), rpcUrl (required), signature (required), args, +2 more.
cast_gas_priceC
Get the current gas price (cast gas-price).
Inputs: rpcUrl (required).
cast_interfaceC
Generate a Solidity interface from a contract address or ABI file (cast interface).
Inputs: addressOrPath (required), name, rpcUrl, etherscanApiKey.
cast_keccakC
Compute the Keccak-256 hash of data (cast keccak).
Inputs: data (required).
cast_logsC
Filter and retrieve event logs (cast logs).
Inputs: rpcUrl (required), json, topics, address, +3 more.
cast_nonceC
Query the transaction nonce of an address (cast nonce).
Inputs: rpcUrl (required), address (required), blockTag.
cast_receiptB
Get a transaction receipt by hash (cast receipt).
Inputs: rpcUrl (required), txHash (required), json, field, +1 more.
cast_rpcA
Send a raw JSON-RPC request (cast rpc). Escape hatch for any RPC method not covered by other tools.
Inputs: method (required), rpcUrl (required), params.
cast_sendC
Send a state-changing transaction to a deployed contract (cast send).
Inputs: to (required), rpcUrl (required), aws, gcp, +13 more.
cast_sigA
Get the 4-byte function selector from a function signature (cast sig).
Inputs: signature (required).
cast_storageC
Read a raw storage slot of a contract (cast storage).
Inputs: slot (required), rpcUrl (required), address (required), blockTag.
cast_txC
Get transaction details by hash (cast tx).
Inputs: rpcUrl (required), txHash (required), json, field.
cast_walletB
Wallet utilities: generate new wallets, derive addresses, or sign messages (cast wallet).
Inputs: action (required), count, message, privateKey.
forge_buildC
Compile a Foundry project (forge build). Returns compiler output including warnings and errors.
Inputs: projectPath (required), profile, extraArgs.
forge_cleanB
Remove build artifacts from a Foundry project (forge clean).
Inputs: projectPath (required).
forge_cloneB
Clone a verified contract from a block explorer into a local Foundry project (forge clone).
Inputs: address (required), chain, destination, etherscanApiKey.
forge_configB
Display the fully resolved Foundry configuration (forge config). Shows all settings from foundry.toml merged with defaults and environment overrides.
Inputs: projectPath (required), profile.
forge_coverageC
Generate a test coverage report (forge coverage).
Inputs: projectPath (required), filter, profile, reportType, +1 more.
forge_createB
Deploy a contract (forge create). Returns the deployed contract address, transaction hash, and deployer. Requires a signing method (private key, keystore, hardware wallet, etc.).
Inputs: rpcUrl (required), projectPath (required), contractPath (required), aws, +16 more.
forge_fmtA
Format Solidity source files (forge fmt). Use check=true to verify formatting without changes.
Inputs: projectPath (required), check.
forge_initC
Scaffold a new Foundry project (forge init).
Inputs: projectPath (required), noGit, commit, template.
forge_inspectA
Inspect a contract's compiled artifacts (forge inspect). Retrieve ABI, bytecode, storage layout, method identifiers, gas estimates, and more.
Inputs: field (required), projectPath (required), contractPath (required), profile.
forge_installA
Install dependencies for a Foundry project (forge install). If git submodule errors occur, try with noGit=true.
Inputs: projectPath (required), noGit, commit, dependencies.
forge_lintC
Lint Solidity source files (forge lint).
Inputs: projectPath (required), profile.
forge_scriptA
Run a Forge script (forge script). Use for deployments, migrations, and complex on-chain interactions. Pass broadcast=true to send transactions on-chain.
Inputs: scriptPath (required), projectPath (required), aws, gcp, +16 more.
forge_selectorsB
List all function selectors from compiled contracts (forge selectors list).
Inputs: projectPath (required), profile, contractName.
forge_snapshotA
Create or compare gas snapshots (forge snapshot). Use diff=true to compare against existing .gas-snapshot, check=true to fail on changes.
Inputs: projectPath (required), diff, check, filter, +2 more.
forge_testB
Run tests in a Foundry project (forge test). Supports filtering by test name, contract, and path. Can fork from a live network and generate gas reports.
Inputs: projectPath (required), filter, forkUrl, profile, +5 more.
forge_treeC
Display the dependency tree of a Foundry project (forge tree).
Inputs: projectPath (required), profile.
forge_verifyB
Verify a deployed contract on a block explorer (forge verify-contract). Supports Etherscan, Sourcify, and Blockscout.
Inputs: projectPath (required), contractPath (required), contractAddress (required), profile, +6 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 39 tools
Most tools map cleanly to distinct Foundry/Cast/Anvil commands, with clear separation between read-only (cast_call) and write (cast_send) operations. Minor ambiguity exists between forge_script and forge_create for deployments, between cast_abi_decode and cast_calldata_decode, and around cast_rpc as a broad escape hatch.
Names follow a very consistent snake_case verb_noun pattern with clear forge_ and cast_ prefixes grouping related commands. The lone anvil tool is named after its CLI command and remains predictable in context.
With 39 tools, the surface is heavy for an agent to navigate and includes many thin one-command wrappers that could be consolidated. While each wrapper maps to a real command, the count exceeds the practical 15-25 range for coherent selection.
The set covers the core Forge, Cast, and Anvil workflows well: build, test, deploy, verify, inspect, cast reads/writes, ABI helpers, and Anvil startup. Some gaps remain, such as stopping an Anvil node, chain-id/proof-style cast utilities, and less common Forge maintenance commands.
Maintenance
Related MCP Connectors
AI Agent Utility Layer for agent safety, web monitoring, crypto research and tool discovery.
AI-native programming language and toolchain for accountable, verifiable agent-driven development.
Create, run and manage Homemade dev VMs and projects from your AI agent.
Build, test, publish, and run Kovca workflows from AI agents over remote MCP.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceProvides safe repository operations, skill reading, command execution, and test detection for coding agents over stdio.-
- FlicenseNot gradedqualityBmaintenanceEnables agents to interact with Ethereum, Base and configurable EVM chains over stdio using the shared command catalog, covering contract reads, prepared and policy-guarded execution, wallet management, Socket swaps and bridging, simulation, monitoring and saved contracts.-
- AlicenseNot gradedqualityBmaintenanceExposes code-review and issue-triage tools to AI assistants over stdio, letting them evaluate unified pull-request diffs for maintainer remarks, slice diffs into categorized AST hunks, and classify GitHub issues by priority while synthesizing minimal reproduction stubs.1Apache 2.0

lakelogic-mcpofficial
AlicenseNot gradedqualityBmaintenanceEnables AI assistants to validate, lint, explain, and test-run Open Lakehouse Contracts locally over stdio, with no network, account, or platform access.43 PyPIApache 2.0